From 0a41c6f0ec1adeb4e627daeddb474c0c9bdad008 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 6 Oct 2015 20:17:49 +0200 Subject: audio: make spdif re-probe from normal decoding work The previous commit handled not falling back to normal decoding if the AO was reloaded (I think...), and this tries to re-engage spdif pass- through if it was previously falling back to normal decoding (e.g. because it temporarily switched to an audio device incapable of passthrough). --- audio/decode/dec_audio.h | 2 +- player/audio.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/audio/decode/dec_audio.h b/audio/decode/dec_audio.h index 6d7dd18bc8..0f7f4d239d 100644 --- a/audio/decode/dec_audio.h +++ b/audio/decode/dec_audio.h @@ -30,7 +30,7 @@ struct dec_audio { struct mp_log *log; struct MPOpts *opts; struct mpv_global *global; - bool spdif_passthrough; + bool spdif_passthrough, spdif_failed; const struct ad_functions *ad_driver; struct sh_stream *header; struct af_stream *afilter; diff --git a/player/audio.c b/player/audio.c index 9ff253ae92..0b35d7018b 100644 --- a/player/audio.c +++ b/player/audio.c @@ -289,6 +289,7 @@ void reinit_audio_chain(struct MPContext *mpctx) // If spdif was used, try to fallback to PCM. if (spdif_fallback) { mpctx->d_audio->spdif_passthrough = false; + mpctx->d_audio->spdif_failed = true; if (!audio_init_best_codec(mpctx->d_audio)) goto init_error; reset_audio_state(mpctx); @@ -474,7 +475,15 @@ void fill_audio_out_buffers(struct MPContext *mpctx, double endpts) ao_reset(mpctx->ao); uninit_audio_out(mpctx); if (d_audio) { - mpctx->d_audio->spdif_passthrough = true; + if (mpctx->d_audio->spdif_failed) { + mpctx->d_audio->spdif_failed = false; + mpctx->d_audio->spdif_passthrough = true; + if (!audio_init_best_codec(mpctx->d_audio)) { + MP_ERR(mpctx, "Error reinitializing audio.\n"); + error_on_track(mpctx, mpctx->current_track[0][STREAM_AUDIO]); + return; + } + } mpctx->audio_status = STATUS_SYNCING; } } -- cgit v1.2.3