2012-04-30 11:43:35 +02:00
|
|
|
/*
|
|
|
|
* IDirectMusicSynthSink Implementation
|
2003-07-22 00:10:14 +02:00
|
|
|
*
|
2004-01-20 01:21:40 +01:00
|
|
|
* Copyright (C) 2003-2004 Rok Mandeljc
|
2012-09-21 15:44:37 +02:00
|
|
|
* Copyright (C) 2012 Christian Costa
|
2003-07-22 00:10:14 +02:00
|
|
|
*
|
2007-05-30 12:54:07 +02:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2003-07-22 00:10:14 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-05-30 12:54:07 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2003-07-22 00:10:14 +02:00
|
|
|
*
|
2007-05-30 12:54:07 +02:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-07-22 00:10:14 +02:00
|
|
|
*/
|
|
|
|
|
2012-11-17 22:48:01 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2003-07-22 00:10:14 +02:00
|
|
|
#include "dmsynth_private.h"
|
2012-05-03 23:05:33 +02:00
|
|
|
#include "initguid.h"
|
|
|
|
#include "uuids.h"
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2012-04-30 11:43:35 +02:00
|
|
|
static inline IDirectMusicSynthSinkImpl *impl_from_IDirectMusicSynthSink(IDirectMusicSynthSink *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicSynthSinkImpl, IDirectMusicSynthSink_iface);
|
|
|
|
}
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicSynthSinkImpl IUnknown part: */
|
2020-01-26 21:51:34 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSynthSinkImpl_QueryInterface(IDirectMusicSynthSink *iface,
|
|
|
|
REFIID riid, void **ret_iface)
|
2012-04-30 11:43:35 +02:00
|
|
|
{
|
2012-05-11 08:18:42 +02:00
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
|
|
|
|
|
|
|
|
if (IsEqualIID (riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID (riid, &IID_IDirectMusicSynthSink))
|
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
*ret_iface = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IKsControl))
|
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
*ret_iface = &This->IKsControl_iface;
|
|
|
|
return S_OK;
|
2012-05-08 22:27:44 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 08:18:42 +02:00
|
|
|
*ret_iface = NULL;
|
|
|
|
|
|
|
|
WARN("(%p)->(%s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2020-01-26 21:51:34 +01:00
|
|
|
static ULONG WINAPI IDirectMusicSynthSinkImpl_AddRef(IDirectMusicSynthSink *iface)
|
2012-04-30 11:43:35 +02:00
|
|
|
{
|
2012-05-10 07:53:34 +02:00
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2012-05-10 07:53:34 +02:00
|
|
|
TRACE("(%p)->(): new ref = %u\n", This, ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2012-05-10 07:53:34 +02:00
|
|
|
return ref;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2020-01-26 21:51:34 +01:00
|
|
|
static ULONG WINAPI IDirectMusicSynthSinkImpl_Release(IDirectMusicSynthSink *iface)
|
2012-04-30 11:43:35 +02:00
|
|
|
{
|
2012-05-10 07:53:34 +02:00
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2012-05-10 07:53:34 +02:00
|
|
|
TRACE("(%p)->(): new ref = %u\n", This, ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2012-05-10 07:53:34 +02:00
|
|
|
if (!ref) {
|
|
|
|
if (This->latency_clock)
|
|
|
|
IReferenceClock_Release(This->latency_clock);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2016-07-19 09:53:07 +02:00
|
|
|
DMSYNTH_UnlockModule();
|
2012-05-10 07:53:34 +02:00
|
|
|
}
|
2005-01-31 21:40:26 +01:00
|
|
|
|
2012-05-10 07:53:34 +02:00
|
|
|
return ref;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicSynthSinkImpl IDirectMusicSynthSink part: */
|
2020-01-26 21:51:34 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSynthSinkImpl_Init(IDirectMusicSynthSink *iface,
|
|
|
|
IDirectMusicSynth *synth)
|
2012-04-30 11:43:35 +02:00
|
|
|
{
|
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, synth);
|
|
|
|
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2020-01-26 21:51:34 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSynthSinkImpl_SetMasterClock(IDirectMusicSynthSink *iface,
|
|
|
|
IReferenceClock *clock)
|
2012-04-30 11:43:35 +02:00
|
|
|
{
|
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, clock);
|
|
|
|
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2020-01-26 21:51:34 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSynthSinkImpl_GetLatencyClock(IDirectMusicSynthSink *iface,
|
|
|
|
IReferenceClock **clock)
|
2012-04-30 11:43:35 +02:00
|
|
|
{
|
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
|
|
|
|
|
2012-05-03 23:05:33 +02:00
|
|
|
TRACE("(%p)->(%p)\n", iface, clock);
|
|
|
|
|
|
|
|
if (!clock)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*clock = This->latency_clock;
|
|
|
|
IReferenceClock_AddRef(This->latency_clock);
|
2012-04-30 11:43:35 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2020-01-26 21:51:34 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSynthSinkImpl_Activate(IDirectMusicSynthSink *iface,
|
|
|
|
BOOL enable)
|
2012-04-30 11:43:35 +02:00
|
|
|
{
|
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%d): stub\n", This, enable);
|
|
|
|
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2020-01-26 21:51:34 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSynthSinkImpl_SampleToRefTime(IDirectMusicSynthSink *iface,
|
|
|
|
LONGLONG sample_time, REFERENCE_TIME *ref_time)
|
2012-04-30 11:43:35 +02:00
|
|
|
{
|
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(0x%s, %p): stub\n", This, wine_dbgstr_longlong(sample_time), ref_time);
|
|
|
|
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2020-01-26 21:51:34 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSynthSinkImpl_RefTimeToSample(IDirectMusicSynthSink *iface,
|
|
|
|
REFERENCE_TIME ref_time, LONGLONG *sample_time)
|
2012-04-30 11:43:35 +02:00
|
|
|
{
|
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(0x%s, %p): stub\n", This, wine_dbgstr_longlong(ref_time), sample_time);
|
|
|
|
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2020-01-26 21:51:34 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSynthSinkImpl_SetDirectSound(IDirectMusicSynthSink *iface,
|
|
|
|
IDirectSound *dsound, IDirectSoundBuffer *dsound_buffer)
|
2012-04-30 11:43:35 +02:00
|
|
|
{
|
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p, %p): stub\n", This, dsound, dsound_buffer);
|
|
|
|
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2020-01-26 21:51:34 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicSynthSinkImpl_GetDesiredBufferSize(IDirectMusicSynthSink *iface,
|
|
|
|
DWORD *buffer_size_in_samples)
|
2012-04-30 11:43:35 +02:00
|
|
|
{
|
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, buffer_size_in_samples);
|
|
|
|
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2005-06-01 21:57:42 +02:00
|
|
|
static const IDirectMusicSynthSinkVtbl DirectMusicSynthSink_Vtbl = {
|
2003-07-22 00:10:14 +02:00
|
|
|
IDirectMusicSynthSinkImpl_QueryInterface,
|
|
|
|
IDirectMusicSynthSinkImpl_AddRef,
|
|
|
|
IDirectMusicSynthSinkImpl_Release,
|
|
|
|
IDirectMusicSynthSinkImpl_Init,
|
|
|
|
IDirectMusicSynthSinkImpl_SetMasterClock,
|
|
|
|
IDirectMusicSynthSinkImpl_GetLatencyClock,
|
|
|
|
IDirectMusicSynthSinkImpl_Activate,
|
|
|
|
IDirectMusicSynthSinkImpl_SampleToRefTime,
|
|
|
|
IDirectMusicSynthSinkImpl_RefTimeToSample,
|
|
|
|
IDirectMusicSynthSinkImpl_SetDirectSound,
|
|
|
|
IDirectMusicSynthSinkImpl_GetDesiredBufferSize
|
|
|
|
};
|
|
|
|
|
2012-05-08 22:27:44 +02:00
|
|
|
static inline IDirectMusicSynthSinkImpl *impl_from_IKsControl(IKsControl *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicSynthSinkImpl, IKsControl_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DMSynthSinkImpl_IKsControl_QueryInterface(IKsControl* iface, REFIID riid, LPVOID *ppobj)
|
|
|
|
{
|
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IKsControl(iface);
|
|
|
|
|
|
|
|
return IDirectMusicSynthSinkImpl_QueryInterface(&This->IDirectMusicSynthSink_iface, riid, ppobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI DMSynthSinkImpl_IKsControl_AddRef(IKsControl* iface)
|
|
|
|
{
|
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IKsControl(iface);
|
|
|
|
|
|
|
|
return IDirectMusicSynthSinkImpl_AddRef(&This->IDirectMusicSynthSink_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI DMSynthSinkImpl_IKsControl_Release(IKsControl* iface)
|
|
|
|
{
|
|
|
|
IDirectMusicSynthSinkImpl *This = impl_from_IKsControl(iface);
|
|
|
|
|
|
|
|
return IDirectMusicSynthSinkImpl_Release(&This->IDirectMusicSynthSink_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DMSynthSinkImpl_IKsControl_KsProperty(IKsControl* iface, PKSPROPERTY Property, ULONG PropertyLength, LPVOID PropertyData,
|
|
|
|
ULONG DataLength, ULONG* BytesReturned)
|
|
|
|
{
|
2012-09-21 15:44:37 +02:00
|
|
|
TRACE("(%p)->(%p, %u, %p, %u, %p)\n", iface, Property, PropertyLength, PropertyData, DataLength, BytesReturned);
|
2012-05-08 22:27:44 +02:00
|
|
|
|
2012-11-17 22:48:01 +01:00
|
|
|
TRACE("Property = %s - %u - %u\n", debugstr_guid(&Property->u.s.Set), Property->u.s.Id, Property->u.s.Flags);
|
2012-09-21 15:44:37 +02:00
|
|
|
|
2012-11-17 22:48:01 +01:00
|
|
|
if (Property->u.s.Flags != KSPROPERTY_TYPE_GET)
|
2012-09-21 15:44:37 +02:00
|
|
|
{
|
2012-11-17 22:48:01 +01:00
|
|
|
FIXME("Property flags %u not yet supported\n", Property->u.s.Flags);
|
2012-09-21 15:44:37 +02:00
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DataLength < sizeof(DWORD))
|
2014-10-07 07:36:48 +02:00
|
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
2012-09-21 15:44:37 +02:00
|
|
|
|
2012-11-17 22:48:01 +01:00
|
|
|
if (IsEqualGUID(&Property->u.s.Set, &GUID_DMUS_PROP_SinkUsesDSound))
|
2012-09-21 15:44:37 +02:00
|
|
|
{
|
|
|
|
*(DWORD*)PropertyData = TRUE;
|
|
|
|
*BytesReturned = sizeof(DWORD);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-17 22:48:01 +01:00
|
|
|
FIXME("Unknown property %s\n", debugstr_guid(&Property->u.s.Set));
|
2012-09-21 15:44:37 +02:00
|
|
|
*(DWORD*)PropertyData = FALSE;
|
|
|
|
*BytesReturned = sizeof(DWORD);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2012-05-08 22:27:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DMSynthSinkImpl_IKsControl_KsMethod(IKsControl* iface, PKSMETHOD Method, ULONG MethodLength, LPVOID MethodData,
|
|
|
|
ULONG DataLength, ULONG* BytesReturned)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %u, %p, %u, %p): stub\n", iface, Method, MethodLength, MethodData, DataLength, BytesReturned);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DMSynthSinkImpl_IKsControl_KsEvent(IKsControl* iface, PKSEVENT Event, ULONG EventLength, LPVOID EventData,
|
|
|
|
ULONG DataLength, ULONG* BytesReturned)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %u, %p, %u, %p): stub\n", iface, Event, EventLength, EventData, DataLength, BytesReturned);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const IKsControlVtbl DMSynthSinkImpl_IKsControl_Vtbl = {
|
|
|
|
DMSynthSinkImpl_IKsControl_QueryInterface,
|
|
|
|
DMSynthSinkImpl_IKsControl_AddRef,
|
|
|
|
DMSynthSinkImpl_IKsControl_Release,
|
|
|
|
DMSynthSinkImpl_IKsControl_KsProperty,
|
|
|
|
DMSynthSinkImpl_IKsControl_KsMethod,
|
|
|
|
DMSynthSinkImpl_IKsControl_KsEvent
|
|
|
|
};
|
|
|
|
|
2003-07-22 00:10:14 +02:00
|
|
|
/* for ClassFactory */
|
2016-07-19 09:50:58 +02:00
|
|
|
HRESULT WINAPI DMUSIC_CreateDirectMusicSynthSinkImpl(REFIID riid, void **ret_iface)
|
2012-05-03 23:05:33 +02:00
|
|
|
{
|
|
|
|
IDirectMusicSynthSinkImpl *obj;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2016-07-19 09:50:58 +02:00
|
|
|
TRACE("(%s, %p)\n", debugstr_guid(riid), ret_iface);
|
2012-05-03 23:05:33 +02:00
|
|
|
|
|
|
|
*ret_iface = NULL;
|
|
|
|
|
|
|
|
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynthSinkImpl));
|
|
|
|
if (!obj)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
obj->IDirectMusicSynthSink_iface.lpVtbl = &DirectMusicSynthSink_Vtbl;
|
2012-05-08 22:27:44 +02:00
|
|
|
obj->IKsControl_iface.lpVtbl = &DMSynthSinkImpl_IKsControl_Vtbl;
|
2016-07-15 10:08:14 +02:00
|
|
|
obj->ref = 1;
|
2012-05-03 23:05:33 +02:00
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (LPVOID*)&obj->latency_clock);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, obj);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2016-07-16 17:31:16 +02:00
|
|
|
DMSYNTH_LockModule();
|
2016-07-15 10:08:14 +02:00
|
|
|
hr = IDirectMusicSynthSink_QueryInterface(&obj->IDirectMusicSynthSink_iface, riid, ret_iface);
|
|
|
|
IDirectMusicSynthSink_Release(&obj->IDirectMusicSynthSink_iface);
|
2012-05-03 23:05:33 +02:00
|
|
|
|
2016-07-15 10:08:14 +02:00
|
|
|
return hr;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|