aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-10 19:41:27 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-10 19:41:27 +0000
commitbe5bfc35fd789a4b8dccf2a7cfb7cb3c1b17f1cd (patch)
treea2d880ab4562d9d481cd6e24804a3d42efa2b442
parent85f2ce820f7299c1b10ce71c606dfc0f36e7fc74 (diff)
downloadmpd-be5bfc35fd789a4b8dccf2a7cfb7cb3c1b17f1cd.tar.gz
mpd-be5bfc35fd789a4b8dccf2a7cfb7cb3c1b17f1cd.tar.xz
mpd-be5bfc35fd789a4b8dccf2a7cfb7cb3c1b17f1cd.zip
some fixes for ogg_decode
git-svn-id: https://svn.musicpd.org/mpd/trunk@976 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/ogg_decode.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/ogg_decode.c b/src/ogg_decode.c
index 2869be7cb..10e90a20e 100644
--- a/src/ogg_decode.c
+++ b/src/ogg_decode.c
@@ -181,7 +181,8 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc)
int current_section;
int eof = 0;
long ret;
- char chunk[CHUNK_SIZE];
+#define OGG_CHUNK_SIZE 2048
+ char chunk[OGG_CHUNK_SIZE];
int chunkpos = 0;
long bitRate = 0;
long test;
@@ -196,22 +197,35 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc)
ov_time_seek_page(&vf,dc->seekWhere);
dc->seek = 0;
}
- ret = ov_read(&vf, chunk, CHUNK_SIZE,
+ ret = ov_read(&vf, chunk+chunkpos,
+ OGG_CHUNK_SIZE-chunkpos,
OGG_DECODE_USE_BIGENDIAN,
2, 1, &current_section);
- if(ret<=0) eof = 1;
- else {
+ if(ret<=0) {
+ eof = 1;
+ break;
+ }
+
+ chunkpos+=ret;
+
+ if(chunkpos >= OGG_CHUNK_SIZE) {
if((test = ov_bitrate_instant(&vf))>0) {
bitRate = test/1000;
}
doReplayGain(chunk,ret,&(dc->audioFormat),
replayGainScale);
- sendDataToOutputBuffer(cb,dc,chunk,ret,
+ sendDataToOutputBuffer(cb,dc,chunk,chunkpos,
ov_time_tell(&vf),bitRate);
if(dc->stop) break;
+ chunkpos = 0;
}
}
+ if(!dc->stop && chunkpos > 0) {
+ sendDataToOutputBuffer(cb,dc,chunk,chunkpos,
+ ov_time_tell(&vf),bitRate);
+ }
+
ov_clear(&vf);
flushOutputBuffer(cb);