-- v4: dmsynth: Return DMUS_E_SYNTHNOTCONFIGURED when sink fails to activate. dmsynth: Return S_FALSE if IDirectMusicSynth_Activate is no-op. dmsynth: Forward IDirectMusicSynth_GetLatencyClock to the sink. dmsynth: Implement latency IReferenceClock interface on the sink. include: Use IReferenceClock interface from strmif.idl in dmusicc.h. dmsynth: Move constructor parameter checks to class factory.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmsynth/dmsynth_main.c | 28 +++++++++++++++++----------- dlls/dmsynth/dmsynth_private.h | 4 ++-- dlls/dmsynth/synth.c | 16 +++++++--------- dlls/dmsynth/synthsink.c | 14 ++++++-------- 4 files changed, 32 insertions(+), 30 deletions(-)
diff --git a/dlls/dmsynth/dmsynth_main.c b/dlls/dmsynth/dmsynth_main.c index edeaab8474e..84caeceb472 100644 --- a/dlls/dmsynth/dmsynth_main.c +++ b/dlls/dmsynth/dmsynth_main.c @@ -27,7 +27,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
typedef struct { IClassFactory IClassFactory_iface; - HRESULT (*fnCreateInstance)(REFIID riid, void **ppv); + HRESULT (*create_instance)(IUnknown **ret_iface); } IClassFactoryImpl;
/****************************************************************** @@ -68,17 +68,24 @@ static ULONG WINAPI ClassFactory_Release(IClassFactory *iface) return 1; /* non-heap based object */ }
-static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter, - REFIID riid, void **ppv) +static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *unk_outer, + REFIID riid, void **ret_iface) { - IClassFactoryImpl *This = impl_from_IClassFactory(iface); + IClassFactoryImpl *This = impl_from_IClassFactory(iface); + IUnknown *object; + HRESULT hr;
- TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv); + TRACE("(%p, %s, %p)\n", unk_outer, debugstr_dmguid(riid), ret_iface);
- if (pUnkOuter) - return CLASS_E_NOAGGREGATION; + *ret_iface = NULL; + if (unk_outer) return CLASS_E_NOAGGREGATION; + if (SUCCEEDED(hr = This->create_instance(&object))) + { + hr = IUnknown_QueryInterface(object, riid, ret_iface); + IUnknown_Release(object); + }
- return This->fnCreateInstance(riid, ppv); + return hr; }
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock) @@ -95,9 +102,8 @@ static const IClassFactoryVtbl classfactory_vtbl = { ClassFactory_LockServer };
-static IClassFactoryImpl Synth_CF = {{&classfactory_vtbl}, DMUSIC_CreateDirectMusicSynthImpl}; -static IClassFactoryImpl SynthSink_CF = {{&classfactory_vtbl}, - DMUSIC_CreateDirectMusicSynthSinkImpl}; +static IClassFactoryImpl Synth_CF = {{&classfactory_vtbl}, synth_create}; +static IClassFactoryImpl SynthSink_CF = {{&classfactory_vtbl}, synth_sink_create};
/****************************************************************** diff --git a/dlls/dmsynth/dmsynth_private.h b/dlls/dmsynth/dmsynth_private.h index 35c87775cf7..529b46ca978 100644 --- a/dlls/dmsynth/dmsynth_private.h +++ b/dlls/dmsynth/dmsynth_private.h @@ -43,8 +43,8 @@ /***************************************************************************** * ClassFactory */ -extern HRESULT DMUSIC_CreateDirectMusicSynthImpl(REFIID riid, void **ppobj); -extern HRESULT DMUSIC_CreateDirectMusicSynthSinkImpl(REFIID riid, void **ppobj); +extern HRESULT synth_create(IUnknown **ret_iface); +extern HRESULT synth_sink_create(IUnknown **ret_iface);
/***************************************************************************** * Misc. diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index 00883505377..e07e47490bd 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -737,19 +737,18 @@ static const IKsControlVtbl synth_control_vtbl = synth_control_KsEvent, };
-HRESULT DMUSIC_CreateDirectMusicSynthImpl(REFIID riid, void **ppobj) +HRESULT synth_create(IUnknown **ret_iface) { struct synth *obj; - HRESULT hr;
- TRACE("(%s, %p)\n", debugstr_guid(riid), ppobj); + TRACE("(%p)\n", ret_iface);
- *ppobj = NULL; + *ret_iface = NULL; if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY; obj->IDirectMusicSynth8_iface.lpVtbl = &synth_vtbl; obj->IKsControl_iface.lpVtbl = &synth_control_vtbl; obj->ref = 1; - /* fill in caps */ + obj->caps.dwSize = sizeof(DMUS_PORTCAPS); obj->caps.dwFlags = DMUS_PC_DLS | DMUS_PC_SOFTWARESYNTH | DMUS_PC_DIRECTSOUND | DMUS_PC_DLS2 | DMUS_PC_AUDIOPATH | DMUS_PC_WAVE; obj->caps.guidPort = CLSID_DirectMusicSynth; @@ -762,8 +761,7 @@ HRESULT DMUSIC_CreateDirectMusicSynthImpl(REFIID riid, void **ppobj) obj->caps.dwEffectFlags = DMUS_EFFECT_REVERB; lstrcpyW(obj->caps.wszDescription, L"Microsoft Synthesizer");
- hr = IDirectMusicSynth8_QueryInterface(&obj->IDirectMusicSynth8_iface, riid, ppobj); - IDirectMusicSynth8_Release(&obj->IDirectMusicSynth8_iface); - - return hr; + TRACE("Created DirectMusicSynth %p\n", obj); + *ret_iface = (IUnknown *)&obj->IDirectMusicSynth8_iface; + return S_OK; } diff --git a/dlls/dmsynth/synthsink.c b/dlls/dmsynth/synthsink.c index e86763cccd0..6a2a7269092 100644 --- a/dlls/dmsynth/synthsink.c +++ b/dlls/dmsynth/synthsink.c @@ -371,29 +371,27 @@ static const IKsControlVtbl synth_sink_control = synth_sink_control_KsEvent, };
-HRESULT DMUSIC_CreateDirectMusicSynthSinkImpl(REFIID riid, void **ret_iface) +HRESULT synth_sink_create(IUnknown **ret_iface) { struct synth_sink *obj; HRESULT hr;
- TRACE("(%s, %p)\n", debugstr_guid(riid), ret_iface); + TRACE("(%p)\n", ret_iface);
*ret_iface = NULL; - if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY; obj->IDirectMusicSynthSink_iface.lpVtbl = &synth_sink_vtbl; obj->IKsControl_iface.lpVtbl = &synth_sink_control; obj->ref = 1;
- hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (LPVOID*)&obj->latency_clock); + hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (void **)&obj->latency_clock); if (FAILED(hr)) { free(obj); return hr; }
- hr = IDirectMusicSynthSink_QueryInterface(&obj->IDirectMusicSynthSink_iface, riid, ret_iface); - IDirectMusicSynthSink_Release(&obj->IDirectMusicSynthSink_iface); - - return hr; + TRACE("Created DirectMusicSynthSink %p\n", obj); + *ret_iface = (IUnknown *)&obj->IDirectMusicSynthSink_iface; + return S_OK; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmsynth/tests/dmsynth.c | 6 ++--- dlls/dmusic/clock.c | 20 ++++++--------- dlls/dmusic/dmusic.c | 18 ++++++-------- dlls/dmusic/tests/dmusic.c | 6 ++--- include/dmusicc.h | 48 ++++-------------------------------- 5 files changed, 27 insertions(+), 71 deletions(-)
diff --git a/dlls/dmsynth/tests/dmsynth.c b/dlls/dmsynth/tests/dmsynth.c index 6d695991cac..c7546296ed0 100644 --- a/dlls/dmsynth/tests/dmsynth.c +++ b/dlls/dmsynth/tests/dmsynth.c @@ -760,20 +760,20 @@ static HRESULT WINAPI test_sink_latency_clock_GetTime(IReferenceClock *iface, RE }
static HRESULT WINAPI test_sink_latency_clock_AdviseTime(IReferenceClock *iface, - REFERENCE_TIME base, REFERENCE_TIME offset, HANDLE event, DWORD *cookie) + REFERENCE_TIME base, REFERENCE_TIME offset, HEVENT event, DWORD_PTR *cookie) { ok(0, "unexpected %s\n", __func__); return E_NOTIMPL; }
static HRESULT WINAPI test_sink_latency_clock_AdvisePeriodic(IReferenceClock *iface, - REFERENCE_TIME start, REFERENCE_TIME period, HANDLE semaphore, DWORD *cookie) + REFERENCE_TIME start, REFERENCE_TIME period, HSEMAPHORE semaphore, DWORD_PTR *cookie) { ok(0, "unexpected %s\n", __func__); return E_NOTIMPL; }
-static HRESULT WINAPI test_sink_latency_clock_Unadvise(IReferenceClock *iface, DWORD cookie) +static HRESULT WINAPI test_sink_latency_clock_Unadvise(IReferenceClock *iface, DWORD_PTR cookie) { ok(0, "unexpected %s\n", __func__); return E_NOTIMPL; diff --git a/dlls/dmusic/clock.c b/dlls/dmusic/clock.c index 19441d3d56f..7b574dd4432 100644 --- a/dlls/dmusic/clock.c +++ b/dlls/dmusic/clock.c @@ -80,30 +80,26 @@ static HRESULT WINAPI IReferenceClockImpl_GetTime(IReferenceClock *iface, REFERE return S_OK; }
-static HRESULT WINAPI IReferenceClockImpl_AdviseTime(IReferenceClock *iface, REFERENCE_TIME baseTime, REFERENCE_TIME streamTime, HANDLE hEvent, DWORD* pdwAdviseCookie) +static HRESULT WINAPI IReferenceClockImpl_AdviseTime(IReferenceClock *iface, REFERENCE_TIME base, + REFERENCE_TIME offset, HEVENT event, DWORD_PTR *cookie) { IReferenceClockImpl *This = impl_from_IReferenceClock(iface); - - FIXME("(%p)->(0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(baseTime), wine_dbgstr_longlong(streamTime), hEvent, pdwAdviseCookie); - + FIXME("(%p)->(%I64d, %I64d, %#Ix, %p): stub\n", This, base, offset, event, cookie); return S_OK; }
-static HRESULT WINAPI IReferenceClockImpl_AdvisePeriodic(IReferenceClock *iface, REFERENCE_TIME startTime, REFERENCE_TIME periodTime, HANDLE hSemaphore, DWORD* pdwAdviseCookie) +static HRESULT WINAPI IReferenceClockImpl_AdvisePeriodic(IReferenceClock *iface, REFERENCE_TIME start, + REFERENCE_TIME period, HSEMAPHORE semaphore, DWORD_PTR *cookie) { IReferenceClockImpl *This = impl_from_IReferenceClock(iface); - - FIXME("(%p)->(0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(startTime), wine_dbgstr_longlong(periodTime), hSemaphore, pdwAdviseCookie); - + FIXME("(%p)->(%I64d, %I64d, %#Ix, %p): stub\n", This, start, period, semaphore, cookie); return S_OK; }
-static HRESULT WINAPI IReferenceClockImpl_Unadvise(IReferenceClock *iface, DWORD dwAdviseCookie) +static HRESULT WINAPI IReferenceClockImpl_Unadvise(IReferenceClock *iface, DWORD_PTR cookie) { IReferenceClockImpl *This = impl_from_IReferenceClock(iface); - - FIXME("(%p, %ld): stub\n", This, dwAdviseCookie); - + FIXME("(%p, %#Ix): stub\n", This, cookie); return S_OK; }
diff --git a/dlls/dmusic/dmusic.c b/dlls/dmusic/dmusic.c index d284b32fdd7..970fb28ebd2 100644 --- a/dlls/dmusic/dmusic.c +++ b/dlls/dmusic/dmusic.c @@ -96,25 +96,23 @@ static HRESULT WINAPI master_IReferenceClock_GetTime(IReferenceClock *iface, return hr; }
-static HRESULT WINAPI master_IReferenceClock_AdviseTime(IReferenceClock *iface, - REFERENCE_TIME base, REFERENCE_TIME offset, HANDLE event, DWORD *cookie) +static HRESULT WINAPI master_IReferenceClock_AdviseTime(IReferenceClock *iface, REFERENCE_TIME base, + REFERENCE_TIME offset, HEVENT event, DWORD_PTR *cookie) { - TRACE("(%p, %s, %s, %p, %p): method not implemented\n", iface, wine_dbgstr_longlong(base), - wine_dbgstr_longlong(offset), event, cookie); + FIXME("(%p, %I64d, %I64d, %#Ix, %p): stub\n", iface, base, offset, event, cookie); return E_NOTIMPL; }
-static HRESULT WINAPI master_IReferenceClock_AdvisePeriodic(IReferenceClock *iface, - REFERENCE_TIME start, REFERENCE_TIME period, HANDLE semaphore, DWORD *cookie) +static HRESULT WINAPI master_IReferenceClock_AdvisePeriodic(IReferenceClock *iface, REFERENCE_TIME start, + REFERENCE_TIME period, HSEMAPHORE semaphore, DWORD_PTR *cookie) { - TRACE("(%p, %s, %s, %p, %p): method not implemented\n", iface, wine_dbgstr_longlong(start), - wine_dbgstr_longlong(period), semaphore, cookie); + FIXME("(%p, %I64d, %I64d, %#Ix, %p): stub\n", iface, start, period, semaphore, cookie); return E_NOTIMPL; }
-static HRESULT WINAPI master_IReferenceClock_Unadvise(IReferenceClock *iface, DWORD cookie) +static HRESULT WINAPI master_IReferenceClock_Unadvise(IReferenceClock *iface, DWORD_PTR cookie) { - TRACE("(%p, %#lx): method not implemented\n", iface, cookie); + FIXME("(%p, %#Ix): stub\n", iface, cookie); return E_NOTIMPL; }
diff --git a/dlls/dmusic/tests/dmusic.c b/dlls/dmusic/tests/dmusic.c index a8152822613..1561c51df76 100644 --- a/dlls/dmusic/tests/dmusic.c +++ b/dlls/dmusic/tests/dmusic.c @@ -862,7 +862,7 @@ static void test_master_clock(void) LARGE_INTEGER counter, freq; DMUS_CLOCKINFO clock_info; IDirectMusic *dmusic; - DWORD cookie; + DWORD_PTR cookie; HRESULT hr; ULONG ref; GUID guid; @@ -912,10 +912,10 @@ static void test_master_clock(void) ok(time2 - time1 > 80 * 10000, "Expected about %s, but got %s.\n", wine_dbgstr_longlong(time1 + 100 * 10000), wine_dbgstr_longlong(time2));
- hr = IReferenceClock_AdviseTime(clock, 0, 0, NULL, &cookie); + hr = IReferenceClock_AdviseTime(clock, 0, 0, 0, &cookie); ok(hr == E_NOTIMPL, "Got hr %#lx.\n", hr);
- hr = IReferenceClock_AdvisePeriodic(clock, 0, 0, NULL, &cookie); + hr = IReferenceClock_AdvisePeriodic(clock, 0, 0, 0, &cookie); ok(hr == E_NOTIMPL, "Got hr %#lx.\n", hr);
hr = IReferenceClock_Unadvise(clock, 0); diff --git a/include/dmusicc.h b/include/dmusicc.h index 94ff184dc9f..351f2733ee2 100644 --- a/include/dmusicc.h +++ b/include/dmusicc.h @@ -31,6 +31,7 @@ #include <dmdls.h> #include <dsound.h> #include <dmusbuff.h> +#include <strmif.h>
#include <pshpack8.h>
@@ -108,8 +109,6 @@ typedef struct IDirectMusicPort *LPDIRECTMUSICPORT; typedef struct IDirectMusicPort IDirectMusicPort8, *LPDIRECTMUSICPORT8; typedef struct IDirectMusicThru *LPDIRECTMUSICTHRU; typedef struct IDirectMusicThru IDirectMusicThru8, *LPDIRECTMUSICTHRU8; -typedef struct IReferenceClock *LPREFERENCECLOCK; -
/***************************************************************************** * Typedef definitions @@ -381,7 +380,7 @@ DECLARE_INTERFACE_(IDirectMusic,IUnknown) STDMETHOD(CreateMusicBuffer)(THIS_ LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER *ppBuffer, LPUNKNOWN pUnkOuter) PURE; STDMETHOD(CreatePort)(THIS_ REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT *ppPort, LPUNKNOWN pUnkOuter) PURE; STDMETHOD(EnumMasterClock)(THIS_ DWORD dwIndex, LPDMUS_CLOCKINFO lpClockInfo) PURE; - STDMETHOD(GetMasterClock)(THIS_ LPGUID pguidClock, struct IReferenceClock **ppReferenceClock) PURE; + STDMETHOD(GetMasterClock)(THIS_ LPGUID pguidClock, IReferenceClock **ppReferenceClock) PURE; STDMETHOD(SetMasterClock)(THIS_ REFGUID rguidClock) PURE; STDMETHOD(Activate)(THIS_ BOOL fEnable) PURE; STDMETHOD(GetDefaultPort)(THIS_ LPGUID pguidPort) PURE; @@ -422,13 +421,13 @@ DECLARE_INTERFACE_(IDirectMusic8,IDirectMusic) STDMETHOD(CreateMusicBuffer)(THIS_ LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER *ppBuffer, LPUNKNOWN pUnkOuter) PURE; STDMETHOD(CreatePort)(THIS_ REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT *ppPort, LPUNKNOWN pUnkOuter) PURE; STDMETHOD(EnumMasterClock)(THIS_ DWORD dwIndex, LPDMUS_CLOCKINFO lpClockInfo) PURE; - STDMETHOD(GetMasterClock)(THIS_ LPGUID pguidClock, struct IReferenceClock **ppReferenceClock) PURE; + STDMETHOD(GetMasterClock)(THIS_ LPGUID pguidClock, IReferenceClock **ppReferenceClock) PURE; STDMETHOD(SetMasterClock)(THIS_ REFGUID rguidClock) PURE; STDMETHOD(Activate)(THIS_ BOOL fEnable) PURE; STDMETHOD(GetDefaultPort)(THIS_ LPGUID pguidPort) PURE; STDMETHOD(SetDirectSound)(THIS_ LPDIRECTSOUND pDirectSound, HWND hWnd) PURE; /*** IDirectMusic8 methods ***/ - STDMETHOD(SetExternalMasterClock)(THIS_ struct IReferenceClock *pClock) PURE; + STDMETHOD(SetExternalMasterClock)(THIS_ IReferenceClock *pClock) PURE; }; #undef INTERFACE
@@ -655,7 +654,7 @@ DECLARE_INTERFACE_(IDirectMusicPort,IUnknown) STDMETHOD(Read)(THIS_ LPDIRECTMUSICBUFFER pBuffer) PURE; STDMETHOD(DownloadInstrument)(THIS_ IDirectMusicInstrument *pInstrument, IDirectMusicDownloadedInstrument **ppDownloadedInstrument, DMUS_NOTERANGE *pNoteRanges, DWORD dwNumNoteRanges) PURE; STDMETHOD(UnloadInstrument)(THIS_ IDirectMusicDownloadedInstrument *pDownloadedInstrument) PURE; - STDMETHOD(GetLatencyClock)(THIS_ struct IReferenceClock **ppClock) PURE; + STDMETHOD(GetLatencyClock)(THIS_ IReferenceClock **ppClock) PURE; STDMETHOD(GetRunningStats)(THIS_ LPDMUS_SYNTHSTATS pStats) PURE; STDMETHOD(Compact)(THIS) PURE; STDMETHOD(GetCaps)(THIS_ LPDMUS_PORTCAPS pPortCaps) PURE; @@ -720,43 +719,6 @@ DECLARE_INTERFACE_(IDirectMusicThru,IUnknown) #define IDirectMusicThru_ThruChannel(p,a,b,c,d,e) (p)->lpVtbl->ThruChannel(p,a,b,c,d,e) #endif
- -#ifndef __IReferenceClock_INTERFACE_DEFINED__ -#define __IReferenceClock_INTERFACE_DEFINED__ -DEFINE_GUID(IID_IReferenceClock,0x56a86897,0x0ad4,0x11ce,0xb0,0x3a,0x00,0x20,0xaf,0x0b,0xa7,0x70); - -/***************************************************************************** - * IReferenceClock interface - */ -#define INTERFACE IReferenceClock -DECLARE_INTERFACE_(IReferenceClock,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IReferenceClock methods ***/ - STDMETHOD(GetTime)(THIS_ REFERENCE_TIME *pTime) PURE; - STDMETHOD(AdviseTime)(THIS_ REFERENCE_TIME baseTime, REFERENCE_TIME streamTime, HANDLE hEvent, DWORD *pdwAdviseCookie) PURE; - STDMETHOD(AdvisePeriodic)(THIS_ REFERENCE_TIME startTime, REFERENCE_TIME periodTime, HANDLE hSemaphore, DWORD *pdwAdviseCookie) PURE; - STDMETHOD(Unadvise)(THIS_ DWORD dwAdviseCookie) PURE; -}; -#undef INTERFACE - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IReferenceClock_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IReferenceClock_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IReferenceClock_Release(p) (p)->lpVtbl->Release(p) -/*** IReferenceClock methods ***/ -#define IReferenceClock_GetTime(p,a) (p)->lpVtbl->GetTime(p,a) -#define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->lpVtbl->AdviseTime(p,a,b,c,d) -#define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->lpVtbl->AdvisePeriodic(p,a,b,c,d) -#define IReferenceClock_Unadvise(p,a) (p)->lpVtbl->Unadvise(p,a) -#endif - -#endif /* __IReferenceClock_INTERFACE_DEFINED__ */ - #ifdef __cplusplus } #endif
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmsynth/synthsink.c | 97 +++++++++++++++++++++++++++++++----- dlls/dmsynth/tests/dmsynth.c | 12 ++--- 2 files changed, 90 insertions(+), 19 deletions(-)
diff --git a/dlls/dmsynth/synthsink.c b/dlls/dmsynth/synthsink.c index 6a2a7269092..28cee0c3a28 100644 --- a/dlls/dmsynth/synthsink.c +++ b/dlls/dmsynth/synthsink.c @@ -29,15 +29,16 @@ struct synth_sink { IDirectMusicSynthSink IDirectMusicSynthSink_iface; IKsControl IKsControl_iface; + IReferenceClock IReferenceClock_iface; LONG ref;
- IReferenceClock *latency_clock; IReferenceClock *master_clock; IDirectMusicSynth *synth; /* No reference hold! */ IDirectSound *dsound;
BOOL active; REFERENCE_TIME activate_time; + REFERENCE_TIME latency_time; };
static inline struct synth_sink *impl_from_IDirectMusicSynthSink(IDirectMusicSynthSink *iface) @@ -74,6 +75,7 @@ static HRESULT synth_sink_activate(struct synth_sink *This) if (This->active) return DMUS_E_SYNTHACTIVE;
if (FAILED(hr = IReferenceClock_GetTime(This->master_clock, &This->activate_time))) return hr; + This->latency_time = This->activate_time;
This->active = TRUE; return S_OK; @@ -131,8 +133,6 @@ static ULONG WINAPI synth_sink_Release(IDirectMusicSynthSink *iface) TRACE("(%p): new ref = %lu\n", This, ref);
if (!ref) { - if (This->latency_clock) - IReferenceClock_Release(This->latency_clock); if (This->master_clock) IReferenceClock_Release(This->master_clock); free(This); @@ -182,8 +182,8 @@ static HRESULT WINAPI synth_sink_GetLatencyClock(IDirectMusicSynthSink *iface, if (!clock) return E_POINTER;
- *clock = This->latency_clock; - IReferenceClock_AddRef(This->latency_clock); + *clock = &This->IReferenceClock_iface; + IReferenceClock_AddRef(*clock);
return S_OK; } @@ -371,10 +371,87 @@ static const IKsControlVtbl synth_sink_control = synth_sink_control_KsEvent, };
+static inline struct synth_sink *impl_from_IReferenceClock(IReferenceClock *iface) +{ + return CONTAINING_RECORD(iface, struct synth_sink, IReferenceClock_iface); +} + +static HRESULT WINAPI latency_clock_QueryInterface(IReferenceClock *iface, REFIID iid, void **out) +{ + TRACE("(%p, %s, %p)\n", iface, debugstr_dmguid(iid), out); + + if (IsEqualIID(iid, &IID_IUnknown) + || IsEqualIID(iid, &IID_IReferenceClock)) + { + IUnknown_AddRef(iface); + *out = iface; + return S_OK; + } + + FIXME("no interface for %s\n", debugstr_dmguid(iid)); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI latency_clock_AddRef(IReferenceClock *iface) +{ + struct synth_sink *This = impl_from_IReferenceClock(iface); + return IDirectMusicSynthSink_AddRef(&This->IDirectMusicSynthSink_iface); +} + +static ULONG WINAPI latency_clock_Release(IReferenceClock *iface) +{ + struct synth_sink *This = impl_from_IReferenceClock(iface); + return IDirectMusicSynthSink_Release(&This->IDirectMusicSynthSink_iface); +} + +static HRESULT WINAPI latency_clock_GetTime(IReferenceClock *iface, REFERENCE_TIME *time) +{ + struct synth_sink *This = impl_from_IReferenceClock(iface); + + TRACE("(%p, %p)\n", iface, time); + + if (!time) return E_INVALIDARG; + if (!This->active) return E_FAIL; + *time = This->latency_time; + + return S_OK; +} + +static HRESULT WINAPI latency_clock_AdviseTime(IReferenceClock *iface, REFERENCE_TIME base, + REFERENCE_TIME offset, HEVENT event, DWORD_PTR *cookie) +{ + FIXME("(%p, %I64d, %I64d, %#Ix, %p): stub\n", iface, base, offset, event, cookie); + return E_NOTIMPL; +} + +static HRESULT WINAPI latency_clock_AdvisePeriodic(IReferenceClock *iface, REFERENCE_TIME start, + REFERENCE_TIME period, HSEMAPHORE semaphore, DWORD_PTR *cookie) +{ + FIXME("(%p, %I64d, %I64d, %#Ix, %p): stub\n", iface, start, period, semaphore, cookie); + return E_NOTIMPL; +} + +static HRESULT WINAPI latency_clock_Unadvise(IReferenceClock *iface, DWORD_PTR cookie) +{ + FIXME("(%p, %#Ix): stub\n", iface, cookie); + return E_NOTIMPL; +} + +static const IReferenceClockVtbl latency_clock_vtbl = +{ + latency_clock_QueryInterface, + latency_clock_AddRef, + latency_clock_Release, + latency_clock_GetTime, + latency_clock_AdviseTime, + latency_clock_AdvisePeriodic, + latency_clock_Unadvise, +}; + HRESULT synth_sink_create(IUnknown **ret_iface) { struct synth_sink *obj; - HRESULT hr;
TRACE("(%p)\n", ret_iface);
@@ -382,15 +459,9 @@ HRESULT synth_sink_create(IUnknown **ret_iface) if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY; obj->IDirectMusicSynthSink_iface.lpVtbl = &synth_sink_vtbl; obj->IKsControl_iface.lpVtbl = &synth_sink_control; + obj->IReferenceClock_iface.lpVtbl = &latency_clock_vtbl; obj->ref = 1;
- hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (void **)&obj->latency_clock); - if (FAILED(hr)) - { - free(obj); - return hr; - } - TRACE("Created DirectMusicSynthSink %p\n", obj); *ret_iface = (IUnknown *)&obj->IDirectMusicSynthSink_iface; return S_OK; diff --git a/dlls/dmsynth/tests/dmsynth.c b/dlls/dmsynth/tests/dmsynth.c index c7546296ed0..99b5c933ab4 100644 --- a/dlls/dmsynth/tests/dmsynth.c +++ b/dlls/dmsynth/tests/dmsynth.c @@ -1222,12 +1222,12 @@ static void test_IDirectMusicSynthSink(void) ok(hr == S_OK, "got %#lx\n", hr); ok(latency_clock != clock, "got same clock\n"); ref = get_refcount(sink); - todo_wine ok(ref == 2, "got %#lx\n", ref); + ok(ref == 2, "got %#lx\n", ref);
hr = IReferenceClock_GetTime(latency_clock, NULL); - todo_wine ok(hr == E_INVALIDARG, "got %#lx\n", hr); + ok(hr == E_INVALIDARG, "got %#lx\n", hr); hr = IReferenceClock_GetTime(latency_clock, &time); - todo_wine ok(hr == E_FAIL, "got %#lx\n", hr); + ok(hr == E_FAIL, "got %#lx\n", hr);
hr = IDirectMusicSynthSink_Init(sink, NULL); ok(hr == S_OK, "got %#lx\n", hr); @@ -1255,7 +1255,7 @@ static void test_IDirectMusicSynthSink(void) hr = IDirectMusicSynthSink_SetMasterClock(sink, clock); ok(hr == S_OK, "got %#lx\n", hr); hr = IReferenceClock_GetTime(latency_clock, &time); - todo_wine ok(hr == E_FAIL, "got %#lx\n", hr); + ok(hr == E_FAIL, "got %#lx\n", hr); hr = IDirectMusicSynthSink_Activate(sink, TRUE); ok(hr == S_OK, "got %#lx\n", hr); hr = IDirectMusicSynthSink_Activate(sink, TRUE); @@ -1283,8 +1283,8 @@ static void test_IDirectMusicSynthSink(void) /* latency clock now works fine */ tmp_time = time; hr = IReferenceClock_GetTime(latency_clock, &tmp_time); - todo_wine_if(hr == S_FALSE) ok(hr == S_OK, "got %#lx\n", hr); - todo_wine_if(tmp_time <= time) ok(tmp_time > time, "got %I64d\n", tmp_time - time); + ok(hr == S_OK, "got %#lx\n", hr); + todo_wine ok(tmp_time > time, "got %I64d\n", tmp_time - time); ok(tmp_time - time <= 2000000, "got %I64d\n", tmp_time - time);
/* setting the clock while active is fine */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmsynth/synth.c | 25 ++++--------------------- dlls/dmsynth/tests/dmsynth.c | 6 +++--- 2 files changed, 7 insertions(+), 24 deletions(-)
diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index e07e47490bd..983e1502fe9 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -38,7 +38,6 @@ struct synth DMUS_PORTPARAMS params; BOOL active; BOOL open; - IReferenceClock *latency_clock; IDirectMusicSynthSink *sink; };
@@ -93,11 +92,7 @@ static ULONG WINAPI synth_Release(IDirectMusicSynth8 *iface)
TRACE("(%p): new ref = %lu\n", This, ref);
- if (!ref) { - if (This->latency_clock) - IReferenceClock_Release(This->latency_clock); - free(This); - } + if (!ref) free(This);
return ref; } @@ -414,14 +409,10 @@ static HRESULT WINAPI synth_GetLatencyClock(IDirectMusicSynth8 *iface,
if (!clock) return E_POINTER; - if (!This->sink) return DMUS_E_NOSYNTHSINK;
- *clock = This->latency_clock; - IReferenceClock_AddRef(This->latency_clock); - - return S_OK; + return IDirectMusicSynthSink_GetLatencyClock(This->sink, clock); }
static HRESULT WINAPI synth_Activate(IDirectMusicSynth8 *iface, BOOL enable) @@ -457,28 +448,20 @@ static HRESULT WINAPI synth_SetSynthSink(IDirectMusicSynth8 *iface, IDirectMusicSynthSink *sink) { struct synth *This = impl_from_IDirectMusicSynth8(iface); - HRESULT hr;
TRACE("(%p)->(%p)\n", iface, sink);
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); - } + if (!sink || This->sink) 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); + return IDirectMusicSynthSink_Init(sink, (IDirectMusicSynth *)iface); }
static HRESULT WINAPI synth_Render(IDirectMusicSynth8 *iface, short *buffer, diff --git a/dlls/dmsynth/tests/dmsynth.c b/dlls/dmsynth/tests/dmsynth.c index 99b5c933ab4..74c3bcea53b 100644 --- a/dlls/dmsynth/tests/dmsynth.c +++ b/dlls/dmsynth/tests/dmsynth.c @@ -1014,7 +1014,7 @@ static void test_IDirectMusicSynth(void) hr = IDirectMusicSynth_SetSynthSink(synth, sink); ok(hr == S_OK, "got %#lx\n", hr); ref = get_refcount(sink); - todo_wine ok(ref == 2, "got %lu\n", ref); + ok(ref == 2, "got %lu\n", ref); hr = IDirectMusicSynth_Activate(synth, TRUE); todo_wine ok(hr == DMUS_E_SYNTHNOTCONFIGURED, "got %#lx\n", hr);
@@ -1062,7 +1062,7 @@ static void test_IDirectMusicSynth(void) hr = IDirectMusicSynth_SetSynthSink(synth, sink); ok(hr == S_OK, "got %#lx\n", hr); ref = get_refcount(sink); - todo_wine ok(ref == 2, "got %lu\n", ref); + ok(ref == 2, "got %lu\n", ref); hr = IDirectMusicSynth_Activate(synth, TRUE); todo_wine ok(hr == S_OK, "got %#lx\n", hr);
@@ -1145,7 +1145,7 @@ static void test_IDirectMusicSynth(void) IDirectMusicSynth_Release(synth);
- if (strcmp(winetest_platform, "wine")) IDirectMusicSynthSink_Release(sink); + IDirectMusicSynthSink_Release(sink); IReferenceClock_Release(clock); IDirectMusic_Release(music); }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmsynth/synth.c | 9 ++------- dlls/dmsynth/tests/dmsynth.c | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index 983e1502fe9..5c492c0e1cf 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -422,16 +422,11 @@ static HRESULT WINAPI synth_Activate(IDirectMusicSynth8 *iface, BOOL enable)
TRACE("(%p)->(%d)\n", This, enable);
+ if (enable == This->active) return S_FALSE; + 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"); diff --git a/dlls/dmsynth/tests/dmsynth.c b/dlls/dmsynth/tests/dmsynth.c index 74c3bcea53b..f6ecf0a2d38 100644 --- a/dlls/dmsynth/tests/dmsynth.c +++ b/dlls/dmsynth/tests/dmsynth.c @@ -1007,7 +1007,7 @@ static void test_IDirectMusicSynth(void) hr = IDirectMusicSynth_Activate(synth, TRUE); ok(hr == DMUS_E_NOSYNTHSINK, "got %#lx\n", hr); hr = IDirectMusicSynth_Activate(synth, FALSE); - todo_wine ok(hr == S_FALSE, "got %#lx\n", hr); + ok(hr == S_FALSE, "got %#lx\n", hr);
hr = IDirectMusicSynth_SetSynthSink(synth, NULL); ok(hr == S_OK, "got %#lx\n", hr); @@ -1034,7 +1034,7 @@ static void test_IDirectMusicSynth(void) hr = IDirectMusicSynth_Activate(synth, TRUE); todo_wine ok(hr == S_OK, "got %#lx\n", hr); hr = IDirectMusicSynth_Activate(synth, TRUE); - todo_wine ok(hr == S_FALSE, "got %#lx\n", hr); + ok(hr == S_FALSE, "got %#lx\n", hr);
/* Close is fine while active */ hr = IDirectMusicSynth_Close(synth);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmsynth/synth.c | 15 +++++++++------ dlls/dmsynth/tests/dmsynth.c | 8 ++++---- 2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index 5c492c0e1cf..0916e64f4a6 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -425,13 +425,16 @@ static HRESULT WINAPI synth_Activate(IDirectMusicSynth8 *iface, BOOL enable) if (enable == This->active) return S_FALSE;
if (!This->sink) - return DMUS_E_NOSYNTHSINK; + { + This->active = FALSE; + return enable ? DMUS_E_NOSYNTHSINK : DMUS_E_SYNTHNOTCONFIGURED; + }
- 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; + if (FAILED(hr = IDirectMusicSynthSink_Activate(This->sink, enable)) + && hr != DMUS_E_SYNTHACTIVE) + { + This->active = FALSE; + return DMUS_E_SYNTHNOTCONFIGURED; }
This->active = enable; diff --git a/dlls/dmsynth/tests/dmsynth.c b/dlls/dmsynth/tests/dmsynth.c index f6ecf0a2d38..63410680bf6 100644 --- a/dlls/dmsynth/tests/dmsynth.c +++ b/dlls/dmsynth/tests/dmsynth.c @@ -1016,7 +1016,7 @@ static void test_IDirectMusicSynth(void) ref = get_refcount(sink); ok(ref == 2, "got %lu\n", ref); hr = IDirectMusicSynth_Activate(synth, TRUE); - todo_wine ok(hr == DMUS_E_SYNTHNOTCONFIGURED, "got %#lx\n", hr); + ok(hr == DMUS_E_SYNTHNOTCONFIGURED, "got %#lx\n", hr);
/* SetMasterClock does nothing */ hr = IDirectMusicSynth_SetMasterClock(synth, NULL); @@ -1047,9 +1047,9 @@ static void test_IDirectMusicSynth(void)
/* but Activate might fail then */ hr = IDirectMusicSynth_Activate(synth, FALSE); - todo_wine ok(hr == DMUS_E_SYNTHNOTCONFIGURED, "got %#lx\n", hr); + ok(hr == DMUS_E_SYNTHNOTCONFIGURED, "got %#lx\n", hr); hr = IDirectMusicSynth_Activate(synth, FALSE); - todo_wine ok(hr == S_FALSE, "got %#lx\n", hr); + ok(hr == S_FALSE, "got %#lx\n", hr);
/* Test generating some samples */ @@ -1064,7 +1064,7 @@ static void test_IDirectMusicSynth(void) ref = get_refcount(sink); ok(ref == 2, "got %lu\n", ref); hr = IDirectMusicSynth_Activate(synth, TRUE); - todo_wine ok(hr == S_OK, "got %#lx\n", hr); + ok(hr == S_OK, "got %#lx\n", hr);
GetTempPathW(MAX_PATH, temp_path); GetTempFileNameW(temp_path, L"synth", 0, temp_file);
This merge request was approved by Michael Stefaniuc.