audio: do not allow AO to change passthrough formats

This makes no sense, because the format can't be converted anyway. It
just sets up the filter chain init code, which will vomit a bunch of
useless and confusing messages. So uninit and fail explicitly when this
happens.
This commit is contained in:
wm4 2015-06-05 22:34:22 +02:00
parent 2bf2254248
commit 68aaffc711
1 changed files with 17 additions and 7 deletions

View File

@ -249,16 +249,26 @@ void reinit_audio_chain(struct MPContext *mpctx)
mpctx->ao = ao_init_best(mpctx->global, mpctx->input,
mpctx->encode_lavc_ctx, afs->output.rate,
afs->output.format, afs->output.channels);
struct ao *ao = mpctx->ao;
if (!ao) {
struct mp_audio fmt = {0};
if (mpctx->ao)
ao_get_format(mpctx->ao, &fmt);
// Verify passthrough format was not changed.
if (mpctx->ao && AF_FORMAT_IS_SPECIAL(afs->output.format)) {
if (!mp_audio_config_equals(&afs->output, &fmt)) {
MP_ERR(mpctx, "Passthrough format unsupported.\n");
ao_uninit(mpctx->ao);
mpctx->ao = NULL;
}
}
if (!mpctx->ao) {
MP_ERR(mpctx, "Could not open/initialize audio device -> no sound.\n");
mpctx->error_playing = MPV_ERROR_AO_INIT_FAILED;
goto init_error;
}
struct mp_audio fmt;
ao_get_format(ao, &fmt);
mp_audio_buffer_reinit(mpctx->ao_buffer, &fmt);
afs->output = fmt;
if (!mp_audio_config_equals(&afs->output, &afs->filter_output))
@ -267,9 +277,9 @@ void reinit_audio_chain(struct MPContext *mpctx)
mpctx->ao_decoder_fmt = talloc(NULL, struct mp_audio);
*mpctx->ao_decoder_fmt = in_format;
MP_INFO(mpctx, "AO: [%s] %s\n", ao_get_name(ao),
MP_INFO(mpctx, "AO: [%s] %s\n", ao_get_name(mpctx->ao),
mp_audio_config_to_str(&fmt));
MP_VERBOSE(mpctx, "AO: Description: %s\n", ao_get_description(ao));
MP_VERBOSE(mpctx, "AO: Description: %s\n", ao_get_description(mpctx->ao));
update_window_title(mpctx, true);
}