summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-06-05 22:34:22 +0200
committerwm4 <wm4@nowhere>2015-06-05 22:34:47 +0200
commit68aaffc7117e2d1f7ff5ce89bb7c027b0e1c028c (patch)
tree18a235df5cbf90475ffb4180274d0a169e35e0a3
parent2bf2254248c4366040eae8724181f325ce28480b (diff)
downloadmpv-68aaffc7117e2d1f7ff5ce89bb7c027b0e1c028c.tar.bz2
mpv-68aaffc7117e2d1f7ff5ce89bb7c027b0e1c028c.tar.xz
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.
-rw-r--r--player/audio.c24
1 files 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);
}