mirror of
https://github.com/mii443/qemu.git
synced 2025-12-16 17:18:49 +00:00
qemu-timer: move timeBeginPeriod/timeEndPeriod to os-win32
These are needed for any of the Win32 alarm timer implementations. They are not tied to mmtimer exclusively. Jacob tested this patch with both mmtimer and Win32 timers. Cc: qemu-stable@nongnu.org Tested-by: Jacob Kroon <jacob.kroon@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
committed by
Stefan Weil
parent
1046127d1f
commit
0727b86754
24
qemu-timer.c
24
qemu-timer.c
@@ -624,28 +624,14 @@ static void CALLBACK mm_alarm_handler(UINT uTimerID, UINT uMsg,
|
||||
static int mm_start_timer(struct qemu_alarm_timer *t)
|
||||
{
|
||||
timeGetDevCaps(&mm_tc, sizeof(mm_tc));
|
||||
|
||||
timeBeginPeriod(mm_tc.wPeriodMin);
|
||||
|
||||
mm_timer = timeSetEvent(mm_tc.wPeriodMin, /* interval (ms) */
|
||||
mm_tc.wPeriodMin, /* resolution */
|
||||
mm_alarm_handler, /* function */
|
||||
(DWORD_PTR)t, /* parameter */
|
||||
TIME_ONESHOT | TIME_CALLBACK_FUNCTION);
|
||||
|
||||
if (!mm_timer) {
|
||||
fprintf(stderr, "Failed to initialize win32 alarm timer\n");
|
||||
timeEndPeriod(mm_tc.wPeriodMin);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mm_stop_timer(struct qemu_alarm_timer *t)
|
||||
{
|
||||
timeKillEvent(mm_timer);
|
||||
timeEndPeriod(mm_tc.wPeriodMin);
|
||||
if (mm_timer) {
|
||||
timeKillEvent(mm_timer);
|
||||
}
|
||||
}
|
||||
|
||||
static void mm_rearm_timer(struct qemu_alarm_timer *t, int64_t delta)
|
||||
@@ -657,7 +643,9 @@ static void mm_rearm_timer(struct qemu_alarm_timer *t, int64_t delta)
|
||||
nearest_delta_ms = mm_tc.wPeriodMax;
|
||||
}
|
||||
|
||||
timeKillEvent(mm_timer);
|
||||
if (mm_timer) {
|
||||
timeKillEvent(mm_timer);
|
||||
}
|
||||
mm_timer = timeSetEvent((UINT)nearest_delta_ms,
|
||||
mm_tc.wPeriodMin,
|
||||
mm_alarm_handler,
|
||||
|
||||
Reference in New Issue
Block a user