1 /* DirectMusic Wave Main
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/port.h"
25 #include "dswave_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(dswave);
30 static HINSTANCE instance;
31 LONG DSWAVE_refCount = 0;
34 const IClassFactoryVtbl *lpVtbl;
37 /******************************************************************
38 * DirectMusicWave ClassFactory
40 static HRESULT WINAPI WaveCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
41 FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
43 if (ppobj == NULL) return E_POINTER;
48 static ULONG WINAPI WaveCF_AddRef(LPCLASSFACTORY iface) {
51 return 2; /* non-heap based object */
54 static ULONG WINAPI WaveCF_Release(LPCLASSFACTORY iface) {
55 DSWAVE_UnlockModule();
57 return 1; /* non-heap based object */
60 static HRESULT WINAPI WaveCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
61 TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
63 return DMUSIC_CreateDirectMusicWaveImpl (riid, ppobj, pOuter);
66 static HRESULT WINAPI WaveCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
67 TRACE("(%d)\n", dolock);
72 DSWAVE_UnlockModule();
77 static const IClassFactoryVtbl WaveCF_Vtbl = {
78 WaveCF_QueryInterface,
81 WaveCF_CreateInstance,
85 static IClassFactoryImpl Wave_CF = {&WaveCF_Vtbl};
87 /******************************************************************
92 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
93 if (fdwReason == DLL_PROCESS_ATTACH) {
95 DisableThreadLibraryCalls(hinstDLL);
96 /* FIXME: Initialisation */
97 } else if (fdwReason == DLL_PROCESS_DETACH) {
105 /******************************************************************
106 * DllCanUnloadNow (DSWAVE.@)
110 HRESULT WINAPI DllCanUnloadNow(void)
112 return DSWAVE_refCount != 0 ? S_FALSE : S_OK;
116 /******************************************************************
117 * DllGetClassObject (DSWAVE.@)
121 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
123 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
124 if (IsEqualCLSID (rclsid, &CLSID_DirectSoundWave) && IsEqualIID (riid, &IID_IClassFactory)) {
126 IClassFactory_AddRef((IClassFactory*)*ppv);
130 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
131 return CLASS_E_CLASSNOTAVAILABLE;
134 /***********************************************************************
135 * DllRegisterServer (DSWAVE.@)
137 HRESULT WINAPI DllRegisterServer(void)
139 return __wine_register_resources( instance, NULL );
142 /***********************************************************************
143 * DllUnregisterServer (DSWAVE.@)
145 HRESULT WINAPI DllUnregisterServer(void)
147 return __wine_unregister_resources( instance, NULL );
150 /******************************************************************
155 /* FOURCC to string conversion for debug messages */
156 const char *debugstr_fourcc (DWORD fourcc) {
157 if (!fourcc) return "'null'";
158 return wine_dbg_sprintf ("\'%c%c%c%c\'",
159 (char)(fourcc), (char)(fourcc >> 8),
160 (char)(fourcc >> 16), (char)(fourcc >> 24));
163 /* DMUS_VERSION struct to string conversion for debug messages */
164 static const char *debugstr_dmversion (const DMUS_VERSION *version) {
165 if (!version) return "'null'";
166 return wine_dbg_sprintf ("\'%i,%i,%i,%i\'",
167 (int)((version->dwVersionMS & 0xFFFF0000) >> 8), (int)(version->dwVersionMS & 0x0000FFFF),
168 (int)((version->dwVersionLS & 0xFFFF0000) >> 8), (int)(version->dwVersionLS & 0x0000FFFF));
171 /* returns name of given GUID */
172 const char *debugstr_dmguid (const GUID *id) {
173 static const guid_info guids[] = {
175 GE(CLSID_AudioVBScript),
176 GE(CLSID_DirectMusic),
177 GE(CLSID_DirectMusicAudioPath),
178 GE(CLSID_DirectMusicAudioPathConfig),
179 GE(CLSID_DirectMusicAuditionTrack),
180 GE(CLSID_DirectMusicBand),
181 GE(CLSID_DirectMusicBandTrack),
182 GE(CLSID_DirectMusicChordMapTrack),
183 GE(CLSID_DirectMusicChordMap),
184 GE(CLSID_DirectMusicChordTrack),
185 GE(CLSID_DirectMusicCollection),
186 GE(CLSID_DirectMusicCommandTrack),
187 GE(CLSID_DirectMusicComposer),
188 GE(CLSID_DirectMusicContainer),
189 GE(CLSID_DirectMusicGraph),
190 GE(CLSID_DirectMusicLoader),
191 GE(CLSID_DirectMusicLyricsTrack),
192 GE(CLSID_DirectMusicMarkerTrack),
193 GE(CLSID_DirectMusicMelodyFormulationTrack),
194 GE(CLSID_DirectMusicMotifTrack),
195 GE(CLSID_DirectMusicMuteTrack),
196 GE(CLSID_DirectMusicParamControlTrack),
197 GE(CLSID_DirectMusicPatternTrack),
198 GE(CLSID_DirectMusicPerformance),
199 GE(CLSID_DirectMusicScript),
200 GE(CLSID_DirectMusicScriptAutoImpSegment),
201 GE(CLSID_DirectMusicScriptAutoImpPerformance),
202 GE(CLSID_DirectMusicScriptAutoImpSegmentState),
203 GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
204 GE(CLSID_DirectMusicScriptAutoImpAudioPath),
205 GE(CLSID_DirectMusicScriptAutoImpSong),
206 GE(CLSID_DirectMusicScriptSourceCodeLoader),
207 GE(CLSID_DirectMusicScriptTrack),
208 GE(CLSID_DirectMusicSection),
209 GE(CLSID_DirectMusicSegment),
210 GE(CLSID_DirectMusicSegmentState),
211 GE(CLSID_DirectMusicSegmentTriggerTrack),
212 GE(CLSID_DirectMusicSegTriggerTrack),
213 GE(CLSID_DirectMusicSeqTrack),
214 GE(CLSID_DirectMusicSignPostTrack),
215 GE(CLSID_DirectMusicSong),
216 GE(CLSID_DirectMusicStyle),
217 GE(CLSID_DirectMusicStyleTrack),
218 GE(CLSID_DirectMusicSynth),
219 GE(CLSID_DirectMusicSynthSink),
220 GE(CLSID_DirectMusicSysExTrack),
221 GE(CLSID_DirectMusicTemplate),
222 GE(CLSID_DirectMusicTempoTrack),
223 GE(CLSID_DirectMusicTimeSigTrack),
224 GE(CLSID_DirectMusicWaveTrack),
225 GE(CLSID_DirectSoundWave),
227 GE(IID_IDirectMusic),
228 GE(IID_IDirectMusic2),
229 GE(IID_IDirectMusic8),
230 GE(IID_IDirectMusicAudioPath),
231 GE(IID_IDirectMusicBand),
232 GE(IID_IDirectMusicBuffer),
233 GE(IID_IDirectMusicChordMap),
234 GE(IID_IDirectMusicCollection),
235 GE(IID_IDirectMusicComposer),
236 GE(IID_IDirectMusicContainer),
237 GE(IID_IDirectMusicDownload),
238 GE(IID_IDirectMusicDownloadedInstrument),
239 GE(IID_IDirectMusicGetLoader),
240 GE(IID_IDirectMusicGraph),
241 GE(IID_IDirectMusicInstrument),
242 GE(IID_IDirectMusicLoader),
243 GE(IID_IDirectMusicLoader8),
244 GE(IID_IDirectMusicObject),
245 GE(IID_IDirectMusicPatternTrack),
246 GE(IID_IDirectMusicPerformance),
247 GE(IID_IDirectMusicPerformance2),
248 GE(IID_IDirectMusicPerformance8),
249 GE(IID_IDirectMusicPort),
250 GE(IID_IDirectMusicPortDownload),
251 GE(IID_IDirectMusicScript),
252 GE(IID_IDirectMusicSegment),
253 GE(IID_IDirectMusicSegment2),
254 GE(IID_IDirectMusicSegment8),
255 GE(IID_IDirectMusicSegmentState),
256 GE(IID_IDirectMusicSegmentState8),
257 GE(IID_IDirectMusicStyle),
258 GE(IID_IDirectMusicStyle8),
259 GE(IID_IDirectMusicSynth),
260 GE(IID_IDirectMusicSynth8),
261 GE(IID_IDirectMusicSynthSink),
262 GE(IID_IDirectMusicThru),
263 GE(IID_IDirectMusicTool),
264 GE(IID_IDirectMusicTool8),
265 GE(IID_IDirectMusicTrack),
266 GE(IID_IDirectMusicTrack8),
268 GE(IID_IPersistStream),
270 GE(IID_IClassFactory),
272 GE(GUID_DirectMusicAllTypes),
273 GE(GUID_NOTIFICATION_CHORD),
274 GE(GUID_NOTIFICATION_COMMAND),
275 GE(GUID_NOTIFICATION_MEASUREANDBEAT),
276 GE(GUID_NOTIFICATION_PERFORMANCE),
277 GE(GUID_NOTIFICATION_RECOMPOSE),
278 GE(GUID_NOTIFICATION_SEGMENT),
281 GE(GUID_CommandParam),
282 GE(GUID_CommandParam2),
283 GE(GUID_CommandParamNext),
284 GE(GUID_IDirectMusicBand),
285 GE(GUID_IDirectMusicChordMap),
286 GE(GUID_IDirectMusicStyle),
288 GE(GUID_Play_Marker),
289 GE(GUID_RhythmParam),
291 GE(GUID_TimeSignature),
292 GE(GUID_Valid_Start_Time),
293 GE(GUID_Clear_All_Bands),
294 GE(GUID_ConnectToDLSCollection),
295 GE(GUID_Disable_Auto_Download),
296 GE(GUID_DisableTempo),
297 GE(GUID_DisableTimeSig),
299 GE(GUID_DownloadToAudioPath),
300 GE(GUID_Enable_Auto_Download),
301 GE(GUID_EnableTempo),
302 GE(GUID_EnableTimeSig),
303 GE(GUID_IgnoreBankSelectForGM),
304 GE(GUID_SeedVariations),
305 GE(GUID_StandardMIDIFile),
307 GE(GUID_UnloadFromAudioPath),
309 GE(GUID_PerfMasterTempo),
310 GE(GUID_PerfMasterVolume),
311 GE(GUID_PerfMasterGrooveLevel),
312 GE(GUID_PerfAutoDownload),
313 GE(GUID_DefaultGMCollection),
314 GE(GUID_Synth_Default),
315 GE(GUID_Buffer_Reverb),
316 GE(GUID_Buffer_EnvReverb),
317 GE(GUID_Buffer_Stereo),
318 GE(GUID_Buffer_3D_Dry),
319 GE(GUID_Buffer_Mono),
320 GE(GUID_DMUS_PROP_GM_Hardware),
321 GE(GUID_DMUS_PROP_GS_Capable),
322 GE(GUID_DMUS_PROP_GS_Hardware),
323 GE(GUID_DMUS_PROP_DLS1),
324 GE(GUID_DMUS_PROP_DLS2),
325 GE(GUID_DMUS_PROP_Effects),
326 GE(GUID_DMUS_PROP_INSTRUMENT2),
327 GE(GUID_DMUS_PROP_LegacyCaps),
328 GE(GUID_DMUS_PROP_MemorySize),
329 GE(GUID_DMUS_PROP_SampleMemorySize),
330 GE(GUID_DMUS_PROP_SamplePlaybackRate),
331 GE(GUID_DMUS_PROP_SetSynthSink),
332 GE(GUID_DMUS_PROP_SinkUsesDSound),
333 GE(GUID_DMUS_PROP_SynthSink_DSOUND),
334 GE(GUID_DMUS_PROP_SynthSink_WAVE),
335 GE(GUID_DMUS_PROP_Volume),
336 GE(GUID_DMUS_PROP_WavesReverb),
337 GE(GUID_DMUS_PROP_WriteLatency),
338 GE(GUID_DMUS_PROP_WritePeriod),
339 GE(GUID_DMUS_PROP_XG_Capable),
340 GE(GUID_DMUS_PROP_XG_Hardware)
345 if (!id) return "(null)";
347 for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
348 if (IsEqualGUID(id, guids[i].guid))
349 return guids[i].name;
351 /* if we didn't find it, act like standard debugstr_guid */
352 return debugstr_guid(id);
355 /* generic flag-dumping function */
356 static const char* debugstr_flags (DWORD flags, const flag_info* names, size_t num_names){
357 char buffer[128] = "", *ptr = &buffer[0];
359 int size = sizeof(buffer);
361 for (i=0; i < num_names; i++)
363 if ((flags & names[i].val) || /* standard flag*/
364 ((!flags) && (!names[i].val))) { /* zero value only */
365 int cnt = snprintf(ptr, size, "%s ", names[i].name);
366 if (cnt < 0 || cnt >= size) break;
372 return wine_dbg_sprintf("%s", buffer);
375 /* dump DMUS_OBJ flags */
376 static const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask) {
377 static const flag_info flags[] = {
381 FE(DMUS_OBJ_CATEGORY),
382 FE(DMUS_OBJ_FILENAME),
383 FE(DMUS_OBJ_FULLPATH),
385 FE(DMUS_OBJ_VERSION),
391 return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
394 /* dump whole DMUS_OBJECTDESC struct */
395 const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) {
397 char buffer[1024] = "", *ptr = &buffer[0];
399 ptr += sprintf(ptr, "DMUS_OBJECTDESC (%p):\n", pDesc);
400 ptr += sprintf(ptr, " - dwSize = %d\n", pDesc->dwSize);
401 ptr += sprintf(ptr, " - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (pDesc->dwValidData));
402 if (pDesc->dwValidData & DMUS_OBJ_CLASS) ptr += sprintf(ptr, " - guidClass = %s\n", debugstr_dmguid(&pDesc->guidClass));
403 if (pDesc->dwValidData & DMUS_OBJ_OBJECT) ptr += sprintf(ptr, " - guidObject = %s\n", debugstr_guid(&pDesc->guidObject));
404 if (pDesc->dwValidData & DMUS_OBJ_DATE) ptr += sprintf(ptr, " - ftDate = FIXME\n");
405 if (pDesc->dwValidData & DMUS_OBJ_VERSION) ptr += sprintf(ptr, " - vVersion = %s\n", debugstr_dmversion(&pDesc->vVersion));
406 if (pDesc->dwValidData & DMUS_OBJ_NAME) ptr += sprintf(ptr, " - wszName = %s\n", debugstr_w(pDesc->wszName));
407 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) ptr += sprintf(ptr, " - wszCategory = %s\n", debugstr_w(pDesc->wszCategory));
408 if (pDesc->dwValidData & DMUS_OBJ_FILENAME) ptr += sprintf(ptr, " - wszFileName = %s\n", debugstr_w(pDesc->wszFileName));
409 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) ptr += sprintf(ptr, " - llMemLength = 0x%s\n - pbMemData = %p\n",
410 wine_dbgstr_longlong(pDesc->llMemLength), pDesc->pbMemData);
411 if (pDesc->dwValidData & DMUS_OBJ_STREAM) ptr += sprintf(ptr, " - pStream = %p", pDesc->pStream);
413 return wine_dbg_sprintf("%s", buffer);
415 return wine_dbg_sprintf("(NULL)");