diff options
Diffstat (limited to 'player')
-rw-r--r-- | player/audio.c | 12 | ||||
-rw-r--r-- | player/core.h | 1 | ||||
-rw-r--r-- | player/loadfile.c | 2 |
3 files changed, 14 insertions, 1 deletions
diff --git a/player/audio.c b/player/audio.c index 1070270dda..e0c6ca9a0c 100644 --- a/player/audio.c +++ b/player/audio.c @@ -129,6 +129,13 @@ void reinit_audio_chain(struct MPContext *mpctx) struct mp_audio in_format; mp_audio_buffer_get_format(mpctx->d_audio->decode_buffer, &in_format); + if (mpctx->ao_decoder_fmt && (mpctx->initialized_flags & INITIALIZED_AO) && + !mp_audio_config_equals(mpctx->ao_decoder_fmt, &in_format) && + opts->gapless_audio < 0) + { + uninit_player(mpctx, INITIALIZED_AO); + } + int ao_srate = opts->force_srate; int ao_format = opts->audio_output_format; struct mp_chmap ao_channels = {0}; @@ -174,6 +181,9 @@ void reinit_audio_chain(struct MPContext *mpctx) mpctx->ao_buffer = mp_audio_buffer_create(ao); mp_audio_buffer_reinit(mpctx->ao_buffer, &fmt); + mpctx->ao_decoder_fmt = talloc(NULL, struct mp_audio); + *mpctx->ao_decoder_fmt = in_format; + char *s = mp_audio_config_to_str(&fmt); MP_INFO(mpctx, "AO: [%s] %s\n", ao_get_name(ao), s); talloc_free(s); @@ -413,7 +423,7 @@ int fill_audio_out_buffers(struct MPContext *mpctx, double endpts) * implementation would require draining buffered old-format audio * while displaying video, then doing the output format switch. */ - if (!mpctx->opts->gapless_audio) + if (mpctx->opts->gapless_audio < 1) uninit_player(mpctx, INITIALIZED_AO); reinit_audio_chain(mpctx); return -1; diff --git a/player/core.h b/player/core.h index 5f4789d267..e3d84f4ed9 100644 --- a/player/core.h +++ b/player/core.h @@ -218,6 +218,7 @@ typedef struct MPContext { struct mixer *mixer; struct ao *ao; double ao_pts; + struct mp_audio *ao_decoder_fmt; // for weak gapless audio check struct mp_audio_buffer *ao_buffer; // queued audio; passed to ao_play() later struct vo *video_out; diff --git a/player/loadfile.c b/player/loadfile.c index d79e82911c..cc65aedd6d 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -179,6 +179,8 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask) ao_uninit(ao); } mpctx->ao = NULL; + talloc_free(mpctx->ao_decoder_fmt); + mpctx->ao_decoder_fmt = NULL; } if (mask & INITIALIZED_PLAYBACK) |