synth.c 10.9 KB
Newer Older
1
/* IDirectMusicSynth8 Implementation
2
 *
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
#include "dmsynth_private.h"
21

22
WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
23

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

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

40
static ULONG WINAPI IDirectMusicSynth8Impl_AddRef (LPDIRECTMUSICSYNTH8 iface) {
41
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
42 43
	ULONG refCount = InterlockedIncrement(&This->ref);

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

46 47
	DMSYNTH_LockModule();

48
	return refCount;
49 50
}

51
static ULONG WINAPI IDirectMusicSynth8Impl_Release (LPDIRECTMUSICSYNTH8 iface) {
52
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
53 54
	ULONG refCount = InterlockedDecrement(&This->ref);

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

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

	DMSYNTH_UnlockModule();
	
63
	return refCount;
64 65
}

66
/* IDirectMusicSynth8Impl IDirectMusicSynth part: */
67
static HRESULT WINAPI IDirectMusicSynth8Impl_Open (LPDIRECTMUSICSYNTH8 iface, LPDMUS_PORTPARAMS pPortParams) {
68
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
Rok Mandeljc's avatar
Rok Mandeljc committed
69 70
	FIXME("(%p, %p): stub\n", This, pPortParams);
	return S_OK;
71 72
}

73
static HRESULT WINAPI IDirectMusicSynth8Impl_Close (LPDIRECTMUSICSYNTH8 iface) {
74
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
Rok Mandeljc's avatar
Rok Mandeljc committed
75 76
	FIXME("(%p): stub\n", This);
	return S_OK;
77 78
}

79
static HRESULT WINAPI IDirectMusicSynth8Impl_SetNumChannelGroups (LPDIRECTMUSICSYNTH8 iface, DWORD dwGroups) {
80
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
81
	FIXME("(%p, %d): stub\n", This, dwGroups);
Rok Mandeljc's avatar
Rok Mandeljc committed
82
	return S_OK;
83 84
}

85
static HRESULT WINAPI IDirectMusicSynth8Impl_Download (LPDIRECTMUSICSYNTH8 iface, LPHANDLE phDownload, LPVOID pvData, LPBOOL pbFree) {
86
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
Rok Mandeljc's avatar
Rok Mandeljc committed
87 88
	FIXME("(%p, %p, %p, %p): stub\n", This, phDownload, pvData, pbFree);
	return S_OK;
89 90
}

91
static HRESULT WINAPI IDirectMusicSynth8Impl_Unload (LPDIRECTMUSICSYNTH8 iface, HANDLE hDownload, HRESULT (CALLBACK* lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData) {
92
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
Rok Mandeljc's avatar
Rok Mandeljc committed
93 94
	FIXME("(%p, %p, %p): stub\n", This, hDownload, hUserData);
	return S_OK;
95 96
}

97
static HRESULT WINAPI IDirectMusicSynth8Impl_PlayBuffer (LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, LPBYTE pbBuffer, DWORD cbBuffer) {
98
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
99
	FIXME("(%p, 0x%s, %p, %d): stub\n", This, wine_dbgstr_longlong(rt), pbBuffer, cbBuffer);
Rok Mandeljc's avatar
Rok Mandeljc committed
100
	return S_OK;
101 102
}

103
static HRESULT WINAPI IDirectMusicSynth8Impl_GetRunningStats (LPDIRECTMUSICSYNTH8 iface, LPDMUS_SYNTHSTATS pStats) {
104
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
Rok Mandeljc's avatar
Rok Mandeljc committed
105 106
	FIXME("(%p, %p): stub\n", This, pStats);
	return S_OK;
107 108
}

109
static HRESULT WINAPI IDirectMusicSynth8Impl_GetPortCaps (LPDIRECTMUSICSYNTH8 iface, LPDMUS_PORTCAPS pCaps) {
110
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
111 112
	TRACE("(%p, %p)\n", This, pCaps);
	*pCaps = This->pCaps;
Rok Mandeljc's avatar
Rok Mandeljc committed
113
	return S_OK;
114 115
}

116
static HRESULT WINAPI IDirectMusicSynth8Impl_SetMasterClock (LPDIRECTMUSICSYNTH8 iface, IReferenceClock* pClock) {
117
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
Rok Mandeljc's avatar
Rok Mandeljc committed
118 119
	FIXME("(%p, %p): stub\n", This, pClock);
	return S_OK;
120 121
}

122
static HRESULT WINAPI IDirectMusicSynth8Impl_GetLatencyClock (LPDIRECTMUSICSYNTH8 iface, IReferenceClock** ppClock) {
123
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
124 125
	TRACE("(%p, %p)\n", This, ppClock);
	*ppClock = This->pLatencyClock;
Rok Mandeljc's avatar
Rok Mandeljc committed
126
	return S_OK;
127 128
}

129
static HRESULT WINAPI IDirectMusicSynth8Impl_Activate (LPDIRECTMUSICSYNTH8 iface, BOOL fEnable) {
130
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
131 132
	TRACE("(%p, %d)\n", This, fEnable);
	This->fActive = fEnable;
Rok Mandeljc's avatar
Rok Mandeljc committed
133
	return S_OK;
134 135
}

136
static HRESULT WINAPI IDirectMusicSynth8Impl_SetSynthSink (LPDIRECTMUSICSYNTH8 iface, IDirectMusicSynthSink* pSynthSink) {
137
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
138 139
	TRACE("(%p, %p)\n", This, pSynthSink);
	This->pSynthSink = (IDirectMusicSynthSinkImpl*)pSynthSink;
Rok Mandeljc's avatar
Rok Mandeljc committed
140
	return S_OK;
141 142
}

143
static HRESULT WINAPI IDirectMusicSynth8Impl_Render (LPDIRECTMUSICSYNTH8 iface, short* pBuffer, DWORD dwLength, LONGLONG llPosition) {
144
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
145
	FIXME("(%p, %p, %d, 0x%s): stub\n", This, pBuffer, dwLength, wine_dbgstr_longlong(llPosition));
Rok Mandeljc's avatar
Rok Mandeljc committed
146
	return S_OK;
147 148
}

149
static HRESULT WINAPI IDirectMusicSynth8Impl_SetChannelPriority (LPDIRECTMUSICSYNTH8 iface, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) {
150
	/*IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface; */
151 152
	/* silenced because of too many messages - 1000 groups * 16 channels ;=) */
	/*FIXME("(%p, %ld, %ld, %ld): stub\n", This, dwChannelGroup, dwChannel, dwPriority); */
Rok Mandeljc's avatar
Rok Mandeljc committed
153
	return S_OK;
154 155
}

156
static HRESULT WINAPI IDirectMusicSynth8Impl_GetChannelPriority (LPDIRECTMUSICSYNTH8 iface, DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) {
157
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
158
	FIXME("(%p, %d, %d, %p): stub\n", This, dwChannelGroup, dwChannel, pdwPriority);
Rok Mandeljc's avatar
Rok Mandeljc committed
159
	return S_OK;
160 161
}

162
static HRESULT WINAPI IDirectMusicSynth8Impl_GetFormat (LPDIRECTMUSICSYNTH8 iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSiz) {
163
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
Rok Mandeljc's avatar
Rok Mandeljc committed
164 165
	FIXME("(%p, %p, %p): stub\n", This, pWaveFormatEx, pdwWaveFormatExSiz);
	return S_OK;
166 167
}

168
static HRESULT WINAPI IDirectMusicSynth8Impl_GetAppend (LPDIRECTMUSICSYNTH8 iface, DWORD* pdwAppend) {
169
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
Rok Mandeljc's avatar
Rok Mandeljc committed
170 171
	FIXME("(%p, %p): stub\n", This, pdwAppend);
	return S_OK;
172 173
}

174
/* IDirectMusicSynth8Impl IDirectMusicSynth8 part: */
175
static HRESULT WINAPI IDirectMusicSynth8Impl_PlayVoice (LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, DWORD dwVoiceId, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwDLId, LONG prPitch, LONG vrVolume, SAMPLE_TIME stVoiceStart, SAMPLE_TIME stLoopStart, SAMPLE_TIME stLoopEnd) {
176
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
177
	FIXME("(%p, 0x%s, %d, %d, %d, %d, %i, %i,0x%s, 0x%s, 0x%s): stub\n",
178 179
	    This, wine_dbgstr_longlong(rt), dwVoiceId, dwChannelGroup, dwChannel, dwDLId, prPitch, vrVolume,
	    wine_dbgstr_longlong(stVoiceStart), wine_dbgstr_longlong(stLoopStart), wine_dbgstr_longlong(stLoopEnd));
Rok Mandeljc's avatar
Rok Mandeljc committed
180
	return S_OK;
181 182
}

183
static HRESULT WINAPI IDirectMusicSynth8Impl_StopVoice (LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, DWORD dwVoiceId) {
184
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
185
	FIXME("(%p, 0x%s, %d): stub\n", This, wine_dbgstr_longlong(rt), dwVoiceId);
Rok Mandeljc's avatar
Rok Mandeljc committed
186
	return S_OK;
187 188
}

189
static HRESULT WINAPI IDirectMusicSynth8Impl_GetVoiceState (LPDIRECTMUSICSYNTH8 iface, DWORD dwVoice[], DWORD cbVoice, DMUS_VOICE_STATE dwVoiceState[]) {
190
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
191
	FIXME("(%p, %p, %d, %p): stub\n", This, dwVoice, cbVoice, dwVoiceState);
Rok Mandeljc's avatar
Rok Mandeljc committed
192
	return S_OK;
193 194
}

195
static HRESULT WINAPI IDirectMusicSynth8Impl_Refresh (LPDIRECTMUSICSYNTH8 iface, DWORD dwDownloadID, DWORD dwFlags) {
196
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
197
	FIXME("(%p, %d, %d): stub\n", This, dwDownloadID, dwFlags);
Rok Mandeljc's avatar
Rok Mandeljc committed
198
	return S_OK;
199 200
}

201
static HRESULT WINAPI IDirectMusicSynth8Impl_AssignChannelToBuses (LPDIRECTMUSICSYNTH8 iface, DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwBuses, DWORD cBuses) {
202
	IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface;
203
	FIXME("(%p, %d, %d, %p, %d): stub\n", This, dwChannelGroup, dwChannel, pdwBuses, cBuses);
Rok Mandeljc's avatar
Rok Mandeljc committed
204
	return S_OK;
205 206
}

207
static const IDirectMusicSynth8Vtbl DirectMusicSynth8_Vtbl = {
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
	IDirectMusicSynth8Impl_QueryInterface,
	IDirectMusicSynth8Impl_AddRef,
	IDirectMusicSynth8Impl_Release,
	IDirectMusicSynth8Impl_Open,
	IDirectMusicSynth8Impl_Close,
	IDirectMusicSynth8Impl_SetNumChannelGroups,
	IDirectMusicSynth8Impl_Download,
	IDirectMusicSynth8Impl_Unload,
	IDirectMusicSynth8Impl_PlayBuffer,
	IDirectMusicSynth8Impl_GetRunningStats,
	IDirectMusicSynth8Impl_GetPortCaps,
	IDirectMusicSynth8Impl_SetMasterClock,
	IDirectMusicSynth8Impl_GetLatencyClock,
	IDirectMusicSynth8Impl_Activate,
	IDirectMusicSynth8Impl_SetSynthSink,
	IDirectMusicSynth8Impl_Render,
	IDirectMusicSynth8Impl_SetChannelPriority,
	IDirectMusicSynth8Impl_GetChannelPriority,
	IDirectMusicSynth8Impl_GetFormat,
	IDirectMusicSynth8Impl_GetAppend,
	IDirectMusicSynth8Impl_PlayVoice,
	IDirectMusicSynth8Impl_StopVoice,
	IDirectMusicSynth8Impl_GetVoiceState,
	IDirectMusicSynth8Impl_Refresh,
	IDirectMusicSynth8Impl_AssignChannelToBuses
};

235
/* for ClassFactory */
236 237
HRESULT WINAPI DMUSIC_CreateDirectMusicSynthImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
	IDirectMusicSynth8Impl *obj;
238
	
239 240 241
	TRACE("(%p,%p,%p)\n", lpcGUID, ppobj, pUnkOuter);
	obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynth8Impl));
	if (NULL == obj) {
242
		*ppobj = NULL;
243
		return E_OUTOFMEMORY;
244
	}
245 246 247 248 249 250 251 252 253 254 255 256 257
	obj->lpVtbl = &DirectMusicSynth8_Vtbl;
	obj->ref = 0;
	/* fill in caps */
	obj->pCaps.dwSize = sizeof(DMUS_PORTCAPS);
	obj->pCaps.dwFlags = DMUS_PC_DLS | DMUS_PC_SOFTWARESYNTH | DMUS_PC_DIRECTSOUND | DMUS_PC_DLS2 | DMUS_PC_AUDIOPATH | DMUS_PC_WAVE;
	obj->pCaps.guidPort = CLSID_DirectMusicSynth;
	obj->pCaps.dwClass = DMUS_PC_OUTPUTCLASS;
	obj->pCaps.dwType = DMUS_PORT_WINMM_DRIVER;
	obj->pCaps.dwMemorySize = DMUS_PC_SYSTEMMEMORY;
	obj->pCaps.dwMaxChannelGroups = 1000;
	obj->pCaps.dwMaxVoices = 1000;
	obj->pCaps.dwMaxAudioChannels = -1;
	obj->pCaps.dwEffectFlags = DMUS_EFFECT_REVERB | DMUS_EFFECT_CHORUS | DMUS_EFFECT_DELAY;
Jeff Zaroyko's avatar
Jeff Zaroyko committed
258
	MultiByteToWideChar (CP_ACP, 0, "Microsoft Synthesizer", -1, obj->pCaps.wszDescription, sizeof(obj->pCaps.wszDescription)/sizeof(WCHAR));
259 260 261 262
	/* assign latency clock */
	/*DMUSIC_CreateReferenceClockImpl (&IID_IReferenceClock, (LPVOID*)&This->pLatencyClock, NULL); */

	return IDirectMusicSynth8Impl_QueryInterface ((LPDIRECTMUSICSYNTH8)obj, lpcGUID, ppobj);
263
}