summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/options.rst6
-rw-r--r--core/cfg-mplayer.h1
-rw-r--r--core/defaultopts.c1
-rw-r--r--core/mp_core.h1
-rw-r--r--core/mplayer.c7
-rw-r--r--core/options.h1
6 files changed, 13 insertions, 4 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index d64cbe8f80..cc55c3a40e 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -786,7 +786,8 @@
--heartbeat-cmd
Command that is executed every 30 seconds during playback via *system()* -
- i.e. using the shell.
+ i.e. using the shell. The time between the commands can be customized with
+ the ``--heartbeat-interval`` option.
*NOTE*: mpv uses this command without any checking. It is your
responsibility to ensure it does not cause security problems (e.g. make
@@ -805,6 +806,9 @@
*EXAMPLE for GNOME screensaver*: ``mpv
--heartbeat-cmd="gnome-screensaver-command -p" file``
+--heartbeat-interval=<sec>
+ Time between ``--heartbeat-cmd`` invocations in seconds (default: 30).
+
--help
Show short summary of options.
diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h
index 5bae70ab0e..17f39822fe 100644
--- a/core/cfg-mplayer.h
+++ b/core/cfg-mplayer.h
@@ -598,6 +598,7 @@ const m_option_t mplayer_opts[]={
OPT_STRINGLIST("fstype", vo.fstype_list, 0),
#endif
OPT_STRING("heartbeat-cmd", heartbeat_cmd, 0),
+ OPT_FLOAT("heartbeat-interval", heartbeat_interval, CONF_MIN, 0),
OPT_FLAG("mouseinput", vo.nomouse_input, 0),
OPT_CHOICE_OR_INT("screen", vo.screen_id, 0, 0, 32,
diff --git a/core/defaultopts.c b/core/defaultopts.c
index 6c00af9a92..44ec8f1978 100644
--- a/core/defaultopts.c
+++ b/core/defaultopts.c
@@ -36,6 +36,7 @@ void set_default_mplayer_options(struct MPOpts *opts)
.WinID = -1,
},
.wintitle = "mpv - ${media-title}",
+ .heartbeat_interval = 30.0,
.gamma_gamma = 1000,
.gamma_brightness = 1000,
.gamma_contrast = 1000,
diff --git a/core/mp_core.h b/core/mp_core.h
index b8782f14e9..ea3d918b27 100644
--- a/core/mp_core.h
+++ b/core/mp_core.h
@@ -220,6 +220,7 @@ typedef struct MPContext {
float audio_delay;
+ unsigned int last_heartbeat;
// used to prevent hanging in some error cases
unsigned int start_timestamp;
diff --git a/core/mplayer.c b/core/mplayer.c
index 460862f057..21af9ca57a 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -3243,10 +3243,11 @@ static void run_playloop(struct MPContext *mpctx)
vo_check_events(vo);
if (opts->heartbeat_cmd) {
- static unsigned last_heartbeat;
unsigned now = GetTimerMS();
- if (now - last_heartbeat > 30000) {
- last_heartbeat = now;
+ if (now - mpctx->last_heartbeat >
+ (unsigned)(opts->heartbeat_interval * 1000))
+ {
+ mpctx->last_heartbeat = now;
system(opts->heartbeat_cmd);
}
}
diff --git a/core/options.h b/core/options.h
index 999f3439e9..0f1df17ba5 100644
--- a/core/options.h
+++ b/core/options.h
@@ -109,6 +109,7 @@ typedef struct MPOpts {
char *status_msg;
char *osd_status_msg;
char *heartbeat_cmd;
+ float heartbeat_interval;
int player_idle_mode;
int slave_mode;
int consolecontrols;