aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-19 22:03:27 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-19 22:03:27 +0000
commitc1fbcd03f04cfb11401174e40f7d451ee3abfff5 (patch)
tree3b664e3b6c46e89990fe4b5348f8bf5e47d2ba86 /src
parent3e659738ba2f02399b98f09873eb4ee2de832430 (diff)
downloadmpd-c1fbcd03f04cfb11401174e40f7d451ee3abfff5.tar.gz
mpd-c1fbcd03f04cfb11401174e40f7d451ee3abfff5.tar.xz
mpd-c1fbcd03f04cfb11401174e40f7d451ee3abfff5.zip
todo update and make firstFrame in mp3_decode less blocky!
git-svn-id: https://svn.musicpd.org/mpd/trunk@1098 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/mp3_decode.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/mp3_decode.c b/src/mp3_decode.c
index 23bed6bac..33c309e7b 100644
--- a/src/mp3_decode.c
+++ b/src/mp3_decode.c
@@ -332,7 +332,7 @@ fail:
return 0;
}
-int decodeFirstFrame(mp3DecodeData * data) {
+int decodeFirstFrame(mp3DecodeData * data, DecoderControl * dc) {
struct xing xing;
int ret;
int skip;
@@ -342,10 +342,12 @@ int decodeFirstFrame(mp3DecodeData * data) {
while(1) {
skip = 0;
- while((ret = decodeNextFrameHeader(data))==DECODE_CONT);
+ while((ret = decodeNextFrameHeader(data))==DECODE_CONT &&
+ (!dc || !dc->stop));
if(ret==DECODE_SKIP) skip = 1;
else if(ret==DECODE_BREAK) return -1;
- while((ret = decodeNextFrame(data))==DECODE_CONT);
+ while((ret = decodeNextFrame(data))==DECODE_CONT &&
+ (!dc || !dc->stop));
if(ret==DECODE_BREAK) return -1;
if(!skip && ret==DECODE_OK) break;
}
@@ -407,16 +409,18 @@ int getMp3TotalTime(char * file) {
if(openInputStream(&inStream, file) < 0) return -1;
initMp3DecodeData(&data,&inStream);
- if(decodeFirstFrame(&data)<0) ret = -1;
+ if(decodeFirstFrame(&data, NULL)<0) ret = -1;
else ret = data.totalTime+0.5;
mp3DecodeDataFinalize(&data);
return ret;
}
-int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data) {
+int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data,
+ DecoderControl * dc)
+{
initMp3DecodeData(data, inStream);
- if(decodeFirstFrame(data)<0) {
+ if(decodeFirstFrame(data, dc)<0) {
mp3DecodeDataFinalize(data);
return -1;
}
@@ -550,7 +554,7 @@ void initAudioFormatFromMp3DecodeData(mp3DecodeData * data, AudioFormat * af) {
int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) {
mp3DecodeData data;
- if(openMp3FromInputStream(inStream, &data) < 0) {
+ if(openMp3FromInputStream(inStream, &data, dc) < 0) {
ERROR("Input does not appear to be a mp3 bit stream.\n");
closeInputStream(inStream);
return -1;