Commit 3b043e72 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winecoreaudio: Introduce a helper to retrieve the time.

The motivation is that this will need to be called from a non-Win32 thread and so shouldn't use the Win32 API. An added benefit is that it will eliminate the 16ms jitter associated with GetTickCount(). The instance of the helper on the user-side is temporary. Signed-off-by: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarAndrew Eikum <aeikum@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 4c04fb00
......@@ -143,6 +143,14 @@ static void set_in_notify(struct notify_context *notify, struct midi_src *src, W
* CoreMIDI IO threaded callback,
* we can't call Wine debug channels, critical section or anything using NtCurrentTeb here.
*/
static uint64_t get_time_ms(void)
{
static mach_timebase_info_data_t timebase;
if (!timebase.denom) mach_timebase_info(&timebase);
return mach_absolute_time() / 1000000 * timebase.numer / timebase.denom;
}
static void midi_in_read_proc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon)
{
CFMessagePortRef msg_port = CFMessagePortCreateRemote(kCFAllocatorDefault, midi_in_thread_port_name);
......@@ -917,7 +925,7 @@ static DWORD midi_in_start(WORD dev_id)
return MMSYSERR_BADDEVICEID;
}
srcs[dev_id].state = 1;
srcs[dev_id].startTime = NtGetTickCount();
srcs[dev_id].startTime = get_time_ms();
return MMSYSERR_NOERROR;
}
......@@ -936,7 +944,7 @@ static DWORD midi_in_stop(WORD dev_id)
static DWORD midi_in_reset(WORD dev_id, struct notify_context *notify)
{
DWORD cur_time = NtGetTickCount();
DWORD cur_time = get_time_ms();
DWORD err = MMSYSERR_NOERROR;
struct midi_src *src;
MIDIHDR *hdr;
......
......@@ -45,6 +45,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(midi);
#include <mach/mach_time.h>
#include <CoreAudio/CoreAudio.h>
#define WINE_DEFINITIONS
......@@ -61,6 +62,14 @@ static MIDIPortRef MIDIInPort = NULL;
MIDISource *sources;
static uint64_t get_time_ms(void)
{
static mach_timebase_info_data_t timebase;
if (!timebase.denom) mach_timebase_info(&timebase);
return mach_absolute_time() / 1000000 * timebase.numer / timebase.denom;
}
static void notify_client(struct notify_context *notify)
{
TRACE("dev_id=%d msg=%d param1=%04lX param2=%04lX\n", notify->dev_id, notify->msg, notify->param_1, notify->param_2);
......@@ -183,7 +192,7 @@ static CFDataRef MIDIIn_MessageHandler(CFMessagePortRef local, SInt32 msgid, CFD
}
midi_lock( TRUE );
currentTime = GetTickCount() - src->startTime;
currentTime = get_time_ms() - src->startTime;
while (len) {
LPMIDIHDR lpMidiHdr = src->lpQueueHdr;
......@@ -218,7 +227,7 @@ static CFDataRef MIDIIn_MessageHandler(CFMessagePortRef local, SInt32 msgid, CFD
}
midi_lock( TRUE );
currentTime = GetTickCount() - src->startTime;
currentTime = get_time_ms() - src->startTime;
while (pos < msg->length)
{
......
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