This (more or less) reverts commit
2b7e016807507b632b8e0a7c874030bdffb2f604.
Stopping the aout from within the callback like this could
lead to deadlocks, where AudioOutputUnitStop in the callback thread
and AudioOutputUnitStart in the audio decoder thread blocked each
other (noticed at startup of playback on a 3GS with iOS 6.0).
Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
/* check if we have enough data */
if (!availableBytes) {
- /* bail out and restart unit the next time we receive some data */
- Flush(p_aout, false);
+ /* return an empty buffer so silence is played until we have data */
+ memset(targetBuffer, 0, bytesToCopy);
} else {
memcpy(targetBuffer, buffer, __MIN(bytesToCopy, availableBytes));
TPCircularBufferConsume(&p_sys->circular_buffer, __MIN(bytesToCopy, availableBytes));