From c560f6ff0ab9aec70e53a268e2ff388a85ec3ca0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 23 Dec 2016 18:03:16 +0100 Subject: audio: change how spdif codecs are selected Remove ad_spdif from the normal codec list, and select it explicitly. One goal was to decouple this from the normal codec selection, so they're less entangled and the decoder selection code can be simplified in the far future. This means spdif codec selection is now done explicitly via select_spdif_codec(). We can also remove the weird requirements on "dts" and "dts-hd" for the --audio-spdif option, and it can just do the right thing. Now both video and audio codecs consist of a single codec family each, vd_lavc and ad_lavc. --- audio/decode/dec_audio.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'audio/decode/dec_audio.c') diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c index 39e867cf42..c98d42f556 100644 --- a/audio/decode/dec_audio.c +++ b/audio/decode/dec_audio.c @@ -43,11 +43,12 @@ #include "audio/filter/af.h" extern const struct ad_functions ad_lavc; + +// Not a real codec - specially treated. extern const struct ad_functions ad_spdif; static const struct ad_functions * const ad_drivers[] = { &ad_lavc, - &ad_spdif, NULL }; @@ -91,9 +92,9 @@ static struct mp_decoder_list *audio_select_decoders(struct dec_audio *d_audio) struct mp_decoder_list *list = audio_decoder_list(); struct mp_decoder_list *new = mp_select_decoders(list, codec, opts->audio_decoders); - if (d_audio->try_spdif) { + if (d_audio->try_spdif && codec) { struct mp_decoder_list *spdif = - mp_select_decoder_list(list, codec, "spdif", opts->audio_spdif); + select_spdif_codec(codec, opts->audio_spdif); mp_append_decoders(spdif, new); talloc_free(new); new = spdif; @@ -108,6 +109,8 @@ static const struct ad_functions *find_driver(const char *name) if (strcmp(ad_drivers[i]->name, name) == 0) return ad_drivers[i]; } + if (strcmp(name, "spdif") == 0) + return &ad_spdif; return NULL; } -- cgit v1.2.3