From ccc213fdac9783b9e450342cf5a346508e961e2f Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 4 Apr 2013 14:24:42 +0200 Subject: core: add --heartbeat-interval option This closely follows MPlayer commit 36099, with some changes. Move a mutable static variable into MPContext. --- core/cfg-mplayer.h | 1 + core/defaultopts.c | 1 + core/mp_core.h | 1 + core/mplayer.c | 7 ++++--- core/options.h | 1 + 5 files changed, 8 insertions(+), 3 deletions(-) (limited to 'core') 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; -- cgit v1.2.3