diff options
author | Max Kellermann <max@duempel.org> | 2008-11-21 20:27:30 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-11-21 20:27:30 +0100 |
commit | 976d5045c671700b1e16ed2b98e746a67fa91e8b (patch) | |
tree | 06acf6433adcaf822c212be15a099ff40c62eb04 /src/decoder/audiofile_plugin.c | |
parent | be9e60d55ef191b5b50a9d1eb2337a6b1199c8d4 (diff) | |
download | mpd-976d5045c671700b1e16ed2b98e746a67fa91e8b.tar.gz mpd-976d5045c671700b1e16ed2b98e746a67fa91e8b.tar.xz mpd-976d5045c671700b1e16ed2b98e746a67fa91e8b.zip |
decoder: check audio_format_valid() in all decoders
Refuse to play audio formats which are not supported by MPD.
Diffstat (limited to '')
-rw-r--r-- | src/decoder/audiofile_plugin.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/decoder/audiofile_plugin.c b/src/decoder/audiofile_plugin.c index 95ae37dd7..c862074b5 100644 --- a/src/decoder/audiofile_plugin.c +++ b/src/decoder/audiofile_plugin.c @@ -77,19 +77,20 @@ audiofile_decode(struct decoder *decoder, const char *path) audio_format.channels = (uint8_t)afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK); + if (!audio_format_valid(&audio_format)) { + g_warning("Invalid audio format: %u:%u:%u\n", + audio_format.sample_rate, audio_format.bits, + audio_format.channels); + afCloseFile(af_fp); + return; + } + frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK); total_time = ((float)frame_count / (float)audio_format.sample_rate); bitRate = (uint16_t)(st.st_size * 8.0 / total_time / 1000.0 + 0.5); - if (audio_format.bits != 8 && audio_format.bits != 16) { - g_warning("Only 8 and 16-bit files are supported. %s is %i-bit\n", - path, audio_format.bits); - afCloseFile(af_fp); - return; - } - fs = (int)afGetVirtualFrameSize(af_fp, AF_DEFAULT_TRACK, 1); decoder_initialized(decoder, &audio_format, true, total_time); |