Michael Stefaniuc : dmusic: Forward GetFormat() to the corresponding synth & sink methods.

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


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

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

dmusic: Forward GetFormat() to the corresponding synth & sink methods.

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

---

 dlls/dmusic/port.c         | 59 ++++++++++++----------------------------------
 dlls/dmusic/tests/dmusic.c | 21 +++++++++++++++++
 2 files changed, 36 insertions(+), 44 deletions(-)

diff --git a/dlls/dmusic/port.c b/dlls/dmusic/port.c
index d593d739a9e..8549c62c4b1 100644
--- a/dlls/dmusic/port.c
+++ b/dlls/dmusic/port.c
@@ -510,50 +510,21 @@ static HRESULT WINAPI synth_port_SetDirectSound(IDirectMusicPort *iface, IDirect
     return S_OK;
 }
 
-static HRESULT WINAPI synth_port_GetFormat(IDirectMusicPort *iface, WAVEFORMATEX *pWaveFormatEx,
-        DWORD *pdwWaveFormatExSize, DWORD *pdwBufferSize)
-{
-	struct synth_port *This = synth_from_IDirectMusicPort(iface);
-	WAVEFORMATEX format;
-	FIXME("(%p, %p, %p, %p): stub\n", This, pWaveFormatEx, pdwWaveFormatExSize, pdwBufferSize);
-
-	if (pWaveFormatEx == NULL)
-	{
-		if (pdwWaveFormatExSize)
-			*pdwWaveFormatExSize = sizeof(format);
-		else
-			return E_POINTER;
-	}
-	else
-	{
-		if (pdwWaveFormatExSize == NULL)
-			return E_POINTER;
-
-		/* Just fill this in with something that will not crash Direct Sound for now. */
-		/* It won't be used anyway until Performances are completed */
-		format.wFormatTag = WAVE_FORMAT_PCM;
-		format.nChannels = 2; /* This->params.dwAudioChannels; */
-		format.nSamplesPerSec = 44100; /* This->params.dwSampleRate; */
-		format.wBitsPerSample = 16;	/* FIXME: check this */
-		format.nBlockAlign = (format.wBitsPerSample * format.nChannels) / 8;
-		format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
-		format.cbSize = 0;
-
-		if (*pdwWaveFormatExSize >= sizeof(format))
-		{
-			CopyMemory(pWaveFormatEx, &format, min(sizeof(format), *pdwWaveFormatExSize));
-			*pdwWaveFormatExSize = sizeof(format);	/* FIXME check if this is set */
-		}
-		else
-			return E_POINTER;	/* FIXME find right error */
-	}
-
-	if (pdwBufferSize)
-		*pdwBufferSize = 44100 * 2 * 2;
-	else
-		return E_POINTER;
-
-	return S_OK;
+static HRESULT WINAPI synth_port_GetFormat(IDirectMusicPort *iface, WAVEFORMATEX *format,
+        DWORD *fmtsize, DWORD *bufsize)
+{
+    struct synth_port *This = synth_from_IDirectMusicPort(iface);
+    HRESULT hr;
+
+    TRACE("(%p, %p, %p, %p)\n", This, format, fmtsize, bufsize);
+
+    if (FAILED(hr = IDirectMusicSynth_GetFormat(This->synth, format, fmtsize)))
+        return hr;
+
+    if (bufsize)
+        hr = IDirectMusicSynthSink_GetDesiredBufferSize(This->synth_sink, bufsize);
+
+    return hr;
 }
 
 static const IDirectMusicPortVtbl synth_port_vtbl = {
diff --git a/dlls/dmusic/tests/dmusic.c b/dlls/dmusic/tests/dmusic.c
index d8fc6affd9b..37b517fe0ca 100644
--- a/dlls/dmusic/tests/dmusic.c
+++ b/dlls/dmusic/tests/dmusic.c
@@ -877,6 +877,9 @@ static void test_synthport(void)
     IDirectMusicPort *port;
     DMUS_BUFFERDESC desc;
     DMUS_PORTCAPS caps;
+    WAVEFORMATEX fmt;
+    DWORD fmtsize, bufsize;
+
     HRESULT hr;
 
     port = create_synth_port(&dmusic);
@@ -922,6 +925,24 @@ static void test_synthport(void)
     ok(caps.dwEffectFlags == DMUS_EFFECT_REVERB, "Unexpected dwEffectFlags returned: %#lx\n", caps.dwEffectFlags);
     trace("Port wszDescription: %s\n", wine_dbgstr_w(caps.wszDescription));
 
+    /* GetFormat */
+    hr = IDirectMusicPort_GetFormat(port, NULL, NULL, NULL);
+    ok(hr == E_POINTER, "GetFormat failed: %#lx\n", hr);
+    hr = IDirectMusicPort_GetFormat(port, NULL, &fmtsize, NULL);
+    ok(hr == S_OK, "GetFormat failed: %#lx\n", hr);
+    ok(fmtsize == sizeof(fmt), "format size; %ld\n", fmtsize);
+    fmtsize = 0;
+    hr = IDirectMusicPort_GetFormat(port, &fmt, &fmtsize, NULL);
+    ok(hr == S_OK, "GetFormat failed: %#lx\n", hr);
+    ok(fmtsize == sizeof(fmt), "format size; %ld\n", fmtsize);
+    hr = IDirectMusicPort_GetFormat(port, NULL, NULL, &bufsize);
+    ok(hr == E_POINTER, "GetFormat failed: %#lx\n", hr);
+    hr = IDirectMusicPort_GetFormat(port, NULL, &fmtsize, &bufsize);
+    ok(hr == S_OK, "GetFormat failed: %#lx\n", hr);
+    hr = IDirectMusicPort_GetFormat(port, &fmt, &fmtsize, &bufsize);
+    ok(hr == S_OK, "GetFormat failed: %#lx\n", hr);
+    ok(bufsize == fmt.nSamplesPerSec * fmt.nChannels * 4, "buffer size: %ld\n", bufsize);
+
     IDirectMusicPort_Release(port);
     IDirectMusic_Release(dmusic);
 }




More information about the wine-cvs mailing list