I use CMdaAudioOutputStream for my audio. I need to know when I can call Stop to stream.
I write to stream with chunks of size 4096 (or less) and on timer events I look on stream position in bytes - GetBytes(). Comparing with bytes totally passed to audio device I can see that all my streams have been played and I can close streaming. What I see is stream playing is stuck and never comes to end. From stream to stream bytes difference is in range form 100b to 10kb. So I have artifacts on my sound.
I looked at implementation of working with audio streaming in SDL - they use empty buffer (256 bytes of zeros) to write to stream when there is no data for streaming. Using this approach gives me continuous stream playing but different artifacts on end of stream still appear.
Why it is happening when stream playing stops (all buffers are written to device but not all of them rendered) when you stop calling WriteL?



