summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--DOCS/man/en/mplayer.111
-rw-r--r--cfg-mplayer.h5
-rw-r--r--defaultopts.c1
-rw-r--r--mplayer.c32
-rw-r--r--options.h2
5 files changed, 37 insertions, 14 deletions
diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1
index a31ffb478b..708fd10199 100644
--- a/DOCS/man/en/mplayer.1
+++ b/DOCS/man/en/mplayer.1
@@ -2663,6 +2663,17 @@ The values that <format> can adopt are listed below in the
description of the format audio filter.
.
.TP
+.B \-gapless\-audio
+Try to play consecutive audio files with no silence or disruption
+at the point of file change.
+This feature is implemented in a simple manner and relies on audio output
+device buffering to continue playback while moving from one file to another.
+If playback of the new file starts slowly, for example because it's played from
+a remote network location or because you have specified cache settings that
+require time for the initial cache fill, then the buffered audio may run out
+before playback of the new file can start.
+.
+.TP
.B \-mixer <device>
Use a mixer device different from the default /dev/\:mixer.
For ALSA this is the mixer name.
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index 7413d171d4..95477edb33 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -98,9 +98,10 @@ const m_option_t mplayer_opts[]={
{"softvol-max", &soft_vol_max, CONF_TYPE_FLOAT, CONF_RANGE, 10, 10000, NULL},
{"volstep", &volstep, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
{"volume", &start_volume, CONF_TYPE_FLOAT, CONF_RANGE, -1, 10000, NULL},
+ OPT_MAKE_FLAGS("gapless-audio", gapless_audio, 0),
{"master", "Option -master has been removed, use -af volume instead.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
- // override audio buffer size (used only by -ao oss, anyway obsolete...)
- {"abs", &ao_data.buffersize, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
+ // override audio buffer size (used only by -ao oss/win32, obsolete)
+ OPT_INT("abs", ao_buffersize, 0),
// -ao pcm options:
{"aofile", "-aofile has been removed. Use -ao pcm:file=<filename> instead.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
diff --git a/defaultopts.c b/defaultopts.c
index cac97c04dd..1314e21f28 100644
--- a/defaultopts.c
+++ b/defaultopts.c
@@ -10,6 +10,7 @@ void set_default_mplayer_options(struct MPOpts *opts)
.audio_driver_list = NULL,
.video_driver_list = NULL,
.fixed_vo = 1,
+ .ao_buffersize = -1,
.monitor_pixel_aspect = 1.0,
.vo_panscanrange = 1.0,
.vo_gamma_gamma = 1000,
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";
diff --git a/options.h b/options.h
index 5a403149d7..a12038708c 100644
--- a/options.h
+++ b/options.h
@@ -6,6 +6,8 @@ typedef struct MPOpts {
char **audio_driver_list;
int fixed_vo;
int vo_ontop;
+ int gapless_audio;
+ int ao_buffersize;
int screen_size_x;
int screen_size_y;
int vo_screenwidth;