From 25dcca4b30fbae830386eac90d57077b8965e6fb Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Mon, 20 Aug 2018 00:01:35 +0200 Subject: [PATCH] dmusic: Implement IDirectMusicPort_GetLatencyClock() for the midi port. Signed-off-by: Michael Stefaniuc Signed-off-by: Alexandre Julliard --- dlls/dmusic/port.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/dlls/dmusic/port.c b/dlls/dmusic/port.c index 2f8fb9288c2..ebc85067698 100644 --- a/dlls/dmusic/port.c +++ b/dlls/dmusic/port.c @@ -907,6 +907,7 @@ HRESULT synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_param struct midi_port { IDirectMusicPort IDirectMusicPort_iface; LONG ref; + IReferenceClock *clock; }; static inline struct midi_port *impl_from_IDirectMusicPort(IDirectMusicPort *iface) @@ -949,8 +950,11 @@ static ULONG WINAPI midi_IDirectMusicPort_Release(IDirectMusicPort *iface) TRACE("(%p) ref = %u\n", iface, ref); - if (!ref) + if (!ref) { + if (This->clock) + IReferenceClock_Release(This->clock); heap_free(This); + } return ref; } @@ -999,9 +1003,17 @@ static HRESULT WINAPI midi_IDirectMusicPort_UnloadInstrument(IDirectMusicPort *i static HRESULT WINAPI midi_IDirectMusicPort_GetLatencyClock(IDirectMusicPort *iface, IReferenceClock **clock) { - FIXME("(%p, %p) stub!\n", iface, clock); + struct midi_port *This = impl_from_IDirectMusicPort(iface); - return E_NOTIMPL; + TRACE("(%p, %p)\n", iface, clock); + + if (!clock) + return E_POINTER; + + *clock = This->clock; + IReferenceClock_AddRef(*clock); + + return S_OK; } static HRESULT WINAPI midi_IDirectMusicPort_GetRunningStats(IDirectMusicPort *iface, @@ -1118,6 +1130,7 @@ HRESULT midi_out_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_pa DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) { struct midi_port *obj; + HRESULT hr; TRACE("(%p, %p, %p)\n", port_params, port_caps, port); @@ -1127,6 +1140,12 @@ HRESULT midi_out_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_pa obj->IDirectMusicPort_iface.lpVtbl = &midi_port_vtbl; obj->ref = 1; + hr = DMUSIC_CreateReferenceClockImpl(&IID_IReferenceClock, (void **)&obj->clock, NULL); + if (hr != S_OK) { + HeapFree(GetProcessHeap(), 0, obj); + return hr; + } + *port = &obj->IDirectMusicPort_iface; return S_OK;