From addfcf9ce339f487c94c36f6e72fc7e736586015 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 27 Nov 2013 00:11:35 +0100 Subject: audio: better rejection of invalid formats This includes the case when lavc decodes audio with more than 8 channels, which our audio chain currently does not support. the changes in ad_lavc.c are just simplifications. The code tried to avoid overriding global parameters if it found something invalid, but that is not needed anymore. --- audio/audio.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'audio/audio.c') diff --git a/audio/audio.c b/audio/audio.c index 02cd27d0d0..b40ef6fab3 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -79,6 +79,12 @@ bool mp_audio_config_equals(const struct mp_audio *a, const struct mp_audio *b) mp_chmap_equals(&a->channels, &b->channels); } +bool mp_audio_config_valid(const struct mp_audio *mpa) +{ + return mp_chmap_is_valid(&mpa->channels) && af_fmt_is_valid(mpa->format) + && mpa->rate >= 1 && mpa->rate < 10000000; +} + char *mp_audio_fmt_to_str(int srate, const struct mp_chmap *chmap, int format) { char *chstr = mp_chmap_to_str(chmap); -- cgit v1.2.3