synthsink.c 5.35 KB
Newer Older
1 2
/* IDirectMusicSynthSink Implementation
 *
3
 * Copyright (C) 2003-2004 Rok Mandeljc
4
 *
5 6 7 8
 * 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.
9 10 11
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
14
 *
15 16 17
 * 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
18 19 20 21
 */

#include "dmsynth_private.h"

22
WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
23

24
/* IDirectMusicSynthSinkImpl IUnknown part: */
25
static HRESULT WINAPI IDirectMusicSynthSinkImpl_QueryInterface (LPDIRECTMUSICSYNTHSINK iface, REFIID riid, LPVOID *ppobj) {
26
	IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
27
	TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
28

29 30
	if (IsEqualIID (riid, &IID_IUnknown) || 
	    IsEqualIID (riid, &IID_IDirectMusicSynthSink)) {
31
		IUnknown_AddRef(iface);
32 33 34
		*ppobj = This;
		return S_OK;
	}
35
	WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
36 37 38
	return E_NOINTERFACE;
}

39
static ULONG WINAPI IDirectMusicSynthSinkImpl_AddRef (LPDIRECTMUSICSYNTHSINK iface) {
40
	IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
41 42
	ULONG refCount = InterlockedIncrement(&This->ref);

43
	TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
44

45 46
	DMSYNTH_LockModule();

47
	return refCount;
48 49
}

50
static ULONG WINAPI IDirectMusicSynthSinkImpl_Release (LPDIRECTMUSICSYNTHSINK iface) {
51
	IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
52 53
	ULONG refCount = InterlockedDecrement(&This->ref);

54
	TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
55 56

	if (!refCount) {
57 58
		HeapFree(GetProcessHeap(), 0, This);
	}
59 60 61

	DMSYNTH_UnlockModule();

62
	return refCount;
63 64
}

65
/* IDirectMusicSynthSinkImpl IDirectMusicSynthSink part: */
66
static HRESULT WINAPI IDirectMusicSynthSinkImpl_Init (LPDIRECTMUSICSYNTHSINK iface, IDirectMusicSynth* pSynth) {
67
	IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
68 69 70 71
	FIXME("(%p, %p): stub\n", This, pSynth);
	return S_OK;
}

72
static HRESULT WINAPI IDirectMusicSynthSinkImpl_SetMasterClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock* pClock) {
73
	IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
74 75 76 77
	FIXME("(%p, %p): stub\n", This, pClock);
	return S_OK;
}

78
static HRESULT WINAPI IDirectMusicSynthSinkImpl_GetLatencyClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock** ppClock) {
79
	IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
80 81 82 83
	FIXME("(%p, %p): stub\n", This, ppClock);
	return S_OK;
}

84
static HRESULT WINAPI IDirectMusicSynthSinkImpl_Activate (LPDIRECTMUSICSYNTHSINK iface, BOOL fEnable) {
85
	IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
86 87 88 89
	FIXME("(%p, %d): stub\n", This, fEnable);
	return S_OK;
}

90
static HRESULT WINAPI IDirectMusicSynthSinkImpl_SampleToRefTime (LPDIRECTMUSICSYNTHSINK iface, LONGLONG llSampleTime, REFERENCE_TIME* prfTime) {
91
	IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
92
	FIXME("(%p, 0x%s, %p): stub\n", This, wine_dbgstr_longlong(llSampleTime), prfTime);
93 94 95
	return S_OK;
}

96
static HRESULT WINAPI IDirectMusicSynthSinkImpl_RefTimeToSample (LPDIRECTMUSICSYNTHSINK iface, REFERENCE_TIME rfTime, LONGLONG* pllSampleTime) {
97
	IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
98
	FIXME("(%p, 0x%s, %p): stub\n", This, wine_dbgstr_longlong(rfTime), pllSampleTime );
99 100 101
	return S_OK;
}

102
static HRESULT WINAPI IDirectMusicSynthSinkImpl_SetDirectSound (LPDIRECTMUSICSYNTHSINK iface, LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer) {
103
	IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
104 105 106 107
	FIXME("(%p, %p, %p): stub\n", This, pDirectSound, pDirectSoundBuffer);
	return S_OK;
}

108
static HRESULT WINAPI IDirectMusicSynthSinkImpl_GetDesiredBufferSize (LPDIRECTMUSICSYNTHSINK iface, LPDWORD pdwBufferSizeInSamples) {
109
	IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
110 111 112 113
	FIXME("(%p, %p): stub\n", This, pdwBufferSizeInSamples);
	return S_OK;
}

114
static const IDirectMusicSynthSinkVtbl DirectMusicSynthSink_Vtbl = {
115 116 117 118 119 120 121 122 123 124 125 126 127 128
	IDirectMusicSynthSinkImpl_QueryInterface,
	IDirectMusicSynthSinkImpl_AddRef,
	IDirectMusicSynthSinkImpl_Release,
	IDirectMusicSynthSinkImpl_Init,
	IDirectMusicSynthSinkImpl_SetMasterClock,
	IDirectMusicSynthSinkImpl_GetLatencyClock,
	IDirectMusicSynthSinkImpl_Activate,
	IDirectMusicSynthSinkImpl_SampleToRefTime,
	IDirectMusicSynthSinkImpl_RefTimeToSample,
	IDirectMusicSynthSinkImpl_SetDirectSound,
	IDirectMusicSynthSinkImpl_GetDesiredBufferSize
};

/* for ClassFactory */
129 130
HRESULT WINAPI DMUSIC_CreateDirectMusicSynthSinkImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
	IDirectMusicSynthSinkImpl *obj;
131
	
132 133 134
	TRACE("(%p,%p,%p)\n", lpcGUID, ppobj, pUnkOuter);
	obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynthSinkImpl));
	if (NULL == obj) {
135
		*ppobj = NULL;
136
		return E_OUTOFMEMORY;
137
	}
138 139
	obj->lpVtbl = &DirectMusicSynthSink_Vtbl;
	obj->ref = 0;
140
	
141
	return IDirectMusicSynthSinkImpl_QueryInterface((LPDIRECTMUSICSYNTHSINK)obj, lpcGUID, ppobj);
142
}