summaryrefslogtreecommitdiffstats
path: root/audio/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-06-05 22:35:43 +0200
committerwm4 <wm4@nowhere>2015-06-05 22:42:59 +0200
commit57048c7393e94820520a395e569d05cdcc085224 (patch)
tree329ff5bbeb7ca13076dfa653f03cbc4aa5736730 /audio/decode
parent14ac4f0bd66d05665f43f3e65138f035be06e29e (diff)
downloadmpv-57048c7393e94820520a395e569d05cdcc085224.tar.bz2
mpv-57048c7393e94820520a395e569d05cdcc085224.tar.xz
audio: add --audio-spdif as new method for enabling passthrough
This provides a new method for enabling spdif passthrough. The old method via --ad (--ad=spdif:ac3 etc.) is deprecated. The deprecated method will probably stop working at some point. This also supports PCM fallback. One caveat is that it will lose at least 1 audio packet in doing so. (I don't care enough to prevent this.) (This is named after the old S/PDIF connector, because it uses the same underlying technology as far as the higher level protoco is concerned. Also, the user should be renamed that passthrough is backwards.)
Diffstat (limited to 'audio/decode')
-rw-r--r--audio/decode/dec_audio.c26
-rw-r--r--audio/decode/dec_audio.h3
2 files changed, 21 insertions, 8 deletions
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index dfbe32cbdf..19d2c4e3df 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -52,6 +52,7 @@ static const struct ad_functions * const ad_drivers[] = {
static void uninit_decoder(struct dec_audio *d_audio)
{
+ audio_reset_decoding(d_audio);
if (d_audio->ad_driver) {
MP_VERBOSE(d_audio, "Uninit audio decoder.\n");
d_audio->ad_driver->uninit(d_audio);
@@ -59,6 +60,8 @@ static void uninit_decoder(struct dec_audio *d_audio)
d_audio->ad_driver = NULL;
talloc_free(d_audio->priv);
d_audio->priv = NULL;
+ d_audio->afilter->initialized = -1;
+ d_audio->decode_format = (struct mp_audio){0};
}
static int init_audio_codec(struct dec_audio *d_audio, const char *decoder)
@@ -81,11 +84,21 @@ struct mp_decoder_list *audio_decoder_list(void)
return list;
}
-static struct mp_decoder_list *audio_select_decoders(const char *codec,
- char *selection)
+static struct mp_decoder_list *audio_select_decoders(struct dec_audio *d_audio)
{
+ struct MPOpts *opts = d_audio->opts;
+ const char *codec = d_audio->header->codec;
+
struct mp_decoder_list *list = audio_decoder_list();
- struct mp_decoder_list *new = mp_select_decoders(list, codec, selection);
+ struct mp_decoder_list *new =
+ mp_select_decoders(list, codec, opts->audio_decoders);
+ if (d_audio->spdif_passthrough) {
+ struct mp_decoder_list *spdif =
+ mp_select_decoder_list(list, codec, "spdif", opts->audio_spdif);
+ mp_append_decoders(spdif, new);
+ talloc_free(new);
+ new = spdif;
+ }
talloc_free(list);
return new;
}
@@ -99,14 +112,13 @@ static const struct ad_functions *find_driver(const char *name)
return NULL;
}
-int audio_init_best_codec(struct dec_audio *d_audio, char *audio_decoders)
+int audio_init_best_codec(struct dec_audio *d_audio)
{
+ uninit_decoder(d_audio);
assert(!d_audio->ad_driver);
- audio_reset_decoding(d_audio);
struct mp_decoder_entry *decoder = NULL;
- struct mp_decoder_list *list =
- audio_select_decoders(d_audio->header->codec, audio_decoders);
+ struct mp_decoder_list *list = audio_select_decoders(d_audio);
mp_print_decoders(d_audio->log, MSGL_V, "Codec list:", list);
diff --git a/audio/decode/dec_audio.h b/audio/decode/dec_audio.h
index 11e4a24b81..6d7dd18bc8 100644
--- a/audio/decode/dec_audio.h
+++ b/audio/decode/dec_audio.h
@@ -30,6 +30,7 @@ struct dec_audio {
struct mp_log *log;
struct MPOpts *opts;
struct mpv_global *global;
+ bool spdif_passthrough;
const struct ad_functions *ad_driver;
struct sh_stream *header;
struct af_stream *afilter;
@@ -57,7 +58,7 @@ enum {
};
struct mp_decoder_list *audio_decoder_list(void);
-int audio_init_best_codec(struct dec_audio *d_audio, char *audio_decoders);
+int audio_init_best_codec(struct dec_audio *d_audio);
int audio_decode(struct dec_audio *d_audio, struct mp_audio_buffer *outbuf,
int minsamples);
int initial_audio_decode(struct dec_audio *d_audio);