xaudio2: Fix mmdevapi buffer size calculation.

Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
This commit is contained in:
Andrew Eikum 2015-09-24 14:33:05 -05:00 committed by Alexandre Julliard
parent f9bae3e5a2
commit 2decbcc05f
1 changed files with 10 additions and 7 deletions

View File

@ -1798,7 +1798,7 @@ static HRESULT WINAPI IXAudio2Impl_CreateMasteringVoice(IXAudio2 *iface,
HRESULT hr;
WAVEFORMATEX *fmt;
ALCint attrs[7];
REFERENCE_TIME period;
REFERENCE_TIME period, bufdur;
TRACE("(%p)->(%p, %u, %u, 0x%x, %s, %p, 0x%x)\n", This,
ppMasteringVoice, inputChannels, inputSampleRate, flags,
@ -1885,18 +1885,21 @@ static HRESULT WINAPI IXAudio2Impl_CreateMasteringVoice(IXAudio2 *iface,
CoTaskMemFree(fmt);
hr = IAudioClient_Initialize(This->aclient, AUDCLNT_SHAREMODE_SHARED,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK, inputSampleRate /* 1s buffer */,
0, &This->fmt.Format, NULL);
hr = IAudioClient_GetDevicePeriod(This->aclient, &period, NULL);
if(FAILED(hr)){
WARN("Initialize failed: %08x\n", hr);
WARN("GetDevicePeriod failed: %08x\n", hr);
hr = XAUDIO2_E_DEVICE_INVALIDATED;
goto exit;
}
hr = IAudioClient_GetDevicePeriod(This->aclient, &period, NULL);
/* 3 periods or 0.1 seconds */
bufdur = max(3 * period, 1000000);
hr = IAudioClient_Initialize(This->aclient, AUDCLNT_SHAREMODE_SHARED,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK, bufdur,
0, &This->fmt.Format, NULL);
if(FAILED(hr)){
WARN("GetDevicePeriod failed: %08x\n", hr);
WARN("Initialize failed: %08x\n", hr);
hr = XAUDIO2_E_DEVICE_INVALIDATED;
goto exit;
}