1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 00:42:57 +00:00

player: add --audio-wait-open options

Complements the option added in the previous commit.
This commit is contained in:
wm4 2016-08-09 16:26:44 +02:00
parent eab92cec60
commit 062349ff5b
5 changed files with 20 additions and 0 deletions

View File

@ -1352,6 +1352,14 @@ Audio
Not all AOs support this.
``--audio-wait-open=<secs>``
This makes sense for use with ``--audio-stream-silence=yes``. If this option
is given, the player will wait for the given amount of seconds after opening
the audio device before sending actual audio data to it. Useful if your
expensive hardware discards the first 1 or 2 seconds of audio data sent to
it. If ``--audio-stream-silence=yes`` is not set, this option will likely
just waste time.
Subtitles
---------

View File

@ -397,6 +397,7 @@ const m_option_t mp_opts[] = {
OPT_STRING("audio-client-name", audio_client_name, 0),
OPT_FLAG("audio-fallback-to-null", ao_null_fallback, 0),
OPT_FLAG("audio-stream-silence", audio_stream_silence, 0),
OPT_FLOATRANGE("audio-wait-open", audio_wait_open, 0, 0, 60),
OPT_CHOICE("force-window", force_vo, 0,
({"no", 0}, {"yes", 1}, {"immediate", 2})),
OPT_FLAG("taskbar-progress", vo.taskbar_progress, 0),

View File

@ -88,6 +88,7 @@ typedef struct MPOpts {
char *audio_client_name;
int ao_null_fallback;
int audio_stream_silence;
float audio_wait_open;
int force_vo;
int softvol;
float softvol_volume;

View File

@ -441,6 +441,9 @@ static void reinit_audio_filters_and_output(struct MPContext *mpctx)
mp_audio_config_to_str(&fmt));
MP_VERBOSE(mpctx, "AO: Description: %s\n", ao_get_description(mpctx->ao));
update_window_title(mpctx, true);
ao_c->ao_resume_time =
opts->audio_wait_open > 0 ? mp_time_sec() + opts->audio_wait_open : 0;
}
if (recreate_audio_filters(mpctx) < 0)
@ -862,6 +865,12 @@ void fill_audio_out_buffers(struct MPContext *mpctx)
return; // try again next iteration
}
if (ao_c->ao_resume_time > mp_time_sec()) {
double remaining = ao_c->ao_resume_time - mp_time_sec();
mpctx->sleeptime = MPMIN(mpctx->sleeptime, remaining);
return;
}
if (mpctx->vo_chain && ao_c->pts_reset) {
MP_VERBOSE(mpctx, "Reset playback due to audio timestamp reset.\n");
reset_playback_state(mpctx);

View File

@ -185,6 +185,7 @@ struct ao_chain {
struct af_stream *af;
struct ao *ao;
struct mp_audio_buffer *ao_buffer;
double ao_resume_time;
// 1-element input frame queue.
struct mp_audio *input_frame;