Commit ec69d69f authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

dmsynth: Implement the sink GetDesiredBufferSize method.

parent a0addfe3
......@@ -180,11 +180,22 @@ static HRESULT WINAPI IDirectMusicSynthSinkImpl_SetDirectSound(IDirectMusicSynth
}
static HRESULT WINAPI IDirectMusicSynthSinkImpl_GetDesiredBufferSize(IDirectMusicSynthSink *iface,
DWORD *buffer_size_in_samples)
DWORD *size)
{
IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
WAVEFORMATEX format;
DWORD fmtsize = sizeof(format);
FIXME("(%p)->(%p): stub\n", This, buffer_size_in_samples);
TRACE("(%p, %p)\n", This, size);
if (!size)
return E_POINTER;
if (!This->synth)
return DMUS_E_SYNTHNOTCONFIGURED;
if (FAILED(IDirectMusicSynth_GetFormat(This->synth, &format, &fmtsize)))
return E_UNEXPECTED;
*size = format.nSamplesPerSec * format.nChannels * 4;
return S_OK;
}
......
......@@ -149,6 +149,8 @@ static void test_dmsynth(void)
/* Synth isn't fully initialized yet */
hr = IDirectMusicSynth_Activate(dmsynth, TRUE);
ok(hr == DMUS_E_NOSYNTHSINK, "IDirectMusicSynth_Activate returned: %#lx\n", hr);
hr = IDirectMusicSynthSink_GetDesiredBufferSize(dmsynth_sink, &size);
ok(hr == DMUS_E_SYNTHNOTCONFIGURED, "IDirectMusicSynthSink_GetDesiredBufferSize returned: %#lx\n", hr);
/* Open / Close */
hr = IDirectMusicSynth_Open(dmsynth, NULL);
......@@ -274,6 +276,28 @@ static void test_dmsynth(void)
hr = IDirectMusicSynth_GetFormat(dmsynth, &format, &size);
ok(hr == S_OK, "GetFormat failed: %#lx\n", hr);
ok(size == sizeof(format), "GetFormat size mismatch, got %ld\n", size);
IDirectMusicSynth_Close(dmsynth);
/* GetDesiredBufferSize */
hr = IDirectMusicSynthSink_GetDesiredBufferSize(dmsynth_sink, NULL);
ok(hr == E_POINTER, "IDirectMusicSynthSink_GetDesiredBufferSize returned: %#lx\n", hr);
hr = IDirectMusicSynthSink_GetDesiredBufferSize(dmsynth_sink, &size);
ok(hr == E_UNEXPECTED, "IDirectMusicSynthSink_GetDesiredBufferSize returned: %#lx\n", hr);
params.dwValidParams = 0;
hr = IDirectMusicSynth_Open(dmsynth, &params);
ok(hr == S_OK, "Open failed: %#lx\n", hr);
hr = IDirectMusicSynthSink_GetDesiredBufferSize(dmsynth_sink, &size);
ok(hr == S_OK, "IDirectMusicSynthSink_GetDesiredBufferSize returned: %#lx\n", hr);
ok(size == params.dwSampleRate * params.dwAudioChannels * 4, "size: %ld\n", size);
IDirectMusicSynth_Close(dmsynth);
params.dwValidParams = DMUS_PORTPARAMS_AUDIOCHANNELS;
params.dwAudioChannels = 1;
hr = IDirectMusicSynth_Open(dmsynth, &params);
ok(hr == S_OK, "Open failed: %#lx\n", hr);
hr = IDirectMusicSynthSink_GetDesiredBufferSize(dmsynth_sink, &size);
ok(hr == S_OK, "IDirectMusicSynthSink_GetDesiredBufferSize returned: %#lx\n", hr);
ok(size == params.dwSampleRate * params.dwAudioChannels * 4, "size: %ld\n", size);
IDirectMusicSynth_Close(dmsynth);
if (control_synth)
IDirectMusicSynth_Release(control_synth);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment