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.)
This commit is contained in:
wm4
2015-06-05 22:35:43 +02:00
parent 14ac4f0bd6
commit 57048c7393
10 changed files with 101 additions and 18 deletions

View File

@@ -190,8 +190,9 @@ void reinit_audio_chain(struct MPContext *mpctx)
mpctx->d_audio->pool = mp_audio_pool_create(mpctx->d_audio);
mpctx->d_audio->afilter = af_new(mpctx->global);
mpctx->d_audio->afilter->replaygain_data = sh->audio->replaygain_data;
mpctx->d_audio->spdif_passthrough = true;
mpctx->ao_buffer = mp_audio_buffer_create(NULL);
if (!audio_init_best_codec(mpctx->d_audio, opts->audio_decoders))
if (!audio_init_best_codec(mpctx->d_audio))
goto init_error;
reset_audio_state(mpctx);
@@ -264,6 +265,18 @@ void reinit_audio_chain(struct MPContext *mpctx)
}
if (!mpctx->ao) {
// If spdif was used, try to fallback to PCM.
if (AF_FORMAT_IS_SPECIAL(afs->output.format) &&
mpctx->d_audio->spdif_passthrough)
{
mpctx->d_audio->spdif_passthrough = false;
if (!audio_init_best_codec(mpctx->d_audio))
goto init_error;
reset_audio_state(mpctx);
reinit_audio_chain(mpctx);
return;
}
MP_ERR(mpctx, "Could not open/initialize audio device -> no sound.\n");
mpctx->error_playing = MPV_ERROR_AO_INIT_FAILED;
goto init_error;

View File

@@ -278,6 +278,10 @@ static bool handle_help_options(struct MPContext *mpctx)
talloc_free(list);
opt_exit = 1;
}
if (opts->audio_spdif && strcmp(opts->audio_spdif, "help") == 0) {
MP_INFO(mpctx, "Choices: ac3,dts-hd,dts (and possibly more)\n");
opt_exit = 1;
}
if (opts->video_decoders && strcmp(opts->video_decoders, "help") == 0) {
struct mp_decoder_list *list = video_decoder_list();
mp_print_decoders(log, MSGL_INFO, "Video decoders:", list);