summaryrefslogtreecommitdiffstats
path: root/video/out/vo_vdpau.c
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 /video/out/vo_vdpau.c
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 'video/out/vo_vdpau.c')
-rw-r--r--video/out/vo_vdpau.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c
index d213b33c6f..975ef526c3 100644
--- a/video/out/vo_vdpau.c
+++ b/video/out/vo_vdpau.c
@@ -97,13 +97,13 @@ struct vdpctx {
bool is_preempted;
bool preemption_acked;
bool preemption_user_notified;
- unsigned int last_preemption_retry_fail;
+ double last_preemption_retry_fail;
VdpGetProcAddress *vdp_get_proc_address;
VdpPresentationQueueTarget flip_target;
VdpPresentationQueue flip_queue;
uint64_t last_vdp_time;
- unsigned int last_sync_update;
+ uint64_t last_sync_update;
VdpOutputSurface output_surfaces[MAX_OUTPUT_SURFACES];
VdpOutputSurface screenshot_surface;
@@ -181,15 +181,15 @@ struct vdpctx {
static bool status_ok(struct vo *vo);
-static int change_vdptime_sync(struct vdpctx *vc, unsigned int *t)
+static int change_vdptime_sync(struct vdpctx *vc, int64_t *t)
{
struct vdp_functions *vdp = vc->vdp;
VdpStatus vdp_st;
VdpTime vdp_time;
vdp_st = vdp->presentation_queue_get_time(vc->flip_queue, &vdp_time);
CHECK_ST_ERROR("Error when calling vdp_presentation_queue_get_time");
- unsigned int t1 = *t;
- unsigned int t2 = GetTimer();
+ uint64_t t1 = *t;
+ uint64_t t2 = mp_time_us();
uint64_t old = vc->last_vdp_time + (t1 - vc->last_sync_update) * 1000ULL;
if (vdp_time > old) {
if (vdp_time > old + (t2 - t1) * 1000ULL)
@@ -209,7 +209,7 @@ static uint64_t sync_vdptime(struct vo *vo)
{
struct vdpctx *vc = vo->priv;
- unsigned int t = GetTimer();
+ uint64_t t = mp_time_us();
if (t - vc->last_sync_update > 5000000)
change_vdptime_sync(vc, &t);
uint64_t now = (t - vc->last_sync_update) * 1000ULL + vc->last_vdp_time;
@@ -218,10 +218,10 @@ static uint64_t sync_vdptime(struct vo *vo)
return now;
}
-static uint64_t convert_to_vdptime(struct vo *vo, unsigned int t)
+static uint64_t convert_to_vdptime(struct vo *vo, uint64_t t)
{
struct vdpctx *vc = vo->priv;
- return (int)(t - vc->last_sync_update) * 1000LL + vc->last_vdp_time;
+ return (t - vc->last_sync_update) * 1000LL + vc->last_vdp_time;
}
static int render_video_to_output_surface(struct vo *vo,
@@ -513,7 +513,7 @@ static int win_x11_init_vdpau_flip_queue(struct vo *vo)
vdp_st = vdp->presentation_queue_get_time(vc->flip_queue, &vdp_time);
CHECK_ST_ERROR("Error when calling vdp_presentation_queue_get_time");
vc->last_vdp_time = vdp_time;
- vc->last_sync_update = GetTimer();
+ vc->last_sync_update = mp_time_us();
vc->vsync_interval = 1;
if (vc->composite_detect && vo_x11_screen_is_composited(vo)) {
@@ -822,11 +822,11 @@ static int handle_preemption(struct vo *vo)
}
/* Trying to initialize seems to be quite slow, so only try once a
* second to avoid using 100% CPU. */
- if (vc->last_preemption_retry_fail
- && GetTimerMS() - vc->last_preemption_retry_fail < 1000)
+ if (vc->last_preemption_retry_fail &&
+ mp_time_sec() - vc->last_preemption_retry_fail < 1.0)
return -1;
if (win_x11_init_vdpau_procs(vo) < 0 || initialize_vdpau_objects(vo) < 0) {
- vc->last_preemption_retry_fail = GetTimerMS() | 1;
+ vc->last_preemption_retry_fail = mp_time_sec();
return -1;
}
vc->last_preemption_retry_fail = 0;
@@ -1102,7 +1102,7 @@ static inline uint64_t prev_vs2(struct vdpctx *vc, uint64_t ts, int shift)
return ts - offset;
}
-static void flip_page_timed(struct vo *vo, unsigned int pts_us, int duration)
+static void flip_page_timed(struct vo *vo, int64_t pts_us, int duration)
{
struct vdpctx *vc = vo->priv;
struct vdp_functions *vdp = vc->vdp;