mirror of https://github.com/mpv-player/mpv
audio: add option for falling back to ao_null
The manpage entry explains this. (Maybe this option could be always enabled and removed. I don't quite remember what valid use-cases there are for just disabling audio entirely, other than that this is also needed for audio decoder init failure.)
This commit is contained in:
parent
e694d67366
commit
54fbda2ba4
|
@ -20,6 +20,7 @@ Interface changes
|
|||
::
|
||||
|
||||
--- mpv 0.12.0 ---
|
||||
- add --audio-fallback-to-null option
|
||||
- replace vf_format outputlevels suboption with "video-output-levels" global
|
||||
property/option; also remove "colormatrix-output-range" property
|
||||
- vo_opengl: remove sharpen3/sharpen5 scale filters, add sharpen sub-option
|
||||
|
|
|
@ -917,6 +917,14 @@ Audio
|
|||
|
||||
Currently not implemented for most AOs.
|
||||
|
||||
``--audio-fallback-to-null=<yes|no>``
|
||||
If no audio device can be opened, behave as if ``--ao=null`` was given. This
|
||||
is useful in combination with ``--audio-device``: instead of causing an
|
||||
error if the selected device does not exist, the client API user (or a
|
||||
Lua script) could let playback continue normally, and check the
|
||||
``current-ao`` and ``audio-device-list`` properties to make high-level
|
||||
decisions about how to continue.
|
||||
|
||||
``--ao=<driver1[:suboption1[=value]:...],driver2,...[,]>``
|
||||
Specify a priority list of audio output drivers to be used. For
|
||||
interactive use one would normally specify a single one to use, but in
|
||||
|
|
|
@ -240,6 +240,7 @@ static void split_ao_device(void *tmp, char *opt, char **out_ao, char **out_dev)
|
|||
}
|
||||
|
||||
struct ao *ao_init_best(struct mpv_global *global,
|
||||
bool ao_null_fallback,
|
||||
struct input_ctx *input_ctx,
|
||||
struct encode_lavc_context *encode_lavc_ctx,
|
||||
int samplerate, int format, struct mp_chmap channels)
|
||||
|
@ -282,6 +283,11 @@ struct ao *ao_init_best(struct mpv_global *global,
|
|||
}
|
||||
}
|
||||
|
||||
if (ao_null_fallback) {
|
||||
MP_TARRAY_APPEND(tmp, ao_list, ao_num,
|
||||
(struct m_obj_settings){.name = "null"});
|
||||
}
|
||||
|
||||
for (int n = 0; n < ao_num; n++) {
|
||||
struct m_obj_settings *entry = &ao_list[n];
|
||||
bool probing = n + 1 != ao_num;
|
||||
|
|
|
@ -72,6 +72,7 @@ struct encode_lavc_context;
|
|||
struct mp_audio;
|
||||
|
||||
struct ao *ao_init_best(struct mpv_global *global,
|
||||
bool ao_null_fallback,
|
||||
struct input_ctx *input_ctx,
|
||||
struct encode_lavc_context *encode_lavc_ctx,
|
||||
int samplerate, int format, struct mp_chmap channels);
|
||||
|
|
|
@ -383,6 +383,7 @@ const m_option_t mp_opts[] = {
|
|||
OPT_SETTINGSLIST("ao-defaults", ao_defs, 0, &ao_obj_list),
|
||||
OPT_STRING("audio-device", audio_device, 0),
|
||||
OPT_STRING("audio-client-name", audio_client_name, 0),
|
||||
OPT_FLAG("audio-fallback-to-null", ao_null_fallback, 0),
|
||||
OPT_CHOICE("force-window", force_vo, 0,
|
||||
({"no", 0}, {"yes", 1}, {"immediate", 2})),
|
||||
OPT_FLAG("ontop", vo.ontop, M_OPT_FIXED),
|
||||
|
|
|
@ -81,6 +81,7 @@ typedef struct MPOpts {
|
|||
struct m_obj_settings *audio_driver_list, *ao_defs;
|
||||
char *audio_device;
|
||||
char *audio_client_name;
|
||||
int ao_null_fallback;
|
||||
int force_vo;
|
||||
int softvol;
|
||||
float mixer_init_volume;
|
||||
|
|
|
@ -260,11 +260,15 @@ void reinit_audio_chain(struct MPContext *mpctx)
|
|||
}
|
||||
|
||||
if (!mpctx->ao) {
|
||||
bool spdif_fallback = af_fmt_is_spdif(afs->output.format) &&
|
||||
mpctx->d_audio->spdif_passthrough;
|
||||
bool ao_null_fallback = opts->ao_null_fallback && !spdif_fallback;
|
||||
|
||||
mp_chmap_remove_useless_channels(&afs->output.channels,
|
||||
&opts->audio_output_channels);
|
||||
mp_audio_set_channels(&afs->output, &afs->output.channels);
|
||||
|
||||
mpctx->ao = ao_init_best(mpctx->global, mpctx->input,
|
||||
mpctx->ao = ao_init_best(mpctx->global, ao_null_fallback, mpctx->input,
|
||||
mpctx->encode_lavc_ctx, afs->output.rate,
|
||||
afs->output.format, afs->output.channels);
|
||||
|
||||
|
@ -283,9 +287,7 @@ void reinit_audio_chain(struct MPContext *mpctx)
|
|||
|
||||
if (!mpctx->ao) {
|
||||
// If spdif was used, try to fallback to PCM.
|
||||
if (af_fmt_is_spdif(afs->output.format) &&
|
||||
mpctx->d_audio->spdif_passthrough)
|
||||
{
|
||||
if (spdif_fallback) {
|
||||
mpctx->d_audio->spdif_passthrough = false;
|
||||
if (!audio_init_best_codec(mpctx->d_audio))
|
||||
goto init_error;
|
||||
|
|
Loading…
Reference in New Issue