aboutsummaryrefslogtreecommitdiffstats
path: root/src/audiofile_decode.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-10 12:35:18 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-10 12:35:18 +0000
commit2ec1c5ff3c1ff67825fb449c9eab2c3e4ff441f6 (patch)
tree249f15fc84bd307facedee89452cdeb606580e5f /src/audiofile_decode.c
parentcd3180c70180ae49c0c5611850c18ce0cebdd464 (diff)
downloadmpd-2ec1c5ff3c1ff67825fb449c9eab2c3e4ff441f6.tar.gz
mpd-2ec1c5ff3c1ff67825fb449c9eab2c3e4ff441f6.tar.xz
mpd-2ec1c5ff3c1ff67825fb449c9eab2c3e4ff441f6.zip
some more work on organizing code for resampling/audioFormat conversion
git-svn-id: https://svn.musicpd.org/mpd/trunk@968 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/audiofile_decode.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/audiofile_decode.c b/src/audiofile_decode.c
index f3e88395b..b6b459f08 100644
--- a/src/audiofile_decode.c
+++ b/src/audiofile_decode.c
@@ -51,8 +51,7 @@ int getAudiofileTotalTime(char * file)
return time;
}
-int audiofile_decode(OutputBuffer * cb, AudioFormat * af, DecoderControl * dc)
-{
+int audiofile_decode(OutputBuffer * cb, DecoderControl * dc) {
int fs, frame_count;
AFfilehandle af_fp;
int bits;
@@ -71,19 +70,20 @@ int audiofile_decode(OutputBuffer * cb, AudioFormat * af, DecoderControl * dc)
}
afGetSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
- af->bits = bits;
- af->sampleRate = afGetRate(af_fp, AF_DEFAULT_TRACK);
- af->channels = afGetChannels(af_fp,AF_DEFAULT_TRACK);
+ dc->audioFormat.bits = bits;
+ dc->audioFormat.sampleRate = afGetRate(af_fp, AF_DEFAULT_TRACK);
+ dc->audioFormat.channels = afGetChannels(af_fp,AF_DEFAULT_TRACK);
+ getOutputAudioFormat(&(dc->audioFormat),&(cb->audioFormat));
frame_count = afGetFrameCount(af_fp,AF_DEFAULT_TRACK);
- cb->totalTime = ((float)frame_count/(float)af->sampleRate);
+ dc->totalTime = ((float)frame_count/(float)dc->audioFormat.sampleRate);
- bitRate = st.st_size*8.0/cb->totalTime/1000.0+0.5;
+ bitRate = st.st_size*8.0/dc->totalTime/1000.0+0.5;
- if (af->bits != 8 && af->bits != 16) {
+ if (dc->audioFormat.bits != 8 && dc->audioFormat.bits != 16) {
ERROR("Only 8 and 16-bit files are supported. %s is %i-bit\n",
- dc->file,af->bits);
+ dc->file,dc->audioFormat.bits);
afCloseFile(af_fp);
return -1;
}
@@ -100,7 +100,8 @@ int audiofile_decode(OutputBuffer * cb, AudioFormat * af, DecoderControl * dc)
if(dc->seek) {
cb->end = cb->begin;
cb->wrap = 0;
- current = dc->seekWhere * af->sampleRate;
+ current = dc->seekWhere *
+ dc->audioFormat.sampleRate;
afSeekFrame(af_fp, AF_DEFAULT_TRACK,current);
dc->seek = 0;
@@ -111,9 +112,9 @@ int audiofile_decode(OutputBuffer * cb, AudioFormat * af, DecoderControl * dc)
else {
current += ret;
sendDataToOutputBuffer(cb,dc,chunk,ret*fs,
- (float)current /
- (float)af->sampleRate,
- bitRate);
+ (float)current /
+ (float)dc->audioFormat.sampleRate,
+ bitRate);
if(dc->stop) break;
else if(dc->seek) continue;
}