dsound: Make timer more robust.
This commit is contained in:
parent
3f762d5d0b
commit
abe8c127d9
|
@ -1514,10 +1514,26 @@ HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGUID lpcG
|
||||||
|
|
||||||
hr = DSOUND_PrimaryCreate(device);
|
hr = DSOUND_PrimaryCreate(device);
|
||||||
if (hr == DS_OK) {
|
if (hr == DS_OK) {
|
||||||
|
UINT triggertime = DS_TIME_DEL, res = DS_TIME_RES, id;
|
||||||
|
TIMECAPS time;
|
||||||
|
|
||||||
DSOUND_renderer[device->drvdesc.dnDevNode] = device;
|
DSOUND_renderer[device->drvdesc.dnDevNode] = device;
|
||||||
timeBeginPeriod(DS_TIME_RES);
|
timeGetDevCaps(&time, sizeof(TIMECAPS));
|
||||||
DSOUND_renderer[device->drvdesc.dnDevNode]->timerID = timeSetEvent(DS_TIME_DEL, DS_TIME_RES, DSOUND_timer,
|
TRACE("Minimum timer resolution: %u, max timer: %u\n", time.wPeriodMin, time.wPeriodMax);
|
||||||
(DWORD_PTR)DSOUND_renderer[device->drvdesc.dnDevNode], TIME_PERIODIC | TIME_CALLBACK_FUNCTION | TIME_KILL_SYNCHRONOUS);
|
if (triggertime < time.wPeriodMin)
|
||||||
|
triggertime = time.wPeriodMin;
|
||||||
|
if (res < time.wPeriodMin)
|
||||||
|
res = time.wPeriodMin;
|
||||||
|
if (timeBeginPeriod(res) == TIMERR_NOCANDO)
|
||||||
|
WARN("Could not set minimum resolution, don't expect sound\n");
|
||||||
|
id = timeSetEvent(triggertime, res, DSOUND_timer, (DWORD_PTR)device, TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
|
||||||
|
if (!id)
|
||||||
|
{
|
||||||
|
WARN("Timer not created! Retrying without TIME_KILL_SYNCHRONOUS\n");
|
||||||
|
id = timeSetEvent(triggertime, res, DSOUND_timer, (DWORD_PTR)device, TIME_PERIODIC);
|
||||||
|
if (!id) ERR("Could not create timer, sound playback will not occur\n");
|
||||||
|
}
|
||||||
|
DSOUND_renderer[device->drvdesc.dnDevNode]->timerID = id;
|
||||||
} else {
|
} else {
|
||||||
WARN("DSOUND_PrimaryCreate failed\n");
|
WARN("DSOUND_PrimaryCreate failed\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue