summaryrefslogtreecommitdiffstats
path: root/mplayer.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-12 14:06:37 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-12 18:29:09 +0200
commit3d999246e446995cd0ae508303ceeaa2f11836ad (patch)
treece4d6adb832ffb69e7a0ec5c6ba783c25d4ef49a /mplayer.c
parenta66cce61ad0d62c9b4c24a9262b7182f865aca5b (diff)
downloadmpv-3d999246e446995cd0ae508303ceeaa2f11836ad.tar.bz2
mpv-3d999246e446995cd0ae508303ceeaa2f11836ad.tar.xz
audio: add -gapless-audio option
If the option is enabled and all audio has been buffered to the AO, then the player will move to the next file without waiting for the buffered audio to drain, while leaving the AO initialized. If the playback of the next file starts quickly enough (before the AO buffer empties) then it should continue writing audio to the same AO with no gap in between.
Diffstat (limited to 'mplayer.c')
-rw-r--r--mplayer.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/mplayer.c b/mplayer.c
index fc3356d085..87e759ac92 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -1742,22 +1742,25 @@ void reinit_audio_chain(struct MPContext *mpctx)
}
+ current_module="af_preinit";
if (!(mpctx->initialized_flags & INITIALIZED_AO)) {
- current_module="af_preinit";
ao_data.samplerate=force_srate;
ao_data.channels=0;
ao_data.format = opts->audio_output_format;
- // first init to detect best values
- if(!init_audio_filters(mpctx->sh_audio, // preliminary init
- // input:
- mpctx->sh_audio->samplerate,
- // output:
- &ao_data.samplerate, &ao_data.channels, &ao_data.format)){
- mp_tmsg(MSGT_CPLAYER,MSGL_ERR, "Error at audio filter chain "
- "pre-init!\n");
- exit_player(mpctx, EXIT_ERROR);
- }
+ }
+ // first init to detect best values
+ if(!init_audio_filters(mpctx->sh_audio, // preliminary init
+ // input:
+ mpctx->sh_audio->samplerate,
+ // output:
+ &ao_data.samplerate, &ao_data.channels, &ao_data.format)){
+ mp_tmsg(MSGT_CPLAYER,MSGL_ERR, "Error at audio filter chain "
+ "pre-init!\n");
+ exit_player(mpctx, EXIT_ERROR);
+ }
+ if (!(mpctx->initialized_flags & INITIALIZED_AO)) {
current_module="ao2_init";
+ ao_data.buffersize = opts->ao_buffersize;
mpctx->audio_out = init_best_audio_out(opts->audio_driver_list,
0, // plugin flag
ao_data.samplerate,
@@ -4488,7 +4491,12 @@ if(benchmark){
}
// time to uninit all, except global stuff:
-uninit_player(mpctx, INITIALIZED_ALL-(opts->fixed_vo?INITIALIZED_VO:0));
+int uninitialize_parts = INITIALIZED_ALL;
+if (opts->fixed_vo)
+ uninitialize_parts -= INITIALIZED_VO;
+if (opts->gapless_audio && mpctx->stop_play == AT_END_OF_FILE)
+ uninitialize_parts -= INITIALIZED_AO;
+uninit_player(mpctx, uninitialize_parts);
if(mpctx->set_of_sub_size > 0) {
current_module="sub_free";