Michael Stefaniuc : dmsynth: Implement the sink GetDesiredBufferSize method.

Alexandre Julliard julliard at winehq.org
Tue Feb 22 16:06:49 CST 2022


Module: wine
Branch: master
Commit: ec69d69f2a24b887f97abc4ff6af1ae7582b5ef2
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ec69d69f2a24b887f97abc4ff6af1ae7582b5ef2

Author: Michael Stefaniuc <mstefani at winehq.org>
Date:   Tue Feb 22 00:49:58 2022 +0100

dmsynth: Implement the sink GetDesiredBufferSize method.

Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dmsynth/synthsink.c     | 15 +++++++++++++--
 dlls/dmsynth/tests/dmsynth.c | 24 ++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/dlls/dmsynth/synthsink.c b/dlls/dmsynth/synthsink.c
index fe578086a23..d34bcf9df5e 100644
--- a/dlls/dmsynth/synthsink.c
+++ b/dlls/dmsynth/synthsink.c
@@ -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;
 }
diff --git a/dlls/dmsynth/tests/dmsynth.c b/dlls/dmsynth/tests/dmsynth.c
index ab3349f666b..a8bf65cd73e 100644
--- a/dlls/dmsynth/tests/dmsynth.c
+++ b/dlls/dmsynth/tests/dmsynth.c
@@ -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);




More information about the wine-cvs mailing list