[PATCH 2/4] dmsynth: Activate the sink from the synth Activate() method

Michael Stefaniuc mstefani at winehq.org
Wed Jan 19 11:48:48 CST 2022


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 dlls/dmsynth/dmsynth_private.h |  2 +-
 dlls/dmsynth/synth.c           | 20 +++++++++++++++++++-
 dlls/dmsynth/tests/dmsynth.c   |  2 +-
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/dlls/dmsynth/dmsynth_private.h b/dlls/dmsynth/dmsynth_private.h
index 32a79f65dd3..9ad06dff5dd 100644
--- a/dlls/dmsynth/dmsynth_private.h
+++ b/dlls/dmsynth/dmsynth_private.h
@@ -63,7 +63,7 @@ struct IDirectMusicSynth8Impl {
 
     /* IDirectMusicSynth8 fields */
     DMUS_PORTCAPS pCaps;
-    BOOL fActive;
+    BOOL active;
     IReferenceClock* pLatencyClock;
     IDirectMusicSynthSink *sink;
 };
diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c
index 4d71bc738c1..bd1ee201165 100644
--- a/dlls/dmsynth/synth.c
+++ b/dlls/dmsynth/synth.c
@@ -332,10 +332,28 @@ static HRESULT WINAPI IDirectMusicSynth8Impl_GetLatencyClock(IDirectMusicSynth8
 static HRESULT WINAPI IDirectMusicSynth8Impl_Activate(IDirectMusicSynth8 *iface, BOOL enable)
 {
     IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
+    HRESULT hr;
 
     TRACE("(%p)->(%d)\n", This, enable);
 
-    This->fActive = enable;
+    if (!This->sink)
+        return DMUS_E_NOSYNTHSINK;
+
+    if (enable == This->active) {
+        if (enable)
+            return DMUS_E_SYNTHACTIVE;
+        else
+            return S_FALSE;
+    }
+
+    if ((hr = IDirectMusicSynthSink_Activate(This->sink, enable)) != S_OK) {
+        if (hr == DMUS_E_SYNTHACTIVE || hr == S_FALSE)
+            WARN("Synth and sink active state out of sync. Fixing.\n");
+        else
+            return hr;
+    }
+
+    This->active = enable;
 
     return S_OK;
 }
diff --git a/dlls/dmsynth/tests/dmsynth.c b/dlls/dmsynth/tests/dmsynth.c
index 3970933cb6f..bb42553469b 100644
--- a/dlls/dmsynth/tests/dmsynth.c
+++ b/dlls/dmsynth/tests/dmsynth.c
@@ -114,7 +114,7 @@ static void test_dmsynth(void)
 
     /* Synth isn't fully initialized yet */
     hr = IDirectMusicSynth_Activate(dmsynth, TRUE);
-    todo_wine ok(hr == DMUS_E_NOSYNTHSINK, "IDirectMusicSynth_Activate returned: %x\n", hr);
+    ok(hr == DMUS_E_NOSYNTHSINK, "IDirectMusicSynth_Activate returned: %x\n", hr);
 
     /* Synth has no default clock */
     hr = IDirectMusicSynth_GetLatencyClock(dmsynth, &clock_synth);
-- 
2.31.1




More information about the wine-devel mailing list