dmsynth: Disconnect old sink, addref and init new sink.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
00eaccda84
commit
6c73c3166b
|
@ -362,15 +362,28 @@ static HRESULT WINAPI IDirectMusicSynth8Impl_SetSynthSink(IDirectMusicSynth8 *if
|
|||
IDirectMusicSynthSink *sink)
|
||||
{
|
||||
IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p)->(%p)\n", iface, sink);
|
||||
|
||||
This->sink = sink;
|
||||
|
||||
if (sink)
|
||||
return IDirectMusicSynthSink_GetLatencyClock(sink, &This->latency_clock);
|
||||
|
||||
if (sink == This->sink)
|
||||
return S_OK;
|
||||
|
||||
if (!sink || This->sink) {
|
||||
/* Disconnect the sink */
|
||||
if (This->latency_clock)
|
||||
IReferenceClock_Release(This->latency_clock);
|
||||
IDirectMusicSynthSink_Release(This->sink);
|
||||
}
|
||||
|
||||
This->sink = sink;
|
||||
if (!sink)
|
||||
return S_OK;
|
||||
|
||||
IDirectMusicSynthSink_AddRef(This->sink);
|
||||
if (FAILED(hr = IDirectMusicSynthSink_Init(sink, (IDirectMusicSynth *)iface)))
|
||||
return hr;
|
||||
return IDirectMusicSynthSink_GetLatencyClock(sink, &This->latency_clock);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IDirectMusicSynth8Impl_Render(IDirectMusicSynth8 *iface, short *buffer,
|
||||
|
|
|
@ -54,7 +54,7 @@ static ULONG get_refcount(void *iface)
|
|||
static void test_dmsynth(void)
|
||||
{
|
||||
IDirectMusicSynth *dmsynth = NULL;
|
||||
IDirectMusicSynthSink *dmsynth_sink = NULL;
|
||||
IDirectMusicSynthSink *dmsynth_sink = NULL, *dmsynth_sink2 = NULL;
|
||||
IReferenceClock* clock_synth = NULL;
|
||||
IReferenceClock* clock_sink = NULL;
|
||||
IKsControl* control_synth = NULL;
|
||||
|
@ -68,7 +68,11 @@ static void test_dmsynth(void)
|
|||
hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth, (LPVOID*)&dmsynth);
|
||||
ok(hr == S_OK, "CoCreateInstance returned: %x\n", hr);
|
||||
|
||||
hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynthSink, (LPVOID*)&dmsynth_sink);
|
||||
hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynthSink,
|
||||
(void **)&dmsynth_sink);
|
||||
ok(hr == S_OK, "CoCreateInstance returned: %x\n", hr);
|
||||
hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynthSink,
|
||||
(void **)&dmsynth_sink2);
|
||||
ok(hr == S_OK, "CoCreateInstance returned: %x\n", hr);
|
||||
|
||||
hr = IDirectMusicSynth_QueryInterface(dmsynth, &IID_IKsControl, (LPVOID*)&control_synth);
|
||||
|
@ -127,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 = IDirectMusicSynth_SetSynthSink(dmsynth, dmsynth_sink2);
|
||||
ok(hr == S_OK, "IDirectMusicSynth_SetSynthSink returned: %x\n", hr);
|
||||
hr = IDirectMusicSynth_SetSynthSink(dmsynth, dmsynth_sink);
|
||||
ok(hr == S_OK, "IDirectMusicSynth_SetSynthSink returned: %x\n", hr);
|
||||
|
||||
|
@ -148,6 +154,8 @@ static void test_dmsynth(void)
|
|||
IReferenceClock_Release(clock_sink);
|
||||
if (dmsynth_sink)
|
||||
IDirectMusicSynthSink_Release(dmsynth_sink);
|
||||
if (dmsynth_sink2)
|
||||
IDirectMusicSynthSink_Release(dmsynth_sink2);
|
||||
IDirectMusicSynth_Release(dmsynth);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue