summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-08 23:54:05 +0200
committerwm4 <wm4@nowhere>2014-06-09 01:20:53 +0200
commit3e2f16a89e625d9798217f39cc5be6211059acf9 (patch)
treeab74ca3b6974058904414bc4ea71cda212de88de /player
parentda89af10768f75ceec9b9c0256649da6f4d843a2 (diff)
downloadmpv-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')
-rw-r--r--player/audio.c12
-rw-r--r--player/core.h1
-rw-r--r--player/loadfile.c2
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)