From 68aaffc7117e2d1f7ff5ce89bb7c027b0e1c028c Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 5 Jun 2015 22:34:22 +0200 Subject: 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. --- player/audio.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/player/audio.c b/player/audio.c index 41555d9150..559e194218 100644 --- a/player/audio.c +++ b/player/audio.c @@ -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); } -- cgit v1.2.3