Use millisecond resolution for the Null and Wave Writer backends

This commit is contained in:
Chris Robinson 2010-08-02 22:34:19 -07:00
parent 3bece35bbd
commit 1504cf8812
2 changed files with 22 additions and 6 deletions

View File

@ -31,6 +31,7 @@ typedef struct {
ALuint size;
ALuint startTime;
ALuint64 baseTime;
volatile int killNow;
ALvoid *thread;
@ -114,8 +115,7 @@ static ALCboolean null_reset_playback(ALCdevice *device)
}
SetDefaultWFXChannelOrder(device);
device->TimeRes = (ALuint64)device->UpdateSize * 1000000000 /
device->Frequency;
device->TimeRes = 1000000;
data->startTime = timeGetTime();
data->thread = StartThread(NullProc, device);
@ -132,6 +132,7 @@ static ALCboolean null_reset_playback(ALCdevice *device)
static void null_stop_playback(ALCdevice *device)
{
null_data *data = (null_data*)device->ExtraData;
ALuint ext;
if(!data->thread)
return;
@ -142,6 +143,9 @@ static void null_stop_playback(ALCdevice *device)
data->killNow = 0;
ext = timeGetTime() - data->startTime;
data->baseTime += (ALuint64)ext * 1000000;
free(data->buffer);
data->buffer = NULL;
}
@ -156,7 +160,11 @@ static ALCboolean null_open_capture(ALCdevice *device, const ALCchar *deviceName
static ALuint64 null_get_time(ALCdevice *Device)
{
return Device->SamplesPlayed * 1000000000 / Device->Frequency;
null_data *data = (null_data*)Device->ExtraData;
ALuint ext = 0;
if(data->thread)
ext = timeGetTime() - data->startTime;
return data->baseTime + ((ALuint64)ext * 1000000);
}

View File

@ -36,6 +36,7 @@ typedef struct {
ALuint size;
ALuint startTime;
ALuint64 baseTime;
volatile int killNow;
ALvoid *thread;
@ -282,9 +283,8 @@ static ALCboolean wave_reset_playback(ALCdevice *device)
return ALC_FALSE;
}
device->TimeRes = (ALuint64)device->UpdateSize * 1000000000 /
device->Frequency;
SetDefaultWFXChannelOrder(device);
device->TimeRes = 1000000;
data->startTime = timeGetTime();
data->thread = StartThread(WaveProc, device);
@ -302,6 +302,7 @@ static void wave_stop_playback(ALCdevice *device)
{
wave_data *data = (wave_data*)device->ExtraData;
ALuint dataLen;
ALuint ext;
long size;
if(!data->thread)
@ -313,6 +314,9 @@ static void wave_stop_playback(ALCdevice *device)
data->killNow = 0;
ext = timeGetTime() - data->startTime;
data->baseTime += (ALuint64)ext * 1000000;
free(data->buffer);
data->buffer = NULL;
@ -348,7 +352,11 @@ static ALCboolean wave_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam
static ALuint64 wave_get_time(ALCdevice *Device)
{
return Device->SamplesPlayed * 1000000000 / Device->Frequency;
wave_data *data = (wave_data*)Device->ExtraData;
ALuint ext = 0;
if(data->thread)
ext = timeGetTime() - data->startTime;
return data->baseTime + ((ALuint64)ext * 1000000);
}