summaryrefslogtreecommitdiffstats
path: root/core/mp_core.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-05-25 18:31:06 +0200
committerwm4 <wm4@nowhere>2013-05-26 16:44:20 +0200
commite56d8a200d900066c3da571d92733f66ce6a13ab (patch)
treef43862ec12beee05380da82ebef23bcce83401e7 /core/mp_core.h
parent51254a678c386cf48f2caa51e06ad34065c8693a (diff)
downloadmpv-e56d8a200d900066c3da571d92733f66ce6a13ab.tar.bz2
mpv-e56d8a200d900066c3da571d92733f66ce6a13ab.tar.xz
Replace all calls to GetTimer()/GetTimerMS()
GetTimer() is generally replaced with mp_time_us(). Both calls return microseconds, but the latter uses int64_t, us defined to never wrap, and never returns 0 or negative values. GetTimerMS() has no direct replacement. Instead the other functions are used. For some code, switch to mp_time_sec(), which returns the time as double float value in seconds. The returned time is offset to program start time, so there is enough precision left to deliver microsecond resolution for at least 100 years. Unless it's casted to a float (or the CPU reduces precision), which is why we still use mp_time_us() out of paranoia in places where precision is clearly needed. Always switch to the correct time. The whole point of the new timer calls is that they don't wrap, and storing microseconds in unsigned int variables would negate this. In some cases, remove wrap-around handling for time values.
Diffstat (limited to 'core/mp_core.h')
-rw-r--r--core/mp_core.h23
1 files changed, 11 insertions, 12 deletions
diff --git a/core/mp_core.h b/core/mp_core.h
index 6f784b4b7c..3b693d1658 100644
--- a/core/mp_core.h
+++ b/core/mp_core.h
@@ -132,9 +132,10 @@ typedef struct MPContext {
subtitle subs; // subtitle list used when reading subtitles from demuxer
int add_osd_seek_info; // bitfield of enum mp_osd_seek_info
- unsigned int osd_visible; // for the osd bar only
+ double osd_visible; // for the osd bar only
int osd_function;
- unsigned int osd_function_visible;
+ double osd_function_visible;
+ double osd_last_update;
struct playlist *playlist;
char *filename; // currently playing file
@@ -196,11 +197,11 @@ typedef struct MPContext {
// by the audio CPU usage meter.
double delay;
// AV sync: time until next frame should be shown
- float time_frame;
+ double time_frame;
// How long the last vo flip() call took. Used to adjust timing with
// the goal of making flip() calls finish (rather than start) at the
// specified time.
- float last_vo_flip_duration;
+ double last_vo_flip_duration;
// How much video timing has been changed to make it match the audio
// timeline. Used for status line information only.
double total_avsync_change;
@@ -232,23 +233,21 @@ typedef struct MPContext {
uint64_t backstep_start_seek_ts;
bool backstep_active;
- float audio_delay;
+ double audio_delay;
- unsigned int last_heartbeat;
+ double last_heartbeat;
- unsigned int mouse_timer;
- unsigned int mouse_last_time;
+ double mouse_timer;
+ unsigned int mouse_event_ts;
int mouse_waiting_hide;
- unsigned int next_wakup_time;
-
// used to prevent hanging in some error cases
- unsigned int start_timestamp;
+ double start_timestamp;
// Timestamp from the last time some timing functions read the
// current time, in (occasionally wrapping) microseconds. Used
// to turn a new time value to a delta from last time.
- unsigned int last_time;
+ int64_t last_time;
// Used to communicate the parameters of a seek between parts
struct seek_params {