Whenever av_gettime() is used to measure relative period of time,
av_gettime_relative() is prefered as it guarantee monotonic time
on supported platforms.
Signed-off-by: Olivier Langlois <olivier@trillion01.com>
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -910,7 +910,7 @@ static void video_audio_display(VideoState *s) |
910 | 910 |
/* to be more precise, we take into account the time spent since |
911 | 911 |
the last buffer computation */ |
912 | 912 |
if (audio_callback_time) { |
913 |
- time_diff = av_gettime() - audio_callback_time; |
|
913 |
+ time_diff = av_gettime_relative() - audio_callback_time; |
|
914 | 914 |
delay -= (time_diff * s->audio_tgt.freq) / 1000000; |
915 | 915 |
} |
916 | 916 |
|
... | ... |
@@ -1143,7 +1143,7 @@ static double get_clock(Clock *c) |
1143 | 1143 |
if (c->paused) { |
1144 | 1144 |
return c->pts; |
1145 | 1145 |
} else { |
1146 |
- double time = av_gettime() / 1000000.0; |
|
1146 |
+ double time = av_gettime_relative() / 1000000.0; |
|
1147 | 1147 |
return c->pts_drift + time - (time - c->last_updated) * (1.0 - c->speed); |
1148 | 1148 |
} |
1149 | 1149 |
} |
... | ... |
@@ -1158,7 +1158,7 @@ static void set_clock_at(Clock *c, double pts, int serial, double time) |
1158 | 1158 |
|
1159 | 1159 |
static void set_clock(Clock *c, double pts, int serial) |
1160 | 1160 |
{ |
1161 |
- double time = av_gettime() / 1000000.0; |
|
1161 |
+ double time = av_gettime_relative() / 1000000.0; |
|
1162 | 1162 |
set_clock_at(c, pts, serial, time); |
1163 | 1163 |
} |
1164 | 1164 |
|
... | ... |
@@ -1251,7 +1251,7 @@ static void stream_seek(VideoState *is, int64_t pos, int64_t rel, int seek_by_by |
1251 | 1251 |
static void stream_toggle_pause(VideoState *is) |
1252 | 1252 |
{ |
1253 | 1253 |
if (is->paused) { |
1254 |
- is->frame_timer += av_gettime() / 1000000.0 + is->vidclk.pts_drift - is->vidclk.pts; |
|
1254 |
+ is->frame_timer += av_gettime_relative() / 1000000.0 + is->vidclk.pts_drift - is->vidclk.pts; |
|
1255 | 1255 |
if (is->read_pause_return != AVERROR(ENOSYS)) { |
1256 | 1256 |
is->vidclk.paused = 0; |
1257 | 1257 |
} |
... | ... |
@@ -1366,7 +1366,7 @@ static void video_refresh(void *opaque, double *remaining_time) |
1366 | 1366 |
check_external_clock_speed(is); |
1367 | 1367 |
|
1368 | 1368 |
if (!display_disable && is->show_mode != SHOW_MODE_VIDEO && is->audio_st) { |
1369 |
- time = av_gettime() / 1000000.0; |
|
1369 |
+ time = av_gettime_relative() / 1000000.0; |
|
1370 | 1370 |
if (is->force_refresh || is->last_vis_time + rdftspeed < time) { |
1371 | 1371 |
video_display(is); |
1372 | 1372 |
is->last_vis_time = time; |
... | ... |
@@ -1397,7 +1397,7 @@ retry: |
1397 | 1397 |
} |
1398 | 1398 |
|
1399 | 1399 |
if (lastvp->serial != vp->serial && !redisplay) |
1400 |
- is->frame_timer = av_gettime() / 1000000.0; |
|
1400 |
+ is->frame_timer = av_gettime_relative() / 1000000.0; |
|
1401 | 1401 |
|
1402 | 1402 |
if (is->paused) |
1403 | 1403 |
goto display; |
... | ... |
@@ -1409,7 +1409,7 @@ retry: |
1409 | 1409 |
else |
1410 | 1410 |
delay = compute_target_delay(last_duration, is); |
1411 | 1411 |
|
1412 |
- time= av_gettime()/1000000.0; |
|
1412 |
+ time= av_gettime_relative()/1000000.0; |
|
1413 | 1413 |
if (time < is->frame_timer + delay && !redisplay) { |
1414 | 1414 |
*remaining_time = FFMIN(is->frame_timer + delay - time, *remaining_time); |
1415 | 1415 |
return; |
... | ... |
@@ -1483,7 +1483,7 @@ display: |
1483 | 1483 |
int aqsize, vqsize, sqsize; |
1484 | 1484 |
double av_diff; |
1485 | 1485 |
|
1486 |
- cur_time = av_gettime(); |
|
1486 |
+ cur_time = av_gettime_relative(); |
|
1487 | 1487 |
if (!last_time || (cur_time - last_time) >= 30000) { |
1488 | 1488 |
aqsize = 0; |
1489 | 1489 |
vqsize = 0; |
... | ... |
@@ -1981,7 +1981,7 @@ static int video_thread(void *arg) |
1981 | 1981 |
goto the_end; |
1982 | 1982 |
|
1983 | 1983 |
while (ret >= 0) { |
1984 |
- is->frame_last_returned_time = av_gettime() / 1000000.0; |
|
1984 |
+ is->frame_last_returned_time = av_gettime_relative() / 1000000.0; |
|
1985 | 1985 |
|
1986 | 1986 |
ret = av_buffersink_get_frame_flags(filt_out, frame, 0); |
1987 | 1987 |
if (ret < 0) { |
... | ... |
@@ -1991,7 +1991,7 @@ static int video_thread(void *arg) |
1991 | 1991 |
break; |
1992 | 1992 |
} |
1993 | 1993 |
|
1994 |
- is->frame_last_filter_delay = av_gettime() / 1000000.0 - is->frame_last_returned_time; |
|
1994 |
+ is->frame_last_filter_delay = av_gettime_relative() / 1000000.0 - is->frame_last_returned_time; |
|
1995 | 1995 |
if (fabs(is->frame_last_filter_delay) > AV_NOSYNC_THRESHOLD / 10.0) |
1996 | 1996 |
is->frame_last_filter_delay = 0; |
1997 | 1997 |
tb = filt_out->inputs[0]->time_base; |
... | ... |
@@ -2392,7 +2392,7 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len) |
2392 | 2392 |
VideoState *is = opaque; |
2393 | 2393 |
int audio_size, len1; |
2394 | 2394 |
|
2395 |
- audio_callback_time = av_gettime(); |
|
2395 |
+ audio_callback_time = av_gettime_relative(); |
|
2396 | 2396 |
|
2397 | 2397 |
while (len > 0) { |
2398 | 2398 |
if (is->audio_buf_index >= is->audio_buf_size) { |
... | ... |
@@ -3191,7 +3191,7 @@ static void refresh_loop_wait_event(VideoState *is, SDL_Event *event) { |
3191 | 3191 |
double remaining_time = 0.0; |
3192 | 3192 |
SDL_PumpEvents(); |
3193 | 3193 |
while (!SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS)) { |
3194 |
- if (!cursor_hidden && av_gettime() - cursor_last_shown > CURSOR_HIDE_DELAY) { |
|
3194 |
+ if (!cursor_hidden && av_gettime_relative() - cursor_last_shown > CURSOR_HIDE_DELAY) { |
|
3195 | 3195 |
SDL_ShowCursor(0); |
3196 | 3196 |
cursor_hidden = 1; |
3197 | 3197 |
} |
... | ... |
@@ -3355,7 +3355,7 @@ static void event_loop(VideoState *cur_stream) |
3355 | 3355 |
SDL_ShowCursor(1); |
3356 | 3356 |
cursor_hidden = 0; |
3357 | 3357 |
} |
3358 |
- cursor_last_shown = av_gettime(); |
|
3358 |
+ cursor_last_shown = av_gettime_relative(); |
|
3359 | 3359 |
if (event.type == SDL_MOUSEBUTTONDOWN) { |
3360 | 3360 |
x = event.button.x; |
3361 | 3361 |
} else { |