diff options
author | Max Kellermann <max@duempel.org> | 2009-11-10 17:11:34 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-12-02 22:29:50 +0100 |
commit | c412d6251e9cd3abe735b7622af4003502e54f72 (patch) | |
tree | 7344c13f62e4cc788c830c05d21bb7b5b47f5866 /src/decoder/audiofile_plugin.c | |
parent | 68c2cfbb4067b2292e1ff1d4e7716ff370903f84 (diff) | |
download | mpd-c412d6251e9cd3abe735b7622af4003502e54f72.tar.gz mpd-c412d6251e9cd3abe735b7622af4003502e54f72.tar.xz mpd-c412d6251e9cd3abe735b7622af4003502e54f72.zip |
audio_format: changed "bits" to "enum sample_format"
This patch prepares support for floating point samples (and probably
other formats). It changes the meaning of the "bits" attribute from a
bit count to a symbolic value.
Diffstat (limited to 'src/decoder/audiofile_plugin.c')
-rw-r--r-- | src/decoder/audiofile_plugin.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/decoder/audiofile_plugin.c b/src/decoder/audiofile_plugin.c index 5a2096d00..fcb431db7 100644 --- a/src/decoder/audiofile_plugin.c +++ b/src/decoder/audiofile_plugin.c @@ -101,13 +101,33 @@ setup_virtual_fops(struct input_stream *stream) return vf; } -static uint8_t +static enum sample_format +audiofile_bits_to_sample_format(int bits) +{ + switch (bits) { + case 8: + return SAMPLE_FORMAT_S8; + + case 16: + return SAMPLE_FORMAT_S16; + + case 24: + return SAMPLE_FORMAT_S24_P32; + + case 32: + return SAMPLE_FORMAT_S32; + } + + return SAMPLE_FORMAT_UNDEFINED; +} + +static enum sample_format audiofile_setup_sample_format(AFfilehandle af_fp) { int fs, bits; afGetSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits); - if (!audio_valid_sample_format(bits)) { + if (!audio_valid_sample_format(audiofile_bits_to_sample_format(bits))) { g_debug("input file has %d bit samples, converting to 16", bits); bits = 16; @@ -117,7 +137,7 @@ audiofile_setup_sample_format(AFfilehandle af_fp) AF_SAMPFMT_TWOSCOMP, bits); afGetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits); - return bits; + return audiofile_bits_to_sample_format(bits); } static void |