aboutsummaryrefslogtreecommitdiffstats
path: root/src/ogg_decode.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-07 19:11:43 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-07 19:11:43 +0000
commitc9f0d22f0ac19dcee7d1991020c75c8a3691b1b7 (patch)
tree9a7a1f0877821c01c808b6e65420e833fa31f263 /src/ogg_decode.c
parent3794126e5609112d68a2e0c9cbae5a923da301b6 (diff)
downloadmpd-c9f0d22f0ac19dcee7d1991020c75c8a3691b1b7.tar.gz
mpd-c9f0d22f0ac19dcee7d1991020c75c8a3691b1b7.tar.xz
mpd-c9f0d22f0ac19dcee7d1991020c75c8a3691b1b7.zip
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
Diffstat (limited to 'src/ogg_decode.c')
-rw-r--r--src/ogg_decode.c34
1 files changed, 9 insertions, 25 deletions
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 <stdio.h>
#include <unistd.h>
@@ -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,
- &current_section);
+ 2, 1, &current_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) {