diff options
author | wm4 <wm4@nowhere> | 2014-06-08 23:54:05 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-06-09 01:20:53 +0200 |
commit | 3e2f16a89e625d9798217f39cc5be6211059acf9 (patch) | |
tree | ab74ca3b6974058904414bc4ea71cda212de88de /player/audio.c | |
parent | da89af10768f75ceec9b9c0256649da6f4d843a2 (diff) | |
download | mpv-3e2f16a89e625d9798217f39cc5be6211059acf9.tar.bz2 mpv-3e2f16a89e625d9798217f39cc5be6211059acf9.tar.xz |
audio: add a "weak" gapless mode, and make it default
Basically, this allows gapless playback with similar files (including
the ordered chapter case), while still being robust in general.
The implementation is quite simplistic on purpose, in order to avoid
all the weird corner cases that can occur when creating the filter
chain. The consequence is that it might do not-gapless playback in
more cases when needed, but if that bothers you, you still can use
the normal gapless mode.
Just using "--gapless-audio" or "--gapless-audio=yes" selects the old
mode.
Diffstat (limited to 'player/audio.c')
-rw-r--r-- | player/audio.c | 12 |
1 files changed, 11 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; |