Commit 0ce9eb7b authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

dmsynth: Create default clock for SynthSink object and assign it to Synth object…

dmsynth: Create default clock for SynthSink object and assign it to Synth object when callink SetSynthSink.
parent 491d0e9d
...@@ -76,6 +76,7 @@ struct IDirectMusicSynthSinkImpl { ...@@ -76,6 +76,7 @@ struct IDirectMusicSynthSinkImpl {
LONG ref; LONG ref;
/* IDirectMusicSynthSinkImpl fields */ /* IDirectMusicSynthSinkImpl fields */
IReferenceClock* latency_clock;
}; };
/********************************************************************** /**********************************************************************
......
...@@ -64,6 +64,8 @@ static ULONG WINAPI IDirectMusicSynth8Impl_Release(LPDIRECTMUSICSYNTH8 iface) ...@@ -64,6 +64,8 @@ static ULONG WINAPI IDirectMusicSynth8Impl_Release(LPDIRECTMUSICSYNTH8 iface)
TRACE("(%p)->(ref before=%u)\n", This, refCount + 1); TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
if (!refCount) { if (!refCount) {
if (This->pLatencyClock)
IReferenceClock_Release(This->pLatencyClock);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
...@@ -160,9 +162,16 @@ static HRESULT WINAPI IDirectMusicSynth8Impl_GetLatencyClock(LPDIRECTMUSICSYNTH8 ...@@ -160,9 +162,16 @@ static HRESULT WINAPI IDirectMusicSynth8Impl_GetLatencyClock(LPDIRECTMUSICSYNTH8
{ {
IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface); IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
TRACE("(%p)->(%p)\n", This, clock); TRACE("(%p)->(%p)\n", iface, clock);
if (!clock)
return E_POINTER;
if (!This->pSynthSink)
return DMUS_E_NOSYNTHSINK;
*clock = This->pLatencyClock; *clock = This->pLatencyClock;
IReferenceClock_AddRef(This->pLatencyClock);
return S_OK; return S_OK;
} }
...@@ -182,10 +191,13 @@ static HRESULT WINAPI IDirectMusicSynth8Impl_SetSynthSink(LPDIRECTMUSICSYNTH8 if ...@@ -182,10 +191,13 @@ static HRESULT WINAPI IDirectMusicSynth8Impl_SetSynthSink(LPDIRECTMUSICSYNTH8 if
{ {
IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface); IDirectMusicSynth8Impl *This = impl_from_IDirectMusicSynth8(iface);
TRACE("(%p)->(%p)\n", This, synth_sink); TRACE("(%p)->(%p)\n", iface, synth_sink);
This->pSynthSink = (IDirectMusicSynthSinkImpl*)synth_sink; This->pSynthSink = (IDirectMusicSynthSinkImpl*)synth_sink;
if (synth_sink)
return IDirectMusicSynthSink_GetLatencyClock(synth_sink, &This->pLatencyClock);
return S_OK; return S_OK;
} }
...@@ -337,8 +349,6 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicSynthImpl (LPCGUID lpcGUID, LPVOID* ppobj ...@@ -337,8 +349,6 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicSynthImpl (LPCGUID lpcGUID, LPVOID* ppobj
obj->pCaps.dwMaxAudioChannels = 2; obj->pCaps.dwMaxAudioChannels = 2;
obj->pCaps.dwEffectFlags = DMUS_EFFECT_REVERB; obj->pCaps.dwEffectFlags = DMUS_EFFECT_REVERB;
MultiByteToWideChar (CP_ACP, 0, "Microsoft Synthesizer", -1, obj->pCaps.wszDescription, sizeof(obj->pCaps.wszDescription)/sizeof(WCHAR)); MultiByteToWideChar (CP_ACP, 0, "Microsoft Synthesizer", -1, obj->pCaps.wszDescription, sizeof(obj->pCaps.wszDescription)/sizeof(WCHAR));
/* assign latency clock */
/*DMUSIC_CreateReferenceClockImpl (&IID_IReferenceClock, (LPVOID*)&This->pLatencyClock, NULL); */
return IDirectMusicSynth8Impl_QueryInterface ((LPDIRECTMUSICSYNTH8)obj, lpcGUID, ppobj); return IDirectMusicSynth8Impl_QueryInterface ((LPDIRECTMUSICSYNTH8)obj, lpcGUID, ppobj);
} }
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
*/ */
#include "dmsynth_private.h" #include "dmsynth_private.h"
#include "initguid.h"
#include "uuids.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmsynth); WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
...@@ -63,6 +65,8 @@ static ULONG WINAPI IDirectMusicSynthSinkImpl_Release(LPDIRECTMUSICSYNTHSINK ifa ...@@ -63,6 +65,8 @@ static ULONG WINAPI IDirectMusicSynthSinkImpl_Release(LPDIRECTMUSICSYNTHSINK ifa
TRACE("(%p)->(ref before=%u)\n", This, refCount + 1); TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
if (!refCount) { if (!refCount) {
if (This->latency_clock)
IReferenceClock_Release(This->latency_clock);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
...@@ -94,7 +98,13 @@ static HRESULT WINAPI IDirectMusicSynthSinkImpl_GetLatencyClock(LPDIRECTMUSICSYN ...@@ -94,7 +98,13 @@ static HRESULT WINAPI IDirectMusicSynthSinkImpl_GetLatencyClock(LPDIRECTMUSICSYN
{ {
IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface); IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
FIXME("(%p)->(%p): stub\n", This, clock); TRACE("(%p)->(%p)\n", iface, clock);
if (!clock)
return E_POINTER;
*clock = This->latency_clock;
IReferenceClock_AddRef(This->latency_clock);
return S_OK; return S_OK;
} }
...@@ -159,17 +169,36 @@ static const IDirectMusicSynthSinkVtbl DirectMusicSynthSink_Vtbl = { ...@@ -159,17 +169,36 @@ static const IDirectMusicSynthSinkVtbl DirectMusicSynthSink_Vtbl = {
}; };
/* for ClassFactory */ /* for ClassFactory */
HRESULT WINAPI DMUSIC_CreateDirectMusicSynthSinkImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) { HRESULT WINAPI DMUSIC_CreateDirectMusicSynthSinkImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter)
{
IDirectMusicSynthSinkImpl *obj; IDirectMusicSynthSinkImpl *obj;
HRESULT hr;
TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter);
*ret_iface = NULL;
TRACE("(%p,%p,%p)\n", lpcGUID, ppobj, pUnkOuter);
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynthSinkImpl)); obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynthSinkImpl));
if (NULL == obj) { if (!obj)
*ppobj = NULL;
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
}
obj->IDirectMusicSynthSink_iface.lpVtbl = &DirectMusicSynthSink_Vtbl; obj->IDirectMusicSynthSink_iface.lpVtbl = &DirectMusicSynthSink_Vtbl;
obj->ref = 0; obj->ref = 0;
return IDirectMusicSynthSinkImpl_QueryInterface((LPDIRECTMUSICSYNTHSINK)obj, lpcGUID, ppobj); hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (LPVOID*)&obj->latency_clock);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, obj);
return hr;
}
hr = IDirectMusicSynthSinkImpl_QueryInterface((LPDIRECTMUSICSYNTHSINK)obj, riid, ret_iface);
if (FAILED(hr))
{
IReferenceClock_Release(obj->latency_clock);
HeapFree(GetProcessHeap(), 0, obj);
return hr;
}
return S_OK;
} }
...@@ -33,7 +33,7 @@ static void test_dmsynth(void) ...@@ -33,7 +33,7 @@ static void test_dmsynth(void)
{ {
IDirectMusicSynth *dmsynth = NULL; IDirectMusicSynth *dmsynth = NULL;
IDirectMusicSynthSink *dmsynth_sink = NULL; IDirectMusicSynthSink *dmsynth_sink = NULL;
IReferenceClock* clock = NULL; IReferenceClock* clock_synth = NULL;
IReferenceClock* clock_sink = NULL; IReferenceClock* clock_sink = NULL;
HRESULT hr; HRESULT hr;
...@@ -48,24 +48,28 @@ static void test_dmsynth(void) ...@@ -48,24 +48,28 @@ static void test_dmsynth(void)
ok(hr == S_OK, "CoCreateInstance returned: %x\n", hr); ok(hr == S_OK, "CoCreateInstance returned: %x\n", hr);
/* Synth has no default clock */ /* Synth has no default clock */
hr = IDirectMusicSynth_GetLatencyClock(dmsynth, &clock); hr = IDirectMusicSynth_GetLatencyClock(dmsynth, &clock_synth);
todo_wine ok(hr == DMUS_E_NOSYNTHSINK, "IDirectMusicSynth_GetLatencyClock returned: %x\n", hr); ok(hr == DMUS_E_NOSYNTHSINK, "IDirectMusicSynth_GetLatencyClock returned: %x\n", hr);
/* SynthSink has a default clock */ /* SynthSink has a default clock */
hr = IDirectMusicSynthSink_GetLatencyClock(dmsynth_sink, &clock_sink); hr = IDirectMusicSynthSink_GetLatencyClock(dmsynth_sink, &clock_sink);
ok(hr == S_OK, "IDirectMusicSynth_GetLatencyClock returned: %x\n", hr); ok(hr == S_OK, "IDirectMusicSynth_GetLatencyClock returned: %x\n", hr);
todo_wine ok(clock_sink != NULL, "No clock returned\n"); ok(clock_sink != NULL, "No clock returned\n");
/* This will set clock to Synth */ /* This will set clock to Synth */
hr = IDirectMusicSynth_SetSynthSink(dmsynth, dmsynth_sink); hr = IDirectMusicSynth_SetSynthSink(dmsynth, dmsynth_sink);
ok(hr == S_OK, "IDirectMusicSynth_SetSynthSink returned: %x\n", hr); ok(hr == S_OK, "IDirectMusicSynth_SetSynthSink returned: %x\n", hr);
/* Check clocks are the same */ /* Check clocks are the same */
hr = IDirectMusicSynth_GetLatencyClock(dmsynth, &clock); hr = IDirectMusicSynth_GetLatencyClock(dmsynth, &clock_synth);
ok(hr == S_OK, "IDirectMusicSynth_GetLatencyClock returned: %x\n", hr); ok(hr == S_OK, "IDirectMusicSynth_GetLatencyClock returned: %x\n", hr);
todo_wine ok(clock != NULL, "No clock returned\n"); ok(clock_synth != NULL, "No clock returned\n");
ok(clock == clock_sink, "Synth and SynthSink clocks are not the same\n"); ok(clock_synth == clock_sink, "Synth and SynthSink clocks are not the same\n");
if (clock_synth)
IReferenceClock_Release(clock_synth);
if (clock_sink)
IReferenceClock_Release(clock_sink);
if (dmsynth_sink) if (dmsynth_sink)
IDirectMusicSynthSink_Release(dmsynth_sink); IDirectMusicSynthSink_Release(dmsynth_sink);
IDirectMusicSynth_Release(dmsynth); IDirectMusicSynth_Release(dmsynth);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment