diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-03-05 16:02:47 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-03-05 16:02:47 +0000 |
commit | 09efb14dbbbbcbf1d96bbb0932009ab25e76868a (patch) | |
tree | 8dc4ec149eb09324387800a3b6ad8dc52f671dc7 /src/ogg_decode.c | |
parent | 8b214b7c8c9740836b398c914d982f471b3d985c (diff) | |
download | mpd-09efb14dbbbbcbf1d96bbb0932009ab25e76868a.tar.gz mpd-09efb14dbbbbcbf1d96bbb0932009ab25e76868a.tar.xz mpd-09efb14dbbbbcbf1d96bbb0932009ab25e76868a.zip |
fix crossfading issue with ogg
problem was, ov_read doesn't always fill to CHUNK_SIZE
and we were moving chunk on every ov_read, instead now we only
dump the buffer when its full
git-svn-id: https://svn.musicpd.org/mpd/trunk@206 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/ogg_decode.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ogg_decode.c b/src/ogg_decode.c index 158428beb..c9cf0016c 100644 --- a/src/ogg_decode.c +++ b/src/ogg_decode.c @@ -63,6 +63,7 @@ int ogg_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) int eof = 0; long ret; char chunk[CHUNK_SIZE]; + int chunkpos = 0; long bitRate = 0; long test; @@ -70,13 +71,17 @@ int ogg_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) if(dc->seek) { cb->end = 0; cb->wrap = 0; + chunkpos = 0; ov_time_seek_page(&vf,dc->seekWhere); dc->seek = 0; } - ret = ov_read(&vf,chunk,CHUNK_SIZE,0,2,1, + ret = ov_read(&vf,chunk+chunkpos, + CHUNK_SIZE-chunkpos, + 0,2,1, ¤t_section); if(ret<=0) eof = 1; - else { + else chunkpos+=ret; + if(chunkpos>=CHUNK_SIZE || eof) { while(cb->begin==cb->end && cb->wrap && !dc->stop && !dc->seek) { @@ -89,8 +94,9 @@ int ogg_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) af->bits); #endif memcpy(cb->chunks+cb->end*CHUNK_SIZE, - chunk,CHUNK_SIZE); - cb->chunkSize[cb->end] = ret; + chunk,chunkpos); + cb->chunkSize[cb->end] = chunkpos; + chunkpos = 0; cb->times[cb->end] = ov_time_tell(&vf); if((test = ov_bitrate_instant(&vf))>0) { bitRate = test/1000; |