summaryrefslogtreecommitdiffstats
path: root/stream
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 /stream
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 'stream')
-rw-r--r--stream/cache2.c6
-rw-r--r--stream/tv.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/stream/cache2.c b/stream/cache2.c
index 1337e44e37..671bd85c53 100644
--- a/stream/cache2.c
+++ b/stream/cache2.c
@@ -264,7 +264,7 @@ static int cache_execute_control(cache_vars_t *s) {
unsigned uint_res;
uint64_t uint64_res;
int needs_flush = 0;
- static unsigned last;
+ static double last;
int quit = s->control == -2;
uint64_t old_pos = s->stream->pos;
int old_eof = s->stream->eof;
@@ -275,7 +275,7 @@ static int cache_execute_control(cache_vars_t *s) {
s->control = -1;
return !quit;
}
- if (GetTimerMS() - last > 99) {
+ if (mp_time_sec() - last > 0.099) {
double len, pos;
if (s->stream->control(s->stream, STREAM_CTRL_GET_TIME_LENGTH, &len) == STREAM_OK)
s->stream_time_length = len;
@@ -296,7 +296,7 @@ static int cache_execute_control(cache_vars_t *s) {
return 0;
}
#endif
- last = GetTimerMS();
+ last = mp_time_sec();
}
if (s->control == -1) return 1;
switch (s->control) {
diff --git a/stream/tv.c b/stream/tv.c
index 38368d4925..1fcb13037d 100644
--- a/stream/tv.c
+++ b/stream/tv.c
@@ -130,7 +130,7 @@ static void tv_scan(tvi_handle_t *tvh)
}
scan = tvh->scan;
- now=GetTimer();
+ now=(unsigned int)mp_time_us();
if (!scan) {
scan=calloc(1,sizeof(tv_scan_t));
tvh->scan=scan;