diff options
author | wm4 <wm4@nowhere> | 2013-04-04 14:24:42 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-04-04 14:24:42 +0200 |
commit | ccc213fdac9783b9e450342cf5a346508e961e2f (patch) | |
tree | b98a96a0c6514e48b0322eaf3552f8503d331f16 /core | |
parent | e1d57504b3e48099f447842713e60f0eef0e04db (diff) | |
download | mpv-ccc213fdac9783b9e450342cf5a346508e961e2f.tar.bz2 mpv-ccc213fdac9783b9e450342cf5a346508e961e2f.tar.xz |
core: add --heartbeat-interval option
This closely follows MPlayer commit 36099, with some changes.
Move a mutable static variable into MPContext.
Diffstat (limited to 'core')
-rw-r--r-- | core/cfg-mplayer.h | 1 | ||||
-rw-r--r-- | core/defaultopts.c | 1 | ||||
-rw-r--r-- | core/mp_core.h | 1 | ||||
-rw-r--r-- | core/mplayer.c | 7 | ||||
-rw-r--r-- | core/options.h | 1 |
5 files changed, 8 insertions, 3 deletions
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; |