Get the mmdevapi device period after initialization
This commit is contained in:
parent
60785eab8e
commit
70f1a7e3ca
@ -204,7 +204,7 @@ static HRESULT DoReset(ALCdevice *device)
|
||||
MMDevApiData *data = device->ExtraData;
|
||||
WAVEFORMATEXTENSIBLE OutputType;
|
||||
WAVEFORMATEX *wfx = NULL;
|
||||
REFERENCE_TIME min_per;
|
||||
REFERENCE_TIME min_per, buf_time;
|
||||
UINT32 buffer_len, min_len;
|
||||
HRESULT hr;
|
||||
|
||||
@ -391,38 +391,30 @@ static HRESULT DoReset(ALCdevice *device)
|
||||
|
||||
SetDefaultWFXChannelOrder(device);
|
||||
|
||||
hr = IAudioClient_GetDevicePeriod(data->client, &min_per, NULL);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
min_len = (min_per*device->Frequency + 10000000-1) / 10000000;
|
||||
if(min_len < device->UpdateSize)
|
||||
min_len *= (device->UpdateSize + min_len/2)/min_len;
|
||||
|
||||
device->NumUpdates = (device->NumUpdates*device->UpdateSize + min_len/2) /
|
||||
min_len;
|
||||
device->NumUpdates = maxu(device->NumUpdates, 2);
|
||||
device->UpdateSize = min_len;
|
||||
|
||||
hr = IAudioClient_Initialize(data->client, AUDCLNT_SHAREMODE_SHARED,
|
||||
AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
|
||||
((REFERENCE_TIME)device->UpdateSize*
|
||||
device->NumUpdates*10000000 +
|
||||
device->Frequency-1) / device->Frequency,
|
||||
0, &OutputType.Format, NULL);
|
||||
}
|
||||
buf_time = ((REFERENCE_TIME)device->UpdateSize*device->NumUpdates*10000000 +
|
||||
device->Frequency-1) / device->Frequency;
|
||||
hr = IAudioClient_Initialize(data->client, AUDCLNT_SHAREMODE_SHARED,
|
||||
AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
|
||||
buf_time, 0, &OutputType.Format, NULL);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
ERR("Failed to initialize audio client: 0x%08lx\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = IAudioClient_GetBufferSize(data->client, &buffer_len);
|
||||
hr = IAudioClient_GetDevicePeriod(data->client, &min_per, NULL);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
min_len = (min_per*device->Frequency + 10000000-1) / 10000000;
|
||||
hr = IAudioClient_GetBufferSize(data->client, &buffer_len);
|
||||
}
|
||||
if(FAILED(hr))
|
||||
{
|
||||
ERR("Failed to get audio buffer info: 0x%08lx\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
device->UpdateSize = min_len;
|
||||
device->NumUpdates = buffer_len / device->UpdateSize;
|
||||
if(device->NumUpdates <= 1)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user