mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
a66cce61ad
commit
3d999246e4
|
@ -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.
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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,
|
||||
|
|
32
mplayer.c
32
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";
|
||||
|
|
Loading…
Reference in New Issue