Skip to content

Commit

Permalink
Experimental fix for win 32 timer
Browse files Browse the repository at this point in the history
  • Loading branch information
jonoomph committed Dec 8, 2024
1 parent 94ff22a commit 6e61142
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ class PlatformTimer final
explicit PlatformTimer (PlatformTimerListener& ptl)
: listener { ptl } {}

void startTimer (int newIntervalMs)
void startTimer(int newIntervalMs)
{
jassert (newIntervalMs > 0);
jassert(newIntervalMs > 0);

const auto callback = [] (UINT, UINT, DWORD_PTR context, DWORD_PTR, DWORD_PTR)
// Define the callback with __stdcall explicitly
static void __stdcall timerCallback(UINT, UINT, DWORD_PTR context, DWORD_PTR, DWORD_PTR)
{
reinterpret_cast<PlatformTimerListener*> (context)->onTimerExpired();
};
reinterpret_cast<PlatformTimerListener*>(context)->onTimerExpired();
}

timerId = timeSetEvent ((UINT) newIntervalMs, 1, callback, (DWORD_PTR) &listener, TIME_PERIODIC | TIME_CALLBACK_FUNCTION);
// Use the explicitly defined callback
timerId = timeSetEvent((UINT)newIntervalMs, 1, timerCallback, (DWORD_PTR)&listener, TIME_PERIODIC | TIME_CALLBACK_FUNCTION);
intervalMs = timerId != 0 ? newIntervalMs : 0;
}

Expand Down

0 comments on commit 6e61142

Please sign in to comment.