aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/audiofile_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-14 23:22:14 +0100
committerMax Kellermann <max@duempel.org>2009-11-14 23:22:14 +0100
commit2c1fb48318436a7e7872acdf4ffd81817f7fab52 (patch)
tree85f43da8f033e57bb3211624633c5070d7b369f3 /src/decoder/audiofile_plugin.c
parent1dfadf4815f5a1ca18f235bc839e9e20dd68ecb0 (diff)
downloadmpd-2c1fb48318436a7e7872acdf4ffd81817f7fab52.tar.gz
mpd-2c1fb48318436a7e7872acdf4ffd81817f7fab52.tar.xz
mpd-2c1fb48318436a7e7872acdf4ffd81817f7fab52.zip
decoder/audiofile: moved code to audiofile_setup_sample_format()
Diffstat (limited to '')
-rw-r--r--src/decoder/audiofile_plugin.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/decoder/audiofile_plugin.c b/src/decoder/audiofile_plugin.c
index 058f87813..4ef471f46 100644
--- a/src/decoder/audiofile_plugin.c
+++ b/src/decoder/audiofile_plugin.c
@@ -101,6 +101,25 @@ setup_virtual_fops(struct input_stream *stream)
return vf;
}
+static uint8_t
+audiofile_setup_sample_format(AFfilehandle af_fp)
+{
+ int fs, bits;
+
+ afGetSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
+ if (!audio_valid_sample_format(bits)) {
+ g_debug("input file has %d bit samples, converting to 16",
+ bits);
+ bits = 16;
+ }
+
+ afSetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK,
+ AF_SAMPFMT_TWOSCOMP, bits);
+ afGetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
+
+ return bits;
+}
+
static void
audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
{
@@ -129,16 +148,7 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
return;
}
- afGetSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
- if (!audio_valid_sample_format(bits)) {
- g_debug("input file has %d bit samples, converting to 16",
- bits);
- bits = 16;
- }
-
- afSetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK,
- AF_SAMPFMT_TWOSCOMP, bits);
- afGetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
+ bits = audiofile_setup_sample_format(af_fp);
if (!audio_format_init_checked(&audio_format,
afGetRate(af_fp, AF_DEFAULT_TRACK),