ap4y / OrigamiEngine

Lightweight audio engine for iOS and OSX with flac, cue, mp3, m4a, m3u support.
http://ap4y.github.com/OrigamiEngine/
MIT License
545 stars 118 forks source link

Gapless playback over HTTP #53

Open alecgorge opened 9 years ago

alecgorge commented 9 years ago

I would like to eliminate the small blip between two MP3's streamed over HTTP.

My guess was that there isn't enough time for the HTTP request to load enough data between the EOF of the first source and end of playback for the first source for the second source to load data over HTTP.

Based on this hunch, I multiplied CHUNK_SIZE and BUFFER_SIZE by 4:

// default reading chunk size
#define CHUNK_SIZE 16 * 1024 * 4
// deault buffer size
#define BUFFER_SIZE 256 * 1024 * 4

This gives gapless playback from cache and over HTTP. However, seek didn't seem to behave properly until I used [_player seekToTime:seekSlider.value withDataFlush:YES].

Are there any downsides to this approach?

squarefrog commented 9 years ago

This seems to work really well. I presume the only noticable downside to this is OrigamiEngine uses more memory?

alecgorge commented 9 years ago

A little more, yeah. The other thing I noticed is initial playback and starting playback after seeking takes a little longer due to the increased sizes, but that is acceptable for what I need to do.