changeset 36005:3be3990375da

Add -heartbeat-interval option. Patch by Android Jack [jackdroido gmail], with minor modification and man page update by me.
author reimar
date Sat, 30 Mar 2013 08:42:57 +0000
parents b81edd9d28ab
children efb9481610d2
files DOCS/man/en/mplayer.1 cfg-mplayer.h mplayer.c mplayer.h
diffstat 4 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Sat Mar 30 03:32:16 2013 +0000
+++ b/DOCS/man/en/mplayer.1	Sat Mar 30 08:42:57 2013 +0000
@@ -1076,6 +1076,10 @@
 .PD 1
 .
 .TP
+.B \-heartbeat\-interval
+Specify how often the \-heartbeat\-cmd should be executed, in seconds between executions (default: 30.0).
+.
+.TP
 .B \-identify
 Shorthand for \-msglevel identify=4.
 Show file parameters in an easily parseable format.
--- a/cfg-mplayer.h	Sat Mar 30 03:32:16 2013 +0000
+++ b/cfg-mplayer.h	Sat Mar 30 08:42:57 2013 +0000
@@ -189,6 +189,7 @@
     {"fstype", &vo_fstype_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
 #endif
     {"heartbeat-cmd", &heartbeat_cmd, CONF_TYPE_STRING, 0, 0, 0, NULL},
+    {"heartbeat-interval", &heartbeat_interval, CONF_TYPE_FLOAT, CONF_MIN, 0.0, 0, NULL},
     {"mouseinput", &vo_nomouse_input, CONF_TYPE_FLAG, 0, 1, 0, NULL},
     {"nomouseinput", &vo_nomouse_input, CONF_TYPE_FLAG,0, 0, 1, NULL},
 
--- a/mplayer.c	Sat Mar 30 03:32:16 2013 +0000
+++ b/mplayer.c	Sat Mar 30 08:42:57 2013 +0000
@@ -146,6 +146,7 @@
 float start_volume = -1;
 double start_pts   = MP_NOPTS_VALUE;
 char *heartbeat_cmd;
+float heartbeat_interval = 30.0;
 static int max_framesize;
 
 int noconsolecontrols;
@@ -3818,7 +3819,9 @@
                 if (heartbeat_cmd) {
                     static unsigned last_heartbeat;
                     unsigned now = GetTimerMS();
-                    if (now - last_heartbeat > 30000) {
+                    // compare as unsigned so that any mistakes (overflow etc)
+                    // trigger a heartbeat, thus resetting the logic.
+                    if (now - last_heartbeat > (unsigned)(heartbeat_interval * 1000)) {
                         last_heartbeat = now;
                         system(heartbeat_cmd);
                     }
--- a/mplayer.h	Sat Mar 30 03:32:16 2013 +0000
+++ b/mplayer.h	Sat Mar 30 08:42:57 2013 +0000
@@ -33,6 +33,7 @@
 extern int slave_mode;
 extern int player_idle_mode;
 extern int use_menu;
+extern float heartbeat_interval;
 
 extern float  audio_delay;
 extern double start_pts;