[PATCH] dmsynth: Implement the sink Init method

Michael Stefaniuc mstefani at winehq.org
Mon Jan 24 17:25:06 CST 2022


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 dlls/dmsynth/dmsynth_private.h | 1 +
 dlls/dmsynth/synthsink.c       | 6 +++++-
 dlls/dmsynth/tests/dmsynth.c   | 2 ++
 dlls/dmusic/port.c             | 2 +-
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/dlls/dmsynth/dmsynth_private.h b/dlls/dmsynth/dmsynth_private.h
index 2a2e88c8e88..aabf1f56904 100644
--- a/dlls/dmsynth/dmsynth_private.h
+++ b/dlls/dmsynth/dmsynth_private.h
@@ -77,6 +77,7 @@ struct IDirectMusicSynthSinkImpl {
     LONG ref;
     IReferenceClock *latency_clock;
     IReferenceClock *master_clock;
+    IDirectMusicSynth *synth;   /* No reference hold! */
     BOOL active;
 };
 
diff --git a/dlls/dmsynth/synthsink.c b/dlls/dmsynth/synthsink.c
index 72fd671a415..9d7096a032b 100644
--- a/dlls/dmsynth/synthsink.c
+++ b/dlls/dmsynth/synthsink.c
@@ -96,7 +96,11 @@ static HRESULT WINAPI IDirectMusicSynthSinkImpl_Init(IDirectMusicSynthSink *ifac
 {
     IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
 
-    FIXME("(%p)->(%p): stub\n", This, synth);
+    TRACE("(%p)->(%p)\n", This, synth);
+
+    /* Not holding a reference to avoid circular dependencies.
+       The synth will release the sink during the synth's destruction. */
+    This->synth = synth;
 
     return S_OK;
 }
diff --git a/dlls/dmsynth/tests/dmsynth.c b/dlls/dmsynth/tests/dmsynth.c
index 1e3e20829b7..e27d8abdb26 100644
--- a/dlls/dmsynth/tests/dmsynth.c
+++ b/dlls/dmsynth/tests/dmsynth.c
@@ -131,6 +131,8 @@ static void test_dmsynth(void)
     ref_clock_sink = get_refcount(clock_sink);
 
     /* This will Init() the SynthSink and finish initializing the Synth */
+    hr = IDirectMusicSynthSink_Init(dmsynth_sink2, NULL);
+    ok(hr == S_OK, "IDirectMusicSynthSink_Init returned: %x\n", hr);
     hr = IDirectMusicSynth_SetSynthSink(dmsynth, dmsynth_sink2);
     ok(hr == S_OK, "IDirectMusicSynth_SetSynthSink returned: %x\n", hr);
     hr = IDirectMusicSynth_SetSynthSink(dmsynth, dmsynth_sink);
diff --git a/dlls/dmusic/port.c b/dlls/dmusic/port.c
index 31b3b764e02..7fe72563bb0 100644
--- a/dlls/dmusic/port.c
+++ b/dlls/dmusic/port.c
@@ -195,10 +195,10 @@ static ULONG WINAPI synth_port_Release(IDirectMusicPort *iface)
     if (!ref)
     {
         dmusic_remove_port(This->parent, iface);
+        IDirectMusicSynthSink_Release(This->synth_sink);
         IDirectMusicSynth_Activate(This->synth, FALSE);
         IDirectMusicSynth_Close(This->synth);
         IDirectMusicSynth_Release(This->synth);
-        IDirectMusicSynthSink_Release(This->synth_sink);
         if (This->dsbuffer)
            IDirectSoundBuffer_Release(This->dsbuffer);
         if (This->dsound)
-- 
2.34.1




More information about the wine-devel mailing list