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 IClassFactory IClassFactory_iface
;
37 /******************************************************************
38 * DirectMusicWave ClassFactory
40 static HRESULT WINAPI
WaveCF_QueryInterface(IClassFactory
* iface
, REFIID riid
, void **ppv
)
45 if (IsEqualGUID(&IID_IUnknown
, riid
))
46 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
47 else if (IsEqualGUID(&IID_IClassFactory
, riid
))
48 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
50 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
56 IUnknown_AddRef((IUnknown
*)*ppv
);
60 static ULONG WINAPI
WaveCF_AddRef(IClassFactory
* iface
)
64 return 2; /* non-heap based object */
67 static ULONG WINAPI
WaveCF_Release(IClassFactory
* iface
)
69 DSWAVE_UnlockModule();
71 return 1; /* non-heap based object */
74 static HRESULT WINAPI
WaveCF_CreateInstance(IClassFactory
* iface
, IUnknown
*pOuter
, REFIID riid
,
77 TRACE ("(%p, %s, %p)\n", pOuter
, debugstr_dmguid(riid
), ppobj
);
79 return DMUSIC_CreateDirectMusicWaveImpl (riid
, ppobj
, pOuter
);
82 static HRESULT WINAPI
WaveCF_LockServer(IClassFactory
* iface
, BOOL dolock
)
84 TRACE("(%d)\n", dolock
);
89 DSWAVE_UnlockModule();
94 static const IClassFactoryVtbl WaveCF_Vtbl
= {
95 WaveCF_QueryInterface
,
98 WaveCF_CreateInstance
,
102 static IClassFactoryImpl Wave_CF
= {{&WaveCF_Vtbl
}};
104 /******************************************************************
109 BOOL WINAPI
DllMain (HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
) {
110 if (fdwReason
== DLL_PROCESS_ATTACH
) {
112 DisableThreadLibraryCalls(hinstDLL
);
113 /* FIXME: Initialisation */
114 } else if (fdwReason
== DLL_PROCESS_DETACH
) {
122 /******************************************************************
123 * DllCanUnloadNow (DSWAVE.@)
127 HRESULT WINAPI
DllCanUnloadNow(void)
129 return DSWAVE_refCount
!= 0 ? S_FALSE
: S_OK
;
133 /******************************************************************
134 * DllGetClassObject (DSWAVE.@)
138 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
140 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid
), debugstr_dmguid(riid
), ppv
);
141 if (IsEqualCLSID (rclsid
, &CLSID_DirectSoundWave
) && IsEqualIID (riid
, &IID_IClassFactory
)) {
143 IClassFactory_AddRef((IClassFactory
*)*ppv
);
147 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid
), debugstr_dmguid(riid
), ppv
);
148 return CLASS_E_CLASSNOTAVAILABLE
;
151 /***********************************************************************
152 * DllRegisterServer (DSWAVE.@)
154 HRESULT WINAPI
DllRegisterServer(void)
156 return __wine_register_resources( instance
);
159 /***********************************************************************
160 * DllUnregisterServer (DSWAVE.@)
162 HRESULT WINAPI
DllUnregisterServer(void)
164 return __wine_unregister_resources( instance
);
167 /******************************************************************
172 /* FOURCC to string conversion for debug messages */
173 const char *debugstr_fourcc (DWORD fourcc
) {
174 if (!fourcc
) return "'null'";
175 return wine_dbg_sprintf ("\'%c%c%c%c\'",
176 (char)(fourcc
), (char)(fourcc
>> 8),
177 (char)(fourcc
>> 16), (char)(fourcc
>> 24));
180 /* DMUS_VERSION struct to string conversion for debug messages */
181 static const char *debugstr_dmversion (const DMUS_VERSION
*version
) {
182 if (!version
) return "'null'";
183 return wine_dbg_sprintf ("\'%i,%i,%i,%i\'",
184 (int)((version
->dwVersionMS
& 0xFFFF0000) >> 8), (int)(version
->dwVersionMS
& 0x0000FFFF),
185 (int)((version
->dwVersionLS
& 0xFFFF0000) >> 8), (int)(version
->dwVersionLS
& 0x0000FFFF));
188 /* returns name of given GUID */
189 const char *debugstr_dmguid (const GUID
*id
) {
190 static const guid_info guids
[] = {
192 GE(CLSID_AudioVBScript
),
193 GE(CLSID_DirectMusic
),
194 GE(CLSID_DirectMusicAudioPath
),
195 GE(CLSID_DirectMusicAudioPathConfig
),
196 GE(CLSID_DirectMusicAuditionTrack
),
197 GE(CLSID_DirectMusicBand
),
198 GE(CLSID_DirectMusicBandTrack
),
199 GE(CLSID_DirectMusicChordMapTrack
),
200 GE(CLSID_DirectMusicChordMap
),
201 GE(CLSID_DirectMusicChordTrack
),
202 GE(CLSID_DirectMusicCollection
),
203 GE(CLSID_DirectMusicCommandTrack
),
204 GE(CLSID_DirectMusicComposer
),
205 GE(CLSID_DirectMusicContainer
),
206 GE(CLSID_DirectMusicGraph
),
207 GE(CLSID_DirectMusicLoader
),
208 GE(CLSID_DirectMusicLyricsTrack
),
209 GE(CLSID_DirectMusicMarkerTrack
),
210 GE(CLSID_DirectMusicMelodyFormulationTrack
),
211 GE(CLSID_DirectMusicMotifTrack
),
212 GE(CLSID_DirectMusicMuteTrack
),
213 GE(CLSID_DirectMusicParamControlTrack
),
214 GE(CLSID_DirectMusicPatternTrack
),
215 GE(CLSID_DirectMusicPerformance
),
216 GE(CLSID_DirectMusicScript
),
217 GE(CLSID_DirectMusicScriptAutoImpSegment
),
218 GE(CLSID_DirectMusicScriptAutoImpPerformance
),
219 GE(CLSID_DirectMusicScriptAutoImpSegmentState
),
220 GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig
),
221 GE(CLSID_DirectMusicScriptAutoImpAudioPath
),
222 GE(CLSID_DirectMusicScriptAutoImpSong
),
223 GE(CLSID_DirectMusicScriptSourceCodeLoader
),
224 GE(CLSID_DirectMusicScriptTrack
),
225 GE(CLSID_DirectMusicSection
),
226 GE(CLSID_DirectMusicSegment
),
227 GE(CLSID_DirectMusicSegmentState
),
228 GE(CLSID_DirectMusicSegmentTriggerTrack
),
229 GE(CLSID_DirectMusicSegTriggerTrack
),
230 GE(CLSID_DirectMusicSeqTrack
),
231 GE(CLSID_DirectMusicSignPostTrack
),
232 GE(CLSID_DirectMusicSong
),
233 GE(CLSID_DirectMusicStyle
),
234 GE(CLSID_DirectMusicStyleTrack
),
235 GE(CLSID_DirectMusicSynth
),
236 GE(CLSID_DirectMusicSynthSink
),
237 GE(CLSID_DirectMusicSysExTrack
),
238 GE(CLSID_DirectMusicTemplate
),
239 GE(CLSID_DirectMusicTempoTrack
),
240 GE(CLSID_DirectMusicTimeSigTrack
),
241 GE(CLSID_DirectMusicWaveTrack
),
242 GE(CLSID_DirectSoundWave
),
244 GE(IID_IDirectMusic
),
245 GE(IID_IDirectMusic2
),
246 GE(IID_IDirectMusic8
),
247 GE(IID_IDirectMusicAudioPath
),
248 GE(IID_IDirectMusicBand
),
249 GE(IID_IDirectMusicBuffer
),
250 GE(IID_IDirectMusicChordMap
),
251 GE(IID_IDirectMusicCollection
),
252 GE(IID_IDirectMusicComposer
),
253 GE(IID_IDirectMusicContainer
),
254 GE(IID_IDirectMusicDownload
),
255 GE(IID_IDirectMusicDownloadedInstrument
),
256 GE(IID_IDirectMusicGetLoader
),
257 GE(IID_IDirectMusicGraph
),
258 GE(IID_IDirectMusicInstrument
),
259 GE(IID_IDirectMusicLoader
),
260 GE(IID_IDirectMusicLoader8
),
261 GE(IID_IDirectMusicObject
),
262 GE(IID_IDirectMusicPatternTrack
),
263 GE(IID_IDirectMusicPerformance
),
264 GE(IID_IDirectMusicPerformance2
),
265 GE(IID_IDirectMusicPerformance8
),
266 GE(IID_IDirectMusicPort
),
267 GE(IID_IDirectMusicPortDownload
),
268 GE(IID_IDirectMusicScript
),
269 GE(IID_IDirectMusicSegment
),
270 GE(IID_IDirectMusicSegment2
),
271 GE(IID_IDirectMusicSegment8
),
272 GE(IID_IDirectMusicSegmentState
),
273 GE(IID_IDirectMusicSegmentState8
),
274 GE(IID_IDirectMusicStyle
),
275 GE(IID_IDirectMusicStyle8
),
276 GE(IID_IDirectMusicSynth
),
277 GE(IID_IDirectMusicSynth8
),
278 GE(IID_IDirectMusicSynthSink
),
279 GE(IID_IDirectMusicThru
),
280 GE(IID_IDirectMusicTool
),
281 GE(IID_IDirectMusicTool8
),
282 GE(IID_IDirectMusicTrack
),
283 GE(IID_IDirectMusicTrack8
),
285 GE(IID_IPersistStream
),
287 GE(IID_IClassFactory
),
289 GE(GUID_DirectMusicAllTypes
),
290 GE(GUID_NOTIFICATION_CHORD
),
291 GE(GUID_NOTIFICATION_COMMAND
),
292 GE(GUID_NOTIFICATION_MEASUREANDBEAT
),
293 GE(GUID_NOTIFICATION_PERFORMANCE
),
294 GE(GUID_NOTIFICATION_RECOMPOSE
),
295 GE(GUID_NOTIFICATION_SEGMENT
),
298 GE(GUID_CommandParam
),
299 GE(GUID_CommandParam2
),
300 GE(GUID_CommandParamNext
),
301 GE(GUID_IDirectMusicBand
),
302 GE(GUID_IDirectMusicChordMap
),
303 GE(GUID_IDirectMusicStyle
),
305 GE(GUID_Play_Marker
),
306 GE(GUID_RhythmParam
),
308 GE(GUID_TimeSignature
),
309 GE(GUID_Valid_Start_Time
),
310 GE(GUID_Clear_All_Bands
),
311 GE(GUID_ConnectToDLSCollection
),
312 GE(GUID_Disable_Auto_Download
),
313 GE(GUID_DisableTempo
),
314 GE(GUID_DisableTimeSig
),
316 GE(GUID_DownloadToAudioPath
),
317 GE(GUID_Enable_Auto_Download
),
318 GE(GUID_EnableTempo
),
319 GE(GUID_EnableTimeSig
),
320 GE(GUID_IgnoreBankSelectForGM
),
321 GE(GUID_SeedVariations
),
322 GE(GUID_StandardMIDIFile
),
324 GE(GUID_UnloadFromAudioPath
),
326 GE(GUID_PerfMasterTempo
),
327 GE(GUID_PerfMasterVolume
),
328 GE(GUID_PerfMasterGrooveLevel
),
329 GE(GUID_PerfAutoDownload
),
330 GE(GUID_DefaultGMCollection
),
331 GE(GUID_Synth_Default
),
332 GE(GUID_Buffer_Reverb
),
333 GE(GUID_Buffer_EnvReverb
),
334 GE(GUID_Buffer_Stereo
),
335 GE(GUID_Buffer_3D_Dry
),
336 GE(GUID_Buffer_Mono
),
337 GE(GUID_DMUS_PROP_GM_Hardware
),
338 GE(GUID_DMUS_PROP_GS_Capable
),
339 GE(GUID_DMUS_PROP_GS_Hardware
),
340 GE(GUID_DMUS_PROP_DLS1
),
341 GE(GUID_DMUS_PROP_DLS2
),
342 GE(GUID_DMUS_PROP_Effects
),
343 GE(GUID_DMUS_PROP_INSTRUMENT2
),
344 GE(GUID_DMUS_PROP_LegacyCaps
),
345 GE(GUID_DMUS_PROP_MemorySize
),
346 GE(GUID_DMUS_PROP_SampleMemorySize
),
347 GE(GUID_DMUS_PROP_SamplePlaybackRate
),
348 GE(GUID_DMUS_PROP_SetSynthSink
),
349 GE(GUID_DMUS_PROP_SinkUsesDSound
),
350 GE(GUID_DMUS_PROP_SynthSink_DSOUND
),
351 GE(GUID_DMUS_PROP_SynthSink_WAVE
),
352 GE(GUID_DMUS_PROP_Volume
),
353 GE(GUID_DMUS_PROP_WavesReverb
),
354 GE(GUID_DMUS_PROP_WriteLatency
),
355 GE(GUID_DMUS_PROP_WritePeriod
),
356 GE(GUID_DMUS_PROP_XG_Capable
),
357 GE(GUID_DMUS_PROP_XG_Hardware
)
362 if (!id
) return "(null)";
364 for (i
= 0; i
< sizeof(guids
)/sizeof(guids
[0]); i
++) {
365 if (IsEqualGUID(id
, guids
[i
].guid
))
366 return guids
[i
].name
;
368 /* if we didn't find it, act like standard debugstr_guid */
369 return debugstr_guid(id
);
372 /* generic flag-dumping function */
373 static const char* debugstr_flags (DWORD flags
, const flag_info
* names
, size_t num_names
){
374 char buffer
[128] = "", *ptr
= &buffer
[0];
376 int size
= sizeof(buffer
);
378 for (i
=0; i
< num_names
; i
++)
380 if ((flags
& names
[i
].val
) || /* standard flag*/
381 ((!flags
) && (!names
[i
].val
))) { /* zero value only */
382 int cnt
= snprintf(ptr
, size
, "%s ", names
[i
].name
);
383 if (cnt
< 0 || cnt
>= size
) break;
389 return wine_dbg_sprintf("%s", buffer
);
392 /* dump DMUS_OBJ flags */
393 static const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask
) {
394 static const flag_info flags
[] = {
398 FE(DMUS_OBJ_CATEGORY
),
399 FE(DMUS_OBJ_FILENAME
),
400 FE(DMUS_OBJ_FULLPATH
),
402 FE(DMUS_OBJ_VERSION
),
408 return debugstr_flags (flagmask
, flags
, sizeof(flags
)/sizeof(flags
[0]));
411 /* dump whole DMUS_OBJECTDESC struct */
412 const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc
) {
414 char buffer
[1024] = "", *ptr
= &buffer
[0];
416 ptr
+= sprintf(ptr
, "DMUS_OBJECTDESC (%p):\n", pDesc
);
417 ptr
+= sprintf(ptr
, " - dwSize = %d\n", pDesc
->dwSize
);
418 ptr
+= sprintf(ptr
, " - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (pDesc
->dwValidData
));
419 if (pDesc
->dwValidData
& DMUS_OBJ_CLASS
) ptr
+= sprintf(ptr
, " - guidClass = %s\n", debugstr_dmguid(&pDesc
->guidClass
));
420 if (pDesc
->dwValidData
& DMUS_OBJ_OBJECT
) ptr
+= sprintf(ptr
, " - guidObject = %s\n", debugstr_guid(&pDesc
->guidObject
));
421 if (pDesc
->dwValidData
& DMUS_OBJ_DATE
) ptr
+= sprintf(ptr
, " - ftDate = FIXME\n");
422 if (pDesc
->dwValidData
& DMUS_OBJ_VERSION
) ptr
+= sprintf(ptr
, " - vVersion = %s\n", debugstr_dmversion(&pDesc
->vVersion
));
423 if (pDesc
->dwValidData
& DMUS_OBJ_NAME
) ptr
+= sprintf(ptr
, " - wszName = %s\n", debugstr_w(pDesc
->wszName
));
424 if (pDesc
->dwValidData
& DMUS_OBJ_CATEGORY
) ptr
+= sprintf(ptr
, " - wszCategory = %s\n", debugstr_w(pDesc
->wszCategory
));
425 if (pDesc
->dwValidData
& DMUS_OBJ_FILENAME
) ptr
+= sprintf(ptr
, " - wszFileName = %s\n", debugstr_w(pDesc
->wszFileName
));
426 if (pDesc
->dwValidData
& DMUS_OBJ_MEMORY
) ptr
+= sprintf(ptr
, " - llMemLength = 0x%s\n - pbMemData = %p\n",
427 wine_dbgstr_longlong(pDesc
->llMemLength
), pDesc
->pbMemData
);
428 if (pDesc
->dwValidData
& DMUS_OBJ_STREAM
) ptr
+= sprintf(ptr
, " - pStream = %p", pDesc
->pStream
);
430 return wine_dbg_sprintf("%s", buffer
);
432 return wine_dbg_sprintf("(NULL)");