3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998 Rob Riggs
5 * Copyright 2000-2002 TransGaming Technologies, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Most thread locking is complete. There may be a few race
23 * conditions still lurking.
25 * Tested with a Soundblaster clone, a Gravis UltraSound Classic,
26 * and a Turtle Beach Tropez+.
29 * Implement SetCooperativeLevel properly (need to address focus issues)
30 * Implement DirectSound3DBuffers (stubs in place)
31 * Use hardware 3D support if available
32 * Add critical section locking inside Release and AddRef methods
33 * Handle static buffers - put those in hardware, non-static not in hardware
34 * Hardware DuplicateSoundBuffer
35 * Proper volume calculation, and setting volume in HEL primary buffer
36 * Optimize WINMM and negotiate fragment size, decrease DS_HEL_MARGIN
42 #define NONAMELESSSTRUCT
43 #define NONAMELESSUNION
51 #include "wine/debug.h"
54 #include "dsound_private.h"
57 WINE_DEFAULT_DEBUG_CHANNEL(dsound
);
59 /* these are eligible for tuning... they must be high on slow machines... */
60 /* some stuff may get more responsive with lower values though... */
61 #define DS_EMULDRIVER 0 /* some games (Quake 2, UT) refuse to accept
62 emulated dsound devices. set to 0 ! */
63 #define DS_HEL_MARGIN 5 /* HEL only: number of waveOut fragments ahead to mix in new buffers
64 * (keep this close or equal to DS_HEL_QUEUE for best results) */
65 #define DS_HEL_QUEUE 5 /* HEL only: number of waveOut fragments ahead to queue to driver
66 * (this will affect HEL sound reliability and latency) */
68 #define DS_SND_QUEUE_MAX 28 /* max number of fragments to prebuffer */
69 #define DS_SND_QUEUE_MIN 12 /* min number of fragments to prebuffer */
71 DirectSoundDevice
* DSOUND_renderer
[MAXWAVEDRIVERS
];
72 GUID DSOUND_renderer_guids
[MAXWAVEDRIVERS
];
73 GUID DSOUND_capture_guids
[MAXWAVEDRIVERS
];
75 HRESULT
mmErr(UINT err
)
78 case MMSYSERR_NOERROR
:
80 case MMSYSERR_ALLOCATED
:
81 return DSERR_ALLOCATED
;
83 case MMSYSERR_INVALHANDLE
:
84 case WAVERR_STILLPLAYING
:
85 return DSERR_GENERIC
; /* FIXME */
86 case MMSYSERR_NODRIVER
:
87 return DSERR_NODRIVER
;
89 return DSERR_OUTOFMEMORY
;
90 case MMSYSERR_INVALPARAM
:
91 case WAVERR_BADFORMAT
:
92 case WAVERR_UNPREPARED
:
93 return DSERR_INVALIDPARAM
;
94 case MMSYSERR_NOTSUPPORTED
:
95 return DSERR_UNSUPPORTED
;
97 FIXME("Unknown MMSYS error %d\n",err
);
102 int ds_emuldriver
= DS_EMULDRIVER
;
103 int ds_hel_margin
= DS_HEL_MARGIN
;
104 int ds_hel_queue
= DS_HEL_QUEUE
;
105 int ds_snd_queue_max
= DS_SND_QUEUE_MAX
;
106 int ds_snd_queue_min
= DS_SND_QUEUE_MIN
;
107 int ds_hw_accel
= DS_HW_ACCEL_FULL
;
108 int ds_default_playback
= 0;
109 int ds_default_capture
= 0;
112 * Get a config key from either the app-specific or the default config
115 inline static DWORD
get_config_key( HKEY defkey
, HKEY appkey
, const char *name
,
116 char *buffer
, DWORD size
)
118 if (appkey
&& !RegQueryValueExA( appkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
119 if (defkey
&& !RegQueryValueExA( defkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
120 return ERROR_FILE_NOT_FOUND
;
125 * Setup the dsound options.
128 void setup_dsound_options(void)
130 char buffer
[MAX_PATH
+16];
131 HKEY hkey
, appkey
= 0;
134 buffer
[MAX_PATH
]='\0';
136 /* @@ Wine registry key: HKCU\Software\Wine\DirectSound */
137 if (RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\DirectSound", &hkey
)) hkey
= 0;
139 len
= GetModuleFileNameA( 0, buffer
, MAX_PATH
);
140 if (len
&& len
< MAX_PATH
)
143 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectSound */
144 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\AppDefaults", &tmpkey
))
146 char *p
, *appname
= buffer
;
147 if ((p
= strrchr( appname
, '/' ))) appname
= p
+ 1;
148 if ((p
= strrchr( appname
, '\\' ))) appname
= p
+ 1;
149 strcat( appname
, "\\DirectSound" );
150 TRACE("appname = [%s] \n",appname
);
151 if (RegOpenKeyA( tmpkey
, appname
, &appkey
)) appkey
= 0;
152 RegCloseKey( tmpkey
);
158 if (!get_config_key( hkey
, appkey
, "EmulDriver", buffer
, MAX_PATH
))
159 ds_emuldriver
= strcmp(buffer
, "N");
161 if (!get_config_key( hkey
, appkey
, "HELmargin", buffer
, MAX_PATH
))
162 ds_hel_margin
= atoi(buffer
);
164 if (!get_config_key( hkey
, appkey
, "HELqueue", buffer
, MAX_PATH
))
165 ds_hel_queue
= atoi(buffer
);
167 if (!get_config_key( hkey
, appkey
, "SndQueueMax", buffer
, MAX_PATH
))
168 ds_snd_queue_max
= atoi(buffer
);
170 if (!get_config_key( hkey
, appkey
, "SndQueueMin", buffer
, MAX_PATH
))
171 ds_snd_queue_min
= atoi(buffer
);
173 if (!get_config_key( hkey
, appkey
, "HardwareAcceleration", buffer
, MAX_PATH
)) {
174 if (strcmp(buffer
, "Full") == 0)
175 ds_hw_accel
= DS_HW_ACCEL_FULL
;
176 else if (strcmp(buffer
, "Standard") == 0)
177 ds_hw_accel
= DS_HW_ACCEL_STANDARD
;
178 else if (strcmp(buffer
, "Basic") == 0)
179 ds_hw_accel
= DS_HW_ACCEL_BASIC
;
180 else if (strcmp(buffer
, "Emulation") == 0)
181 ds_hw_accel
= DS_HW_ACCEL_EMULATION
;
183 FIXME("dsound is hardcoded to software emulation until we fix it in ros\n");
184 ds_hw_accel
= DS_HW_ACCEL_EMULATION
;
186 if (!get_config_key( hkey
, appkey
, "DefaultPlayback", buffer
, MAX_PATH
))
187 ds_default_playback
= atoi(buffer
);
189 if (!get_config_key( hkey
, appkey
, "DefaultCapture", buffer
, MAX_PATH
))
190 ds_default_capture
= atoi(buffer
);
192 if (appkey
) RegCloseKey( appkey
);
193 if (hkey
) RegCloseKey( hkey
);
195 if (ds_emuldriver
!= DS_EMULDRIVER
)
196 WARN("ds_emuldriver = %d (default=%d)\n",ds_emuldriver
, DS_EMULDRIVER
);
197 if (ds_hel_margin
!= DS_HEL_MARGIN
)
198 WARN("ds_hel_margin = %d (default=%d)\n",ds_hel_margin
, DS_HEL_MARGIN
);
199 if (ds_hel_queue
!= DS_HEL_QUEUE
)
200 WARN("ds_hel_queue = %d (default=%d)\n",ds_hel_queue
, DS_HEL_QUEUE
);
201 if (ds_snd_queue_max
!= DS_SND_QUEUE_MAX
)
202 WARN("ds_snd_queue_max = %d (default=%d)\n",ds_snd_queue_max
,DS_SND_QUEUE_MAX
);
203 if (ds_snd_queue_min
!= DS_SND_QUEUE_MIN
)
204 WARN("ds_snd_queue_min = %d (default=%d)\n",ds_snd_queue_min
,DS_SND_QUEUE_MIN
);
205 if (ds_hw_accel
!= DS_HW_ACCEL_FULL
)
206 WARN("ds_hw_accel = %s (default=Full)\n",
207 ds_hw_accel
==DS_HW_ACCEL_FULL
? "Full" :
208 ds_hw_accel
==DS_HW_ACCEL_STANDARD
? "Standard" :
209 ds_hw_accel
==DS_HW_ACCEL_BASIC
? "Basic" :
210 ds_hw_accel
==DS_HW_ACCEL_EMULATION
? "Emulation" :
212 if (ds_default_playback
!= 0)
213 WARN("ds_default_playback = %d (default=0)\n",ds_default_playback
);
214 if (ds_default_capture
!= 0)
215 WARN("ds_default_capture = %d (default=0)\n",ds_default_playback
);
218 const char * get_device_id(LPCGUID pGuid
)
220 if (IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuid
))
221 return "DSDEVID_DefaultPlayback";
222 else if (IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuid
))
223 return "DSDEVID_DefaultVoicePlayback";
224 else if (IsEqualGUID(&DSDEVID_DefaultCapture
, pGuid
))
225 return "DSDEVID_DefaultCapture";
226 else if (IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuid
))
227 return "DSDEVID_DefaultVoiceCapture";
228 return debugstr_guid(pGuid
);
231 /***************************************************************************
232 * GetDeviceID [DSOUND.9]
234 * Retrieves unique identifier of default device specified
237 * pGuidSrc [I] Address of device GUID.
238 * pGuidDest [O] Address to receive unique device GUID.
242 * Failure: DSERR_INVALIDPARAM
245 * pGuidSrc is a valid device GUID or DSDEVID_DefaultPlayback,
246 * DSDEVID_DefaultCapture, DSDEVID_DefaultVoicePlayback, or
247 * DSDEVID_DefaultVoiceCapture.
248 * Returns pGuidSrc if pGuidSrc is a valid device or the device
249 * GUID for the specified constants.
251 HRESULT WINAPI
GetDeviceID(LPCGUID pGuidSrc
, LPGUID pGuidDest
)
253 TRACE("(%s,%p)\n", get_device_id(pGuidSrc
),pGuidDest
);
255 if ( pGuidSrc
== NULL
) {
256 WARN("invalid parameter: pGuidSrc == NULL\n");
257 return DSERR_INVALIDPARAM
;
260 if ( pGuidDest
== NULL
) {
261 WARN("invalid parameter: pGuidDest == NULL\n");
262 return DSERR_INVALIDPARAM
;
265 if ( IsEqualGUID( &DSDEVID_DefaultPlayback
, pGuidSrc
) ||
266 IsEqualGUID( &DSDEVID_DefaultVoicePlayback
, pGuidSrc
) ) {
267 CopyMemory(pGuidDest
, &DSOUND_renderer_guids
[ds_default_playback
], sizeof(GUID
));
268 TRACE("returns %s\n", get_device_id(pGuidDest
));
272 if ( IsEqualGUID( &DSDEVID_DefaultCapture
, pGuidSrc
) ||
273 IsEqualGUID( &DSDEVID_DefaultVoiceCapture
, pGuidSrc
) ) {
274 CopyMemory(pGuidDest
, &DSOUND_capture_guids
[ds_default_capture
], sizeof(GUID
));
275 TRACE("returns %s\n", get_device_id(pGuidDest
));
279 CopyMemory(pGuidDest
, pGuidSrc
, sizeof(GUID
));
280 TRACE("returns %s\n", get_device_id(pGuidDest
));
286 /***************************************************************************
287 * DirectSoundEnumerateA [DSOUND.2]
289 * Enumerate all DirectSound drivers installed in the system
292 * lpDSEnumCallback [I] Address of callback function.
293 * lpContext [I] Address of user defined context passed to callback function.
297 * Failure: DSERR_INVALIDPARAM
299 HRESULT WINAPI
DirectSoundEnumerateA(
300 LPDSENUMCALLBACKA lpDSEnumCallback
,
308 TRACE("lpDSEnumCallback = %p, lpContext = %p\n",
309 lpDSEnumCallback
, lpContext
);
311 if (lpDSEnumCallback
== NULL
) {
312 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
313 return DSERR_INVALIDPARAM
;
316 devs
= waveOutGetNumDevs();
318 if (GetDeviceID(&DSDEVID_DefaultPlayback
, &guid
) == DS_OK
) {
319 for (wod
= 0; wod
< devs
; ++wod
) {
320 if (IsEqualGUID( &guid
, &DSOUND_renderer_guids
[wod
]) ) {
321 err
= mmErr(WineWaveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
323 TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
324 "Primary Sound Driver",desc
.szDrvname
,lpContext
);
325 if (lpDSEnumCallback(NULL
, "Primary Sound Driver", desc
.szDrvname
, lpContext
) == FALSE
)
333 for (wod
= 0; wod
< devs
; ++wod
) {
334 err
= mmErr(WineWaveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
336 TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
337 debugstr_guid(&DSOUND_renderer_guids
[wod
]),desc
.szDesc
,desc
.szDrvname
,lpContext
);
338 if (lpDSEnumCallback(&DSOUND_renderer_guids
[wod
], desc
.szDesc
, desc
.szDrvname
, lpContext
) == FALSE
)
345 /***************************************************************************
346 * DirectSoundEnumerateW [DSOUND.3]
348 * Enumerate all DirectSound drivers installed in the system
351 * lpDSEnumCallback [I] Address of callback function.
352 * lpContext [I] Address of user defined context passed to callback function.
356 * Failure: DSERR_INVALIDPARAM
358 HRESULT WINAPI
DirectSoundEnumerateW(
359 LPDSENUMCALLBACKW lpDSEnumCallback
,
366 WCHAR wDesc
[MAXPNAMELEN
];
367 WCHAR wName
[MAXPNAMELEN
];
369 TRACE("lpDSEnumCallback = %p, lpContext = %p\n",
370 lpDSEnumCallback
, lpContext
);
372 if (lpDSEnumCallback
== NULL
) {
373 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
374 return DSERR_INVALIDPARAM
;
377 devs
= waveOutGetNumDevs();
379 if (GetDeviceID(&DSDEVID_DefaultPlayback
, &guid
) == DS_OK
) {
380 for (wod
= 0; wod
< devs
; ++wod
) {
381 if (IsEqualGUID( &guid
, &DSOUND_renderer_guids
[wod
] ) ) {
382 err
= mmErr(WineWaveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
384 TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
385 "Primary Sound Driver",desc
.szDrvname
,lpContext
);
386 MultiByteToWideChar( CP_ACP
, 0, "Primary Sound Driver", -1,
387 wDesc
, sizeof(wDesc
)/sizeof(WCHAR
) );
388 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1,
389 wName
, sizeof(wName
)/sizeof(WCHAR
) );
390 if (lpDSEnumCallback(NULL
, wDesc
, wName
, lpContext
) == FALSE
)
398 for (wod
= 0; wod
< devs
; ++wod
) {
399 err
= mmErr(WineWaveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
401 TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
402 debugstr_guid(&DSOUND_renderer_guids
[wod
]),desc
.szDesc
,desc
.szDrvname
,lpContext
);
403 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1,
404 wDesc
, sizeof(wDesc
)/sizeof(WCHAR
) );
405 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1,
406 wName
, sizeof(wName
)/sizeof(WCHAR
) );
407 if (lpDSEnumCallback(&DSOUND_renderer_guids
[wod
], wDesc
, wName
, lpContext
) == FALSE
)
414 /*******************************************************************************
415 * DirectSound ClassFactory
418 static HRESULT WINAPI
419 DSCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
) {
420 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
422 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
423 return E_NOINTERFACE
;
426 static ULONG WINAPI
DSCF_AddRef(LPCLASSFACTORY iface
)
428 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
429 ULONG ref
= InterlockedIncrement(&(This
->ref
));
430 TRACE("(%p) ref was %ld\n", This
, ref
- 1);
434 static ULONG WINAPI
DSCF_Release(LPCLASSFACTORY iface
)
436 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
437 ULONG ref
= InterlockedDecrement(&(This
->ref
));
438 TRACE("(%p) ref was %ld\n", This
, ref
+ 1);
439 /* static class, won't be freed */
443 static HRESULT WINAPI
DSCF_CreateInstance(
444 LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
446 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
447 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
450 return CLASS_E_NOAGGREGATION
;
453 WARN("invalid parameter\n");
454 return DSERR_INVALIDPARAM
;
459 if ( IsEqualIID( &IID_IDirectSound
, riid
) )
460 return DSOUND_Create((LPDIRECTSOUND
*)ppobj
,pOuter
);
462 if ( IsEqualIID( &IID_IDirectSound8
, riid
) )
463 return DSOUND_Create8((LPDIRECTSOUND8
*)ppobj
,pOuter
);
465 WARN("(%p,%p,%s,%p) Interface not found!\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
466 return E_NOINTERFACE
;
469 static HRESULT WINAPI
DSCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
470 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
471 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
475 static const IClassFactoryVtbl DSCF_Vtbl
= {
483 static IClassFactoryImpl DSOUND_CF
= { &DSCF_Vtbl
, 1 };
485 /*******************************************************************************
486 * DirectSoundPrivate ClassFactory
489 static HRESULT WINAPI
490 DSPCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
) {
491 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
493 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
494 return E_NOINTERFACE
;
497 static ULONG WINAPI
DSPCF_AddRef(LPCLASSFACTORY iface
)
499 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
500 ULONG ref
= InterlockedIncrement(&(This
->ref
));
501 TRACE("(%p) ref was %ld\n", This
, ref
- 1);
505 static ULONG WINAPI
DSPCF_Release(LPCLASSFACTORY iface
)
507 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
508 ULONG ref
= InterlockedDecrement(&(This
->ref
));
509 TRACE("(%p) ref was %ld\n", This
, ref
+ 1);
510 /* static class, won't be freed */
514 static HRESULT WINAPI
515 DSPCF_CreateInstance(
516 LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
518 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
519 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
522 WARN("invalid parameter\n");
523 return DSERR_INVALIDPARAM
;
528 if ( IsEqualGUID( &IID_IKsPropertySet
, riid
) ) {
529 return IKsPrivatePropertySetImpl_Create((IKsPrivatePropertySetImpl
**)ppobj
);
532 WARN("(%p,%p,%s,%p) Interface not found!\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
533 return E_NOINTERFACE
;
536 static HRESULT WINAPI
537 DSPCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
538 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
539 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
543 static const IClassFactoryVtbl DSPCF_Vtbl
= {
544 DSPCF_QueryInterface
,
547 DSPCF_CreateInstance
,
551 static IClassFactoryImpl DSOUND_PRIVATE_CF
= { &DSPCF_Vtbl
, 1 };
553 /*******************************************************************************
554 * DllGetClassObject [DSOUND.@]
555 * Retrieves class object from a DLL object
558 * Docs say returns STDAPI
561 * rclsid [I] CLSID for the class object
562 * riid [I] Reference to identifier of interface for class object
563 * ppv [O] Address of variable to receive interface pointer for riid
567 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
570 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
572 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
575 WARN("invalid parameter\n");
581 if ( IsEqualCLSID( &CLSID_DirectSound
, rclsid
) ||
582 IsEqualCLSID( &CLSID_DirectSound8
, rclsid
) ) {
583 if ( IsEqualCLSID( &IID_IClassFactory
, riid
) ) {
584 *ppv
= (LPVOID
)&DSOUND_CF
;
585 IClassFactory_AddRef((IClassFactory
*)*ppv
);
588 WARN("(%s,%s,%p): no interface found.\n",
589 debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
593 if ( IsEqualCLSID( &CLSID_DirectSoundCapture
, rclsid
) ||
594 IsEqualCLSID( &CLSID_DirectSoundCapture8
, rclsid
) ) {
595 if ( IsEqualCLSID( &IID_IClassFactory
, riid
) ) {
596 *ppv
= (LPVOID
)&DSOUND_CAPTURE_CF
;
597 IClassFactory_AddRef((IClassFactory
*)*ppv
);
600 WARN("(%s,%s,%p): no interface found.\n",
601 debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
605 if ( IsEqualCLSID( &CLSID_DirectSoundFullDuplex
, rclsid
) ) {
606 if ( IsEqualCLSID( &IID_IClassFactory
, riid
) ) {
607 *ppv
= (LPVOID
)&DSOUND_FULLDUPLEX_CF
;
608 IClassFactory_AddRef((IClassFactory
*)*ppv
);
611 WARN("(%s,%s,%p): no interface found.\n",
612 debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
616 if ( IsEqualCLSID( &CLSID_DirectSoundPrivate
, rclsid
) ) {
617 if ( IsEqualCLSID( &IID_IClassFactory
, riid
) ) {
618 *ppv
= (LPVOID
)&DSOUND_PRIVATE_CF
;
619 IClassFactory_AddRef((IClassFactory
*)*ppv
);
622 WARN("(%s,%s,%p): no interface found.\n",
623 debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
627 WARN("(%s,%s,%p): no class found.\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
628 return CLASS_E_CLASSNOTAVAILABLE
;
632 /*******************************************************************************
633 * DllCanUnloadNow [DSOUND.4]
634 * Determines whether the DLL is in use.
640 HRESULT WINAPI
DllCanUnloadNow(void)
642 FIXME("(void): stub\n");
646 #define INIT_GUID(guid, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
647 guid.Data1 = l; guid.Data2 = w1; guid.Data3 = w2; \
648 guid.Data4[0] = b1; guid.Data4[1] = b2; guid.Data4[2] = b3; \
649 guid.Data4[3] = b4; guid.Data4[4] = b5; guid.Data4[5] = b6; \
650 guid.Data4[6] = b7; guid.Data4[7] = b8;
652 /***********************************************************************
653 * DllMain (DSOUND.init)
655 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
658 TRACE("(%p %ld %p)\n", hInstDLL
, fdwReason
, lpvReserved
);
661 case DLL_PROCESS_ATTACH
:
662 TRACE("DLL_PROCESS_ATTACH\n");
663 for (i
= 0; i
< MAXWAVEDRIVERS
; i
++) {
664 DSOUND_renderer
[i
] = NULL
;
665 DSOUND_capture
[i
] = NULL
;
666 INIT_GUID(DSOUND_renderer_guids
[i
], 0xbd6dd71a, 0x3deb, 0x11d1, 0xb1, 0x71, 0x00, 0xc0, 0x4f, 0xc2, 0x00, 0x00 + i
);
667 INIT_GUID(DSOUND_capture_guids
[i
], 0xbd6dd71b, 0x3deb, 0x11d1, 0xb1, 0x71, 0x00, 0xc0, 0x4f, 0xc2, 0x00, 0x00 + i
);
670 case DLL_PROCESS_DETACH
:
671 TRACE("DLL_PROCESS_DETACH\n");
673 case DLL_THREAD_ATTACH
:
674 TRACE("DLL_THREAD_ATTACH\n");
676 case DLL_THREAD_DETACH
:
677 TRACE("DLL_THREAD_DETACH\n");
680 TRACE("UNKNOWN REASON\n");