From c9f0d22f0ac19dcee7d1991020c75c8a3691b1b7 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Fri, 7 May 2004 19:11:43 +0000 Subject: rewrite outputBuffer'ing abstraction a bit to be more effecient and easier to interface. Also, use outputBuffer abstraction for ogg git-svn-id: https://svn.musicpd.org/mpd/trunk@941 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/ogg_decode.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) (limited to 'src/ogg_decode.c') diff --git a/src/ogg_decode.c b/src/ogg_decode.c index 5aad02f78..709fbac23 100644 --- a/src/ogg_decode.c +++ b/src/ogg_decode.c @@ -26,6 +26,7 @@ #include "log.h" #include "pcm_utils.h" #include "inputStream.h" +#include "outputBuffer.h" #include #include @@ -132,41 +133,24 @@ int ogg_decode(OutputBuffer * cb, AudioFormat * af, DecoderControl * dc) ov_time_seek_page(&vf,dc->seekWhere); dc->seek = 0; } - ret = ov_read(&vf,chunk+chunkpos, - CHUNK_SIZE-chunkpos, + ret = ov_read(&vf, chunk, CHUNK_SIZE, OGG_DECODE_USE_BIGENDIAN, - 2,1, - ¤t_section); + 2, 1, ¤t_section); if(ret<=0) eof = 1; - else chunkpos+=ret; - if(chunkpos>=CHUNK_SIZE || eof) { - while(cb->begin==cb->end && cb->wrap && - !dc->stop && !dc->seek) - { - my_usleep(10000); - } - if(dc->stop) break; - else if(dc->seek) continue; - - memcpy(cb->chunks+cb->end*CHUNK_SIZE, - chunk,chunkpos); - cb->chunkSize[cb->end] = chunkpos; - chunkpos = 0; - cb->times[cb->end] = ov_time_tell(&vf); + else { if((test = ov_bitrate_instant(&vf))>0) { bitRate = test/1000; } - cb->bitRate[cb->end] = bitRate; - cb->end++; - if(cb->end>=buffered_chunks) { - cb->end = 0; - cb->wrap = 1; - } + sendDataToOutputBuffer(cb,dc,chunk,ret, + ov_time_tell(&vf),bitRate); + if(dc->stop) break; } } ov_clear(&vf); + flushOutputBuffer(cb); + if(dc->seek) dc->seek = 0; if(dc->stop) { -- cgit v1.2.3