@@ -318,7 +318,7 @@ void SoundDeviceNetwork::workerWriteProcess(NetworkOutputStreamWorkerPtr pWorker
318318 // << "Catch up with silence:" << writeExpected - copyCount
319319 // << "streamTime" << pWorker->getStreamTimeFrames();;
320320 // catch up by filling buffer until we are synced
321- workerWriteSilence (pWorker, writeExpected - copyCount);
321+ workerWriteSilence (pWorker, ( writeExpected - copyCount) / m_numOutputChannels );
322322 m_pSoundManager->underflowHappened (24 );
323323 } else if (writeExpected - copyCount > outChunkSize / 2 ) {
324324 // try to keep PAs buffer filled up to 0.5 chunks
@@ -327,7 +327,7 @@ void SoundDeviceNetwork::workerWriteProcess(NetworkOutputStreamWorkerPtr pWorker
327327 // kLogger.debug() << "workerWriteProcess() duplicate one frame"
328328 // << (float)writeExpected / outChunkSize
329329 // << (float)readAvailable / outChunkSize;
330- workerWrite (pWorker, dataPtr1, m_numOutputChannels );
330+ workerWrite (pWorker, dataPtr1, 1 );
331331 } else {
332332 pWorker->setOutputDrift (true );
333333 }
@@ -349,9 +349,9 @@ void SoundDeviceNetwork::workerWriteProcess(NetworkOutputStreamWorkerPtr pWorker
349349 pWorker->setOutputDrift (false );
350350 }
351351
352- workerWrite (pWorker, dataPtr1, size1);
352+ workerWrite (pWorker, dataPtr1, size1 / m_numOutputChannels );
353353 if (size2 > 0 ) {
354- workerWrite (pWorker, dataPtr2, size2);
354+ workerWrite (pWorker, dataPtr2, size2 / m_numOutputChannels );
355355 }
356356
357357 QSharedPointer<FIFO <CSAMPLE >> pFifo = pWorker->getOutputFifo ();
@@ -368,17 +368,16 @@ void SoundDeviceNetwork::workerWriteProcess(NetworkOutputStreamWorkerPtr pWorker
368368}
369369
370370void SoundDeviceNetwork::workerWrite (NetworkOutputStreamWorkerPtr pWorker,
371- const CSAMPLE * buffer,
372- SINT samples) {
371+ const CSAMPLE * buffer, int frames) {
373372 if (!pWorker->threadWaiting ()) {
374- pWorker->addFramesWritten (samples / m_numOutputChannels );
373+ pWorker->addFramesWritten (frames );
375374 return ;
376375 }
377376
378377 QSharedPointer<FIFO <CSAMPLE >> pFifo = pWorker->getOutputFifo ();
379378 if (pFifo) {
380379 int writeAvailable = pFifo->writeAvailable ();
381- int writeRequired = samples ;
380+ int writeRequired = frames * m_numOutputChannels ;
382381 if (writeAvailable < writeRequired) {
383382 kLogger .warning () << " write: worker buffer full, losing samples" ;
384383 pWorker->incOverflowCount ();
@@ -396,16 +395,16 @@ void SoundDeviceNetwork::workerWrite(NetworkOutputStreamWorkerPtr pWorker,
396395 }
397396}
398397
399- void SoundDeviceNetwork::workerWriteSilence (NetworkOutputStreamWorkerPtr pWorker, SINT samples ) {
398+ void SoundDeviceNetwork::workerWriteSilence (NetworkOutputStreamWorkerPtr pWorker, int frames ) {
400399 if (!pWorker->threadWaiting ()) {
401- pWorker->addFramesWritten (samples / m_numOutputChannels );
400+ pWorker->addFramesWritten (frames );
402401 return ;
403402 }
404403
405404 QSharedPointer<FIFO <CSAMPLE >> pFifo = pWorker->getOutputFifo ();
406405 if (pFifo) {
407406 int writeAvailable = pFifo->writeAvailable ();
408- int writeRequired = samples ;
407+ int writeRequired = frames * m_numOutputChannels ;
409408 if (writeAvailable < writeRequired) {
410409 kLogger .warning () << " writeSilence: worker buffer full, losing samples" ;
411410 pWorker->incOverflowCount ();
0 commit comments