Question

I'm writing this post in case anyone else is having the same issue I've been having with the lack of documentation for the CVDisplayLink API.

Intro:

In my CVDisplayLink code I've been using the following code to obtain the deltaSeconds value between calls to its callback:

float deltaTime = 1.0 / (outputTime->rateScalar * (float)outputTime->videoTimeScale / (float)outputTime->videoRefreshPeriod);

It seems like this line of code is widely used across different apps & engines.

The issue:

While running my OpenGL app I've noticed that this value is now constant (0.016669 to be precise). I haven't made any big changes to account for this change of behaviour, other than using Mavericks and the new development tools.

Finding the cause has been a lost cause so far.

Was it helpful?

Solution

I've found what I believe is a good way to calculate the deltaSeconds between frames by using the following alternative code:

double deltaSeconds = (outputTime->videoTime - self.previousOutputVideoTime) / (double)outputTime->videoTimeScale;
self.previousOutputVideoTime = outputTime->videoTime;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top