aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-03-22 05:08:14 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-03-22 05:08:14 +0000
commit80e0fec6835f15e6a81ca1dd24db726c503a56be (patch)
tree32c34222c48566ddbb2945b37f2cfc329cfbb507 /src
parent097c8720ef546d455ec1e6373001d941ba41df1f (diff)
downloadmpd-80e0fec6835f15e6a81ca1dd24db726c503a56be.tar.gz
mpd-80e0fec6835f15e6a81ca1dd24db726c503a56be.tar.xz
mpd-80e0fec6835f15e6a81ca1dd24db726c503a56be.zip
a few aac/mp4 minor fixes
don't set audioFormat till decode first frame git-svn-id: https://svn.musicpd.org/mpd/trunk@359 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r--src/aac_decode.c24
-rw-r--r--src/mp4_decode.c26
2 files changed, 33 insertions, 17 deletions
diff --git a/src/aac_decode.c b/src/aac_decode.c
index d52aebd49..fe8ede2fd 100644
--- a/src/aac_decode.c
+++ b/src/aac_decode.c
@@ -301,14 +301,10 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
return -1;
}
- af->sampleRate = sampleRate;
- af->channels = channels;
af->bits = 16;
cb->totalTime = totalTime;
- dc->state = DECODE_STATE_DECODE;
- dc->start = 0;
time = 0.0;
advanceAacBuffer(&b,bread);
@@ -322,7 +318,6 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
sampleBuffer = faacDecDecode(decoder,&frameInfo,b.buffer,
b.bytesIntoBuffer);
- advanceAacBuffer(&b,frameInfo.bytesconsumed);
if(frameInfo.error > 0) {
ERROR("error decoding AAC file: %s\n",dc->file);
@@ -332,6 +327,15 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
break;
}
+ if(dc->start) {
+ af->channels = frameInfo.channels;
+ af->sampleRate = frameInfo.samplerate;
+ dc->state = DECODE_STATE_DECODE;
+ dc->start = 0;
+ }
+
+ advanceAacBuffer(&b,frameInfo.bytesconsumed);
+
sampleCount = (unsigned long)(frameInfo.samples);
if(sampleCount>0) {
@@ -383,6 +387,12 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
if(b.bytesIntoBuffer==0) eof = 1;
} while (!eof);
+ faacDecClose(decoder);
+ fclose(b.infile);
+ if(b.buffer) free(b.buffer);
+
+ if(dc->start) return -1;
+
if(!dc->stop && !dc->seek && chunkLen>0) {
cb->chunkSize[cb->end] = chunkLen;
++cb->end;
@@ -394,10 +404,6 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
chunkLen = 0;
}
- faacDecClose(decoder);
- fclose(b.infile);
- if(b.buffer) free(b.buffer);
-
if(dc->seek) dc->seek = 0;
if(dc->stop) {
diff --git a/src/mp4_decode.c b/src/mp4_decode.c
index 0e9ba0a1b..e9e3d22eb 100644
--- a/src/mp4_decode.c
+++ b/src/mp4_decode.c
@@ -174,8 +174,6 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
numSamples = mp4ff_num_samples(mp4fh,track);
- dc->state = DECODE_STATE_DECODE;
- dc->start = 0;
time = 0.0;
seekTable = malloc(sizeof(float)*numSamples);
@@ -224,6 +222,16 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
sampleBuffer = faacDecDecode(decoder,&frameInfo,mp4Buffer,
mp4BufferSize);
+
+ if(dc->start) {
+ channels = frameInfo.channels;
+ scale = frameInfo.samplerate;
+ af->channels = frameInfo.channels;
+ af->sampleRate = frameInfo.samplerate;
+ dc->state = DECODE_STATE_DECODE;
+ dc->start = 0;
+ }
+
if(mp4Buffer) free(mp4Buffer);
if(frameInfo.error > 0) {
ERROR("error decoding MP4 file: %s\n",dc->file);
@@ -287,6 +295,14 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
}
}
+ free(seekTable);
+ faacDecClose(decoder);
+ mp4ff_close(mp4fh);
+ fclose(fh);
+ free(mp4cb);
+
+ if(dc->start) return -1;
+
if(!dc->stop && !dc->seek && chunkLen>0) {
cb->chunkSize[cb->end] = chunkLen;
++cb->end;
@@ -298,12 +314,6 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
chunkLen = 0;
}
- free(seekTable);
- faacDecClose(decoder);
- mp4ff_close(mp4fh);
- fclose(fh);
- free(mp4cb);
-
if(dc->seek) dc->seek = 0;
if(dc->stop) {