aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins/audiofile_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:05 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:05 +0200
commit4590a98f0eb9484e185e7e0c25a3373c8e9076ea (patch)
tree94ea0d53bdf0b7f9b81ff679b0fb4466d971b1e5 /src/inputPlugins/audiofile_plugin.c
parent0d45870cea6836cd48e6953f4e67756b2502e22c (diff)
downloadmpd-4590a98f0eb9484e185e7e0c25a3373c8e9076ea.tar.gz
mpd-4590a98f0eb9484e185e7e0c25a3373c8e9076ea.tar.xz
mpd-4590a98f0eb9484e185e7e0c25a3373c8e9076ea.zip
added audio_format parameter to decoder_initialized()
dc->audioFormat is set once by the decoder plugins before invoking decoder_initialized(); hide dc->audioFormat and let the decoder pass an AudioFormat pointer to decoder_initialized().
Diffstat (limited to 'src/inputPlugins/audiofile_plugin.c')
-rw-r--r--src/inputPlugins/audiofile_plugin.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c
index 696621aff..f96ea2fca 100644
--- a/src/inputPlugins/audiofile_plugin.c
+++ b/src/inputPlugins/audiofile_plugin.c
@@ -45,6 +45,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
int fs, frame_count;
AFfilehandle af_fp;
int bits;
+ AudioFormat audio_format;
mpd_uint16 bitRate;
struct stat st;
@@ -62,30 +63,30 @@ static int audiofile_decode(struct decoder * decoder, char *path)
afSetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK,
AF_SAMPFMT_TWOSCOMP, 16);
afGetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
- dc.audioFormat.bits = (mpd_uint8)bits;
- dc.audioFormat.sampleRate =
+ audio_format.bits = (mpd_uint8)bits;
+ audio_format.sampleRate =
(unsigned int)afGetRate(af_fp, AF_DEFAULT_TRACK);
- dc.audioFormat.channels =
+ audio_format.channels =
(mpd_uint8)afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK);
- getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat));
frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK);
dc.totalTime =
- ((float)frame_count / (float)dc.audioFormat.sampleRate);
+ ((float)frame_count / (float)audio_format.sampleRate);
bitRate = (mpd_uint16)(st.st_size * 8.0 / dc.totalTime / 1000.0 + 0.5);
- if (dc.audioFormat.bits != 8 && dc.audioFormat.bits != 16) {
+ if (audio_format.bits != 8 && audio_format.bits != 16) {
ERROR("Only 8 and 16-bit files are supported. %s is %i-bit\n",
- path, dc.audioFormat.bits);
+ path, audio_format.bits);
afCloseFile(af_fp);
return -1;
}
fs = (int)afGetVirtualFrameSize(af_fp, AF_DEFAULT_TRACK, 1);
- decoder_initialized(decoder);
+ decoder_initialized(decoder, &audio_format);
+
{
int ret, eof = 0, current = 0;
char chunk[CHUNK_SIZE];
@@ -94,7 +95,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
if (dc.command == DECODE_COMMAND_SEEK) {
decoder_clear(decoder);
current = dc.seekWhere *
- dc.audioFormat.sampleRate;
+ audio_format.sampleRate;
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
dc_command_finished();
}
@@ -110,7 +111,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
1,
chunk, ret * fs,
(float)current /
- (float)dc.audioFormat.
+ (float)audio_format.
sampleRate, bitRate,
NULL);
if (dc.command == DECODE_COMMAND_STOP)