mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-05-31 17:20:54 +00:00
Handle deprecation of GTimeVal (#575)
`GTimeVal` has been deprecated in glib 2.62 . While switching to `g_get_monotonic_time()`, I realized that we could simply reuse `fluid_utime()` for that purpose.
This commit is contained in:
parent
dfcf5c019f
commit
64cee5537d
1 changed files with 7 additions and 8 deletions
|
@ -313,22 +313,21 @@ void fluid_msleep(unsigned int msecs)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get time in milliseconds to be used in relative timing operations.
|
* Get time in milliseconds to be used in relative timing operations.
|
||||||
* @return Unix time in milliseconds.
|
* @return Monotonic time in milliseconds.
|
||||||
*/
|
*/
|
||||||
unsigned int fluid_curtime(void)
|
unsigned int fluid_curtime(void)
|
||||||
{
|
{
|
||||||
static glong initial_seconds = 0;
|
float now;
|
||||||
GTimeVal timeval;
|
static float initial_time = 0;
|
||||||
|
|
||||||
if(initial_seconds == 0)
|
if(initial_time == 0)
|
||||||
{
|
{
|
||||||
g_get_current_time(&timeval);
|
initial_time = (float)fluid_utime();
|
||||||
initial_seconds = timeval.tv_sec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_get_current_time(&timeval);
|
now = (float)fluid_utime();
|
||||||
|
|
||||||
return (unsigned int)((timeval.tv_sec - initial_seconds) * 1000.0 + timeval.tv_usec / 1000.0);
|
return (unsigned int)((now - initial_time) / 1000.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue