mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-19 17:06:04 -07:00
Compare commits
3 commits
b113cae60c
...
238856b253
Author | SHA1 | Date | |
---|---|---|---|
|
238856b253 | ||
|
d15b6f0e01 | ||
|
be97c86737 |
2 changed files with 77 additions and 19 deletions
|
@ -2673,6 +2673,81 @@ static void test_endpointvolume(void)
|
|||
IAudioEndpointVolume_Release(aev);
|
||||
}
|
||||
|
||||
static void test_audio_clock_adjustment(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
IAudioClient *ac;
|
||||
IAudioClockAdjustment *aca;
|
||||
UINT bufsize, expected_bufsize;
|
||||
WAVEFORMATEX *pwfx;
|
||||
HANDLE event;
|
||||
|
||||
const REFERENCE_TIME buffer_duration = 500000;
|
||||
|
||||
hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
|
||||
NULL, (void**)&ac);
|
||||
ok(hr == S_OK, "Activation failed with %08lx\n", hr);
|
||||
if(hr != S_OK)
|
||||
return;
|
||||
|
||||
hr = IAudioClient_GetMixFormat(ac, &pwfx);
|
||||
ok(hr == S_OK, "GetMixFormat failed: %08lx\n", hr);
|
||||
|
||||
pwfx->nSamplesPerSec = 44100;
|
||||
expected_bufsize = (buffer_duration / 10000000.) * pwfx->nSamplesPerSec;
|
||||
|
||||
hr = IAudioClient_Initialize(ac, AUDCLNT_SHAREMODE_SHARED,
|
||||
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_RATEADJUST, buffer_duration, 0, pwfx, NULL);
|
||||
ok(hr == S_OK, "Initialize failed: %08lx\n", hr);
|
||||
if(hr != S_OK)
|
||||
return;
|
||||
|
||||
hr = IAudioClient_GetBufferSize(ac, &bufsize);
|
||||
ok(bufsize == expected_bufsize, "unexpected bufsize %d expected %d\n", bufsize, expected_bufsize);
|
||||
|
||||
hr = IAudioClient_GetService(ac, &IID_IAudioClockAdjustment, (void**)&aca);
|
||||
ok(hr == S_OK, "IAudioClient_GetService(IID_IAudioClockAdjustment) returned %08lx\n", hr);
|
||||
|
||||
event = CreateEventW(NULL, FALSE, FALSE, NULL);
|
||||
ok(event != NULL, "CreateEvent failed\n");
|
||||
|
||||
hr = IAudioClient_SetEventHandle(ac, event);
|
||||
ok(hr == S_OK, "SetEventHandle failed: %08lx\n", hr);
|
||||
|
||||
hr = IAudioClient_Start(ac);
|
||||
ok(hr == S_OK, "Start failed: %08lx\n", hr);
|
||||
|
||||
hr = IAudioClockAdjustment_SetSampleRate(aca, 48000.00f);
|
||||
ok(hr == S_OK, "SetSampleRate failed: %08lx\n", hr);
|
||||
|
||||
/* Wait for frame processing */
|
||||
WaitForSingleObject(event, 1000);
|
||||
|
||||
hr = IAudioClient_GetBufferSize(ac, &bufsize);
|
||||
ok(bufsize == expected_bufsize, "unexpected bufsize %d expected %d\n", bufsize, expected_bufsize);
|
||||
|
||||
hr = IAudioClockAdjustment_SetSampleRate(aca, 44100.00f);
|
||||
ok(hr == S_OK, "SetSampleRate failed: %08lx\n", hr);
|
||||
|
||||
/* Wait for frame processing */
|
||||
WaitForSingleObject(event, 1000);
|
||||
|
||||
hr = IAudioClient_GetBufferSize(ac, &bufsize);
|
||||
ok(bufsize == expected_bufsize, "unexpected bufsize %d expected %d\n", bufsize, expected_bufsize);
|
||||
|
||||
hr = IAudioClockAdjustment_SetSampleRate(aca, 22050.00f);
|
||||
ok(hr == S_OK, "SetSampleRate failed: %08lx\n", hr);
|
||||
|
||||
/* Wait for frame processing */
|
||||
WaitForSingleObject(event, 1000);
|
||||
|
||||
hr = IAudioClient_GetBufferSize(ac, &bufsize);
|
||||
ok(bufsize == expected_bufsize, "unexpected bufsize %d expected %d\n", bufsize, expected_bufsize);
|
||||
|
||||
IAudioClockAdjustment_Release(aca);
|
||||
IAudioClient_Release(ac);
|
||||
}
|
||||
|
||||
START_TEST(render)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
@ -2719,6 +2794,7 @@ START_TEST(render)
|
|||
test_session_creation();
|
||||
test_worst_case();
|
||||
test_endpointvolume();
|
||||
test_audio_clock_adjustment();
|
||||
|
||||
IMMDevice_Release(dev);
|
||||
|
||||
|
|
|
@ -2494,8 +2494,6 @@ static NTSTATUS pulse_set_sample_rate(void *args)
|
|||
struct pulse_stream *stream = handle_get_stream(params->stream);
|
||||
HRESULT hr = S_OK;
|
||||
int success;
|
||||
SIZE_T size, new_bufsize_frames;
|
||||
BYTE *new_buffer = NULL;
|
||||
pa_sample_spec new_ss;
|
||||
|
||||
pulse_lock();
|
||||
|
@ -2510,22 +2508,12 @@ static NTSTATUS pulse_set_sample_rate(void *args)
|
|||
|
||||
new_ss = stream->ss;
|
||||
new_ss.rate = params->rate;
|
||||
new_bufsize_frames = ceil((stream->duration / 10000000.) * new_ss.rate);
|
||||
size = new_bufsize_frames * 2 * pa_frame_size(&stream->ss);
|
||||
|
||||
if (NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&new_buffer,
|
||||
zero_bits, &size, MEM_COMMIT, PAGE_READWRITE)) {
|
||||
hr = E_OUTOFMEMORY;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!wait_pa_operation_complete(pa_stream_update_sample_rate(stream->stream, params->rate, pulse_op_cb, &success)))
|
||||
success = 0;
|
||||
|
||||
if (!success) {
|
||||
hr = E_OUTOFMEMORY;
|
||||
size = 0;
|
||||
NtFreeVirtualMemory(GetCurrentProcess(), (void **)&new_buffer, &size, MEM_RELEASE);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -2536,15 +2524,9 @@ static NTSTATUS pulse_set_sample_rate(void *args)
|
|||
stream->pa_offs_bytes = stream->lcl_offs_bytes = 0;
|
||||
stream->held_bytes = stream->pa_held_bytes = 0;
|
||||
stream->period_bytes = pa_frame_size(&new_ss) * muldiv(stream->mmdev_period_usec, new_ss.rate, 1000000);
|
||||
stream->real_bufsize_bytes = size;
|
||||
stream->bufsize_frames = new_bufsize_frames;
|
||||
stream->ss = new_ss;
|
||||
|
||||
size = 0;
|
||||
NtFreeVirtualMemory(GetCurrentProcess(), (void **)&stream->local_buffer, &size, MEM_RELEASE);
|
||||
|
||||
silence_buffer(new_ss.format, new_buffer, stream->real_bufsize_bytes);
|
||||
stream->local_buffer = new_buffer;
|
||||
silence_buffer(new_ss.format, stream->local_buffer, stream->real_bufsize_bytes);
|
||||
|
||||
exit:
|
||||
pulse_unlock();
|
||||
|
|
Loading…
Reference in a new issue