summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-08-09 16:26:44 +0200
committerwm4 <wm4@nowhere>2016-08-09 17:09:29 +0200
commit062349ff5b9b062aff581e96f3770e6cbd419491 (patch)
treee9578ded2892d8f9327673f91534e70e96219095
parenteab92cec60d92e0de2ea53d4d01052f4d7acc5d5 (diff)
downloadmpv-062349ff5b9b062aff581e96f3770e6cbd419491.tar.bz2
mpv-062349ff5b9b062aff581e96f3770e6cbd419491.tar.xz
player: add --audio-wait-open options
Complements the option added in the previous commit.
-rw-r--r--DOCS/man/options.rst8
-rw-r--r--options/options.c1
-rw-r--r--options/options.h1
-rw-r--r--player/audio.c9
-rw-r--r--player/core.h1
5 files changed, 20 insertions, 0 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 344b77bf3a..2deadd29df 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -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
---------
diff --git a/options/options.c b/options/options.c
index 833568659f..9dcaedcf2d 100644
--- a/options/options.c
+++ b/options/options.c
@@ -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),
diff --git a/options/options.h b/options/options.h
index 2aff254fbd..29cfb2231d 100644
--- a/options/options.h
+++ b/options/options.h
@@ -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;
diff --git a/player/audio.c b/player/audio.c
index 1f0fe9d0a0..5b52eceb11 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -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);
diff --git a/player/core.h b/player/core.h
index 70570fccb3..8f90a1903f 100644
--- a/player/core.h
+++ b/player/core.h
@@ -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;