mmdevapi: Use a sane default if no buffer size is requested.

This commit is contained in:
Andrew Eikum 2011-07-18 11:19:30 -05:00 committed by Alexandre Julliard
parent 9a30a29db5
commit 80fd691e9e
4 changed files with 15 additions and 0 deletions

View File

@ -211,6 +211,15 @@ static void test_audioclient(void)
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000, 0, NULL, NULL);
ok(hr == E_POINTER, "Initialize with null format returns %08x\n", hr);
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 0, 0, pwfx, NULL);
ok(hr == S_OK, "Initialize with 0 buffer size returns %08x\n", hr);
IAudioClient_Release(ac);
hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
NULL, (void**)&ac);
ok(hr == S_OK, "Activation failed with %08x\n", hr);
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED, 0, 5000000, 0, pwfx, NULL);
ok(hr == S_OK, "Valid Initialize returns %08x\n", hr);

View File

@ -799,6 +799,8 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
goto exit;
}
if(!duration)
duration = 300000; /* 0.03s */
This->bufsize_frames = ceil((duration / 10000000.) * fmt->nSamplesPerSec);
This->local_buffer = HeapAlloc(GetProcessHeap(), 0,
This->bufsize_frames * fmt->nBlockAlign);

View File

@ -862,6 +862,8 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
}else
This->period_ms = MinimumPeriod / 10000;
if(!duration)
duration = 300000; /* 0.03s */
This->bufsize_frames = ceil(fmt->nSamplesPerSec * (duration / 10000000.));
if(This->dataflow == eCapture){

View File

@ -819,6 +819,8 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
else
This->period_us = DefaultPeriod / 10;
if(!duration)
duration = 300000; /* 0.03s */
This->bufsize_frames = ceil(fmt->nSamplesPerSec * (duration / 10000000.));
This->local_buffer = HeapAlloc(GetProcessHeap(), 0,
This->bufsize_frames * fmt->nBlockAlign);