Archived
1
0
This repository has been archived on 2024-10-17. You can view files and clone it, but cannot push or open issues or pull requests.
winamp/Src/Wasabi/api/timer/osx_timer.cpp
2024-09-24 14:54:57 +02:00

39 lines
1007 B
C++

#include "osx_timer.h"
#include <api/timer/timerclient.h>
timer_api *timerApi = NULL;
TimerApi::TimerApi()
{
mainEventLoop = GetMainEventLoop();
}
static void WasabiTimerProc(EventLoopTimerRef inTimer, void * inUserData)
{
TimerClient *client = (TimerClient *)inUserData;
if (client)
client->timerclient_timerCallback(inTimer);
}
TimerToken TimerApi::timer_add(TimerClient *client, int id, int ms)
{
EventLoopTimerRef token;
OSStatus err = InstallEventLoopTimer(mainEventLoop,
(float)ms/1000.0f,
(float)ms/1000.0f,
WasabiTimerProc,
client,
&token);
if (err == noErr)
return token;
else
return 0;
}
void TimerApi::timer_remove(TimerClient *client, TimerToken token)
{
RemoveEventLoopTimer(token);
}