Commit 6dd96842 authored by Torge Matthies's avatar Torge Matthies Committed by Alexandre Julliard

winepulse.drv: Make timer delay more accurate.

parent b07c33ca
......@@ -38,6 +38,7 @@
#include "winbase.h"
#include "winnls.h"
#include "winreg.h"
#include "winternl.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "wine/list.h"
......@@ -1021,14 +1022,14 @@ static void pulse_read(ACImpl *This)
static DWORD WINAPI pulse_timer_cb(void *user)
{
DWORD delay;
LARGE_INTEGER delay;
UINT32 adv_bytes;
ACImpl *This = user;
int success;
pa_operation *o;
pthread_mutex_lock(&pulse_lock);
delay = This->mmdev_period_usec / 1000;
delay.QuadPart = -This->mmdev_period_usec * 10;
pa_stream_get_time(This->stream, &This->last_time);
pthread_mutex_unlock(&pulse_lock);
......@@ -1036,11 +1037,11 @@ static DWORD WINAPI pulse_timer_cb(void *user)
pa_usec_t now, adv_usec = 0;
int err;
Sleep(delay);
NtDelayExecution(FALSE, &delay);
pthread_mutex_lock(&pulse_lock);
delay = This->mmdev_period_usec / 1000;
delay.QuadPart = -This->mmdev_period_usec * 10;
o = pa_stream_update_timing_info(This->stream, pulse_op_cb, &success);
if (o)
......@@ -1076,7 +1077,7 @@ static DWORD WINAPI pulse_timer_cb(void *user)
else if(adjust < -((INT32)(This->mmdev_period_usec / 2)))
adjust = -1 * This->mmdev_period_usec / 2;
delay = (This->mmdev_period_usec + adjust) / 1000;
delay.QuadPart = -(This->mmdev_period_usec + adjust) * 10;
This->last_time += This->mmdev_period_usec;
}
......@@ -1094,16 +1095,16 @@ static DWORD WINAPI pulse_timer_cb(void *user)
}
}else{
This->last_time = now;
delay = This->mmdev_period_usec / 1000;
delay.QuadPart = -This->mmdev_period_usec * 10;
}
}
if (This->event)
SetEvent(This->event);
TRACE("%p after update, adv usec: %d, held: %u, delay: %u\n",
TRACE("%p after update, adv usec: %d, held: %u, delay usec: %u\n",
This, (int)adv_usec,
(int)(This->held_bytes/ pa_frame_size(&This->ss)), delay);
(int)(This->held_bytes/ pa_frame_size(&This->ss)), (unsigned int)(-delay.QuadPart / 10));
pthread_mutex_unlock(&pulse_lock);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment