mattgallagher / AudioStreamer

A streaming audio player class (AudioStreamer) for Mac OS X and iPhone.
http://cocoawithlove.com
1.93k stars 553 forks source link

Off by one in handleAudioPackets #22

Open ragnar opened 13 years ago

ragnar commented 13 years ago

Seems like there is a off by one test in handleAudioPackets.

diff --git a/Classes/AudioStreamer.m b/Classes/AudioStreamer.m
index 3985ec0..dedfc54 100644
--- a/Classes/AudioStreamer.m
+++ b/Classes/AudioStreamer.m
@@ -1731,7 +1731,7 @@ - (void)handleAudioPackets:(const void *)inInputData
                                // If there was some kind of issue with enqueueBuffer and we didn't
                                // make space for the new audio data then back out
                                //
-                               if (bytesFilled + packetSize >= packetBufferSize)
+                               if (bytesFilled + packetSize > packetBufferSize)
                                {
                                        return;
                                }

When the bytesFilled + packetSize == packetBufferSize the buffer won't be enqueued and there is glitches in the audio stream.

best regards,

-ragnar-