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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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
52 #include "wine/debug.h"
55 #include "dsound_private.h"
58 WINE_DEFAULT_DEBUG_CHANNEL(dsound
);
60 /* these are eligible for tuning... they must be high on slow machines... */
61 /* some stuff may get more responsive with lower values though... */
62 #define DS_EMULDRIVER 0 /* some games (Quake 2, UT) refuse to accept
63 emulated dsound devices. set to 0 ! */
64 #define DS_HEL_MARGIN 5 /* HEL only: number of waveOut fragments ahead to mix in new buffers
65 * (keep this close or equal to DS_HEL_QUEUE for best results) */
66 #define DS_HEL_QUEUE 5 /* HEL only: number of waveOut fragments ahead to queue to driver
67 * (this will affect HEL sound reliability and latency) */
69 #define DS_SND_QUEUE_MAX 28 /* max number of fragments to prebuffer */
70 #define DS_SND_QUEUE_MIN 12 /* min number of fragments to prebuffer */
72 DirectSoundDevice
* DSOUND_renderer
[MAXWAVEDRIVERS
];
73 GUID DSOUND_renderer_guids
[MAXWAVEDRIVERS
];
74 GUID DSOUND_capture_guids
[MAXWAVEDRIVERS
];
76 HRESULT
mmErr(UINT err
)
79 case MMSYSERR_NOERROR
:
81 case MMSYSERR_ALLOCATED
:
82 return DSERR_ALLOCATED
;
84 case MMSYSERR_INVALHANDLE
:
85 case WAVERR_STILLPLAYING
:
86 return DSERR_GENERIC
; /* FIXME */
87 case MMSYSERR_NODRIVER
:
88 return DSERR_NODRIVER
;
90 return DSERR_OUTOFMEMORY
;
91 case MMSYSERR_INVALPARAM
:
92 case WAVERR_BADFORMAT
:
93 case WAVERR_UNPREPARED
:
94 return DSERR_INVALIDPARAM
;
95 case MMSYSERR_NOTSUPPORTED
:
96 return DSERR_UNSUPPORTED
;
98 FIXME("Unknown MMSYS error %d\n",err
);
103 int ds_emuldriver
= DS_EMULDRIVER
;
104 int ds_hel_margin
= DS_HEL_MARGIN
;
105 int ds_hel_queue
= DS_HEL_QUEUE
;
106 int ds_snd_queue_max
= DS_SND_QUEUE_MAX
;
107 int ds_snd_queue_min
= DS_SND_QUEUE_MIN
;
108 int ds_hw_accel
= DS_HW_ACCEL_FULL
;
109 int ds_default_playback
= 0;
110 int ds_default_capture
= 0;
111 int ds_default_sample_rate
= 22050;
112 int ds_default_bits_per_sample
= 8;
115 * Get a config key from either the app-specific or the default config
118 inline static DWORD
get_config_key( HKEY defkey
, HKEY appkey
, const char *name
,
119 char *buffer
, DWORD size
)
121 if (appkey
&& !RegQueryValueExA( appkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
122 if (defkey
&& !RegQueryValueExA( defkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
123 return ERROR_FILE_NOT_FOUND
;
128 * Setup the dsound options.
131 void setup_dsound_options(void)
133 char buffer
[MAX_PATH
+16];
134 HKEY hkey
, appkey
= 0;
137 buffer
[MAX_PATH
]='\0';
139 /* @@ Wine registry key: HKCU\Software\Wine\DirectSound */
140 if (RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\DirectSound", &hkey
)) hkey
= 0;
142 len
= GetModuleFileNameA( 0, buffer
, MAX_PATH
);
143 if (len
&& len
< MAX_PATH
)
146 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectSound */
147 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\AppDefaults", &tmpkey
))
149 char *p
, *appname
= buffer
;
150 if ((p
= strrchr( appname
, '/' ))) appname
= p
+ 1;
151 if ((p
= strrchr( appname
, '\\' ))) appname
= p
+ 1;
152 strcat( appname
, "\\DirectSound" );
153 TRACE("appname = [%s]\n", appname
);
154 if (RegOpenKeyA( tmpkey
, appname
, &appkey
)) appkey
= 0;
155 RegCloseKey( tmpkey
);
161 if (!get_config_key( hkey
, appkey
, "EmulDriver", buffer
, MAX_PATH
))
162 ds_emuldriver
= strcmp(buffer
, "N");
164 if (!get_config_key( hkey
, appkey
, "HELmargin", buffer
, MAX_PATH
))
165 ds_hel_margin
= atoi(buffer
);
167 if (!get_config_key( hkey
, appkey
, "HELqueue", buffer
, MAX_PATH
))
168 ds_hel_queue
= atoi(buffer
);
170 if (!get_config_key( hkey
, appkey
, "SndQueueMax", buffer
, MAX_PATH
))
171 ds_snd_queue_max
= atoi(buffer
);
173 if (!get_config_key( hkey
, appkey
, "SndQueueMin", buffer
, MAX_PATH
))
174 ds_snd_queue_min
= atoi(buffer
);
176 if (!get_config_key( hkey
, appkey
, "HardwareAcceleration", buffer
, MAX_PATH
)) {
177 if (strcmp(buffer
, "Full") == 0)
178 ds_hw_accel
= DS_HW_ACCEL_FULL
;
179 else if (strcmp(buffer
, "Standard") == 0)
180 ds_hw_accel
= DS_HW_ACCEL_STANDARD
;
181 else if (strcmp(buffer
, "Basic") == 0)
182 ds_hw_accel
= DS_HW_ACCEL_BASIC
;
183 else if (strcmp(buffer
, "Emulation") == 0)
184 ds_hw_accel
= DS_HW_ACCEL_EMULATION
;
187 if (!get_config_key( hkey
, appkey
, "DefaultPlayback", buffer
, MAX_PATH
))
188 ds_default_playback
= atoi(buffer
);
190 if (!get_config_key( hkey
, appkey
, "DefaultCapture", buffer
, MAX_PATH
))
191 ds_default_capture
= atoi(buffer
);
193 if (!get_config_key( hkey
, appkey
, "DefaultSampleRate", buffer
, MAX_PATH
))
194 ds_default_sample_rate
= atoi(buffer
);
196 if (!get_config_key( hkey
, appkey
, "DefaultBitsPerSample", buffer
, MAX_PATH
))
197 ds_default_bits_per_sample
= atoi(buffer
);
199 if (appkey
) RegCloseKey( appkey
);
200 if (hkey
) RegCloseKey( hkey
);
202 if (ds_emuldriver
!= DS_EMULDRIVER
)
203 WARN("ds_emuldriver = %d (default=%d)\n",ds_emuldriver
, DS_EMULDRIVER
);
204 if (ds_hel_margin
!= DS_HEL_MARGIN
)
205 WARN("ds_hel_margin = %d (default=%d)\n",ds_hel_margin
, DS_HEL_MARGIN
);
206 if (ds_hel_queue
!= DS_HEL_QUEUE
)
207 WARN("ds_hel_queue = %d (default=%d)\n",ds_hel_queue
, DS_HEL_QUEUE
);
208 if (ds_snd_queue_max
!= DS_SND_QUEUE_MAX
)
209 WARN("ds_snd_queue_max = %d (default=%d)\n",ds_snd_queue_max
,DS_SND_QUEUE_MAX
);
210 if (ds_snd_queue_min
!= DS_SND_QUEUE_MIN
)
211 WARN("ds_snd_queue_min = %d (default=%d)\n",ds_snd_queue_min
,DS_SND_QUEUE_MIN
);
212 if (ds_hw_accel
!= DS_HW_ACCEL_FULL
)
213 WARN("ds_hw_accel = %s (default=Full)\n",
214 ds_hw_accel
==DS_HW_ACCEL_FULL
? "Full" :
215 ds_hw_accel
==DS_HW_ACCEL_STANDARD
? "Standard" :
216 ds_hw_accel
==DS_HW_ACCEL_BASIC
? "Basic" :
217 ds_hw_accel
==DS_HW_ACCEL_EMULATION
? "Emulation" :
219 if (ds_default_playback
!= 0)
220 WARN("ds_default_playback = %d (default=0)\n",ds_default_playback
);
221 if (ds_default_capture
!= 0)
222 WARN("ds_default_capture = %d (default=0)\n",ds_default_playback
);
223 if (ds_default_sample_rate
!= 22050)
224 WARN("ds_default_sample_rate = %d (default=22050)\n",ds_default_sample_rate
);
225 if (ds_default_bits_per_sample
!= 8)
226 WARN("ds_default_bits_per_sample = %d (default=8)\n",ds_default_bits_per_sample
);
229 const char * get_device_id(LPCGUID pGuid
)
231 if (IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuid
))
232 return "DSDEVID_DefaultPlayback";
233 else if (IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuid
))
234 return "DSDEVID_DefaultVoicePlayback";
235 else if (IsEqualGUID(&DSDEVID_DefaultCapture
, pGuid
))
236 return "DSDEVID_DefaultCapture";
237 else if (IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuid
))
238 return "DSDEVID_DefaultVoiceCapture";
239 return debugstr_guid(pGuid
);
242 /***************************************************************************
243 * GetDeviceID [DSOUND.9]
245 * Retrieves unique identifier of default device specified
248 * pGuidSrc [I] Address of device GUID.
249 * pGuidDest [O] Address to receive unique device GUID.
253 * Failure: DSERR_INVALIDPARAM
256 * pGuidSrc is a valid device GUID or DSDEVID_DefaultPlayback,
257 * DSDEVID_DefaultCapture, DSDEVID_DefaultVoicePlayback, or
258 * DSDEVID_DefaultVoiceCapture.
259 * Returns pGuidSrc if pGuidSrc is a valid device or the device
260 * GUID for the specified constants.
262 HRESULT WINAPI
GetDeviceID(LPCGUID pGuidSrc
, LPGUID pGuidDest
)
264 TRACE("(%s,%p)\n", get_device_id(pGuidSrc
),pGuidDest
);
266 if ( pGuidSrc
== NULL
) {
267 WARN("invalid parameter: pGuidSrc == NULL\n");
268 return DSERR_INVALIDPARAM
;
271 if ( pGuidDest
== NULL
) {
272 WARN("invalid parameter: pGuidDest == NULL\n");
273 return DSERR_INVALIDPARAM
;
276 if ( IsEqualGUID( &DSDEVID_DefaultPlayback
, pGuidSrc
) ||
277 IsEqualGUID( &DSDEVID_DefaultVoicePlayback
, pGuidSrc
) ) {
278 CopyMemory(pGuidDest
, &DSOUND_renderer_guids
[ds_default_playback
], sizeof(GUID
));
279 TRACE("returns %s\n", get_device_id(pGuidDest
));
283 if ( IsEqualGUID( &DSDEVID_DefaultCapture
, pGuidSrc
) ||
284 IsEqualGUID( &DSDEVID_DefaultVoiceCapture
, pGuidSrc
) ) {
285 CopyMemory(pGuidDest
, &DSOUND_capture_guids
[ds_default_capture
], sizeof(GUID
));
286 TRACE("returns %s\n", get_device_id(pGuidDest
));
290 CopyMemory(pGuidDest
, pGuidSrc
, sizeof(GUID
));
291 TRACE("returns %s\n", get_device_id(pGuidDest
));
297 /***************************************************************************
298 * DirectSoundEnumerateA [DSOUND.2]
300 * Enumerate all DirectSound drivers installed in the system
303 * lpDSEnumCallback [I] Address of callback function.
304 * lpContext [I] Address of user defined context passed to callback function.
308 * Failure: DSERR_INVALIDPARAM
310 HRESULT WINAPI
DirectSoundEnumerateA(
311 LPDSENUMCALLBACKA lpDSEnumCallback
,
319 TRACE("lpDSEnumCallback = %p, lpContext = %p\n",
320 lpDSEnumCallback
, lpContext
);
322 if (lpDSEnumCallback
== NULL
) {
323 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
324 return DSERR_INVALIDPARAM
;
327 devs
= waveOutGetNumDevs();
329 if (GetDeviceID(&DSDEVID_DefaultPlayback
, &guid
) == DS_OK
) {
330 for (wod
= 0; wod
< devs
; ++wod
) {
331 if (IsEqualGUID( &guid
, &DSOUND_renderer_guids
[wod
]) ) {
332 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
334 TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
335 "Primary Sound Driver",desc
.szDrvname
,lpContext
);
336 if (lpDSEnumCallback(NULL
, "Primary Sound Driver", desc
.szDrvname
, lpContext
) == FALSE
)
344 for (wod
= 0; wod
< devs
; ++wod
) {
345 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
347 TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
348 debugstr_guid(&DSOUND_renderer_guids
[wod
]),desc
.szDesc
,desc
.szDrvname
,lpContext
);
349 if (lpDSEnumCallback(&DSOUND_renderer_guids
[wod
], desc
.szDesc
, desc
.szDrvname
, lpContext
) == FALSE
)
356 /***************************************************************************
357 * DirectSoundEnumerateW [DSOUND.3]
359 * Enumerate all DirectSound drivers installed in the system
362 * lpDSEnumCallback [I] Address of callback function.
363 * lpContext [I] Address of user defined context passed to callback function.
367 * Failure: DSERR_INVALIDPARAM
369 HRESULT WINAPI
DirectSoundEnumerateW(
370 LPDSENUMCALLBACKW lpDSEnumCallback
,
377 WCHAR wDesc
[MAXPNAMELEN
];
378 WCHAR wName
[MAXPNAMELEN
];
380 TRACE("lpDSEnumCallback = %p, lpContext = %p\n",
381 lpDSEnumCallback
, lpContext
);
383 if (lpDSEnumCallback
== NULL
) {
384 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
385 return DSERR_INVALIDPARAM
;
388 devs
= waveOutGetNumDevs();
390 if (GetDeviceID(&DSDEVID_DefaultPlayback
, &guid
) == DS_OK
) {
391 for (wod
= 0; wod
< devs
; ++wod
) {
392 if (IsEqualGUID( &guid
, &DSOUND_renderer_guids
[wod
] ) ) {
393 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
395 TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
396 "Primary Sound Driver",desc
.szDrvname
,lpContext
);
397 MultiByteToWideChar( CP_ACP
, 0, "Primary Sound Driver", -1,
398 wDesc
, sizeof(wDesc
)/sizeof(WCHAR
) );
399 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1,
400 wName
, sizeof(wName
)/sizeof(WCHAR
) );
401 if (lpDSEnumCallback(NULL
, wDesc
, wName
, lpContext
) == FALSE
)
409 for (wod
= 0; wod
< devs
; ++wod
) {
410 err
= mmErr(waveOutMessage((HWAVEOUT
)wod
,DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
412 TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
413 debugstr_guid(&DSOUND_renderer_guids
[wod
]),desc
.szDesc
,desc
.szDrvname
,lpContext
);
414 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1,
415 wDesc
, sizeof(wDesc
)/sizeof(WCHAR
) );
416 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1,
417 wName
, sizeof(wName
)/sizeof(WCHAR
) );
418 if (lpDSEnumCallback(&DSOUND_renderer_guids
[wod
], wDesc
, wName
, lpContext
) == FALSE
)
425 /*******************************************************************************
426 * DirectSound ClassFactory
429 static HRESULT WINAPI
430 DSCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
) {
431 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
433 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
434 return E_NOINTERFACE
;
437 static ULONG WINAPI
DSCF_AddRef(LPCLASSFACTORY iface
)
439 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
440 ULONG ref
= InterlockedIncrement(&(This
->ref
));
441 TRACE("(%p) ref was %ld\n", This
, ref
- 1);
445 static ULONG WINAPI
DSCF_Release(LPCLASSFACTORY iface
)
447 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
448 ULONG ref
= InterlockedDecrement(&(This
->ref
));
449 TRACE("(%p) ref was %ld\n", This
, ref
+ 1);
450 /* static class, won't be freed */
454 static HRESULT WINAPI
DSCF_CreateInstance(
455 LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
457 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
458 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
461 return CLASS_E_NOAGGREGATION
;
464 WARN("invalid parameter\n");
465 return DSERR_INVALIDPARAM
;
470 if ( IsEqualIID( &IID_IDirectSound
, riid
) )
471 return DSOUND_Create((LPDIRECTSOUND
*)ppobj
,pOuter
);
473 if ( IsEqualIID( &IID_IDirectSound8
, riid
) )
474 return DSOUND_Create8((LPDIRECTSOUND8
*)ppobj
,pOuter
);
476 WARN("(%p,%p,%s,%p) Interface not found!\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
477 return E_NOINTERFACE
;
480 static HRESULT WINAPI
DSCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
481 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
482 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
486 static const IClassFactoryVtbl DSCF_Vtbl
= {
494 static IClassFactoryImpl DSOUND_CF
= { &DSCF_Vtbl
, 1 };
496 /*******************************************************************************
497 * DirectSoundPrivate ClassFactory
500 static HRESULT WINAPI
501 DSPCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
) {
502 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
504 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
505 return E_NOINTERFACE
;
508 static ULONG WINAPI
DSPCF_AddRef(LPCLASSFACTORY iface
)
510 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
511 ULONG ref
= InterlockedIncrement(&(This
->ref
));
512 TRACE("(%p) ref was %ld\n", This
, ref
- 1);
516 static ULONG WINAPI
DSPCF_Release(LPCLASSFACTORY iface
)
518 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
519 ULONG ref
= InterlockedDecrement(&(This
->ref
));
520 TRACE("(%p) ref was %ld\n", This
, ref
+ 1);
521 /* static class, won't be freed */
525 static HRESULT WINAPI
526 DSPCF_CreateInstance(
527 LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
529 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
530 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
533 WARN("invalid parameter\n");
534 return DSERR_INVALIDPARAM
;
539 if ( IsEqualGUID( &IID_IKsPropertySet
, riid
) ) {
540 return IKsPrivatePropertySetImpl_Create((IKsPrivatePropertySetImpl
**)ppobj
);
543 WARN("(%p,%p,%s,%p) Interface not found!\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
544 return E_NOINTERFACE
;
547 static HRESULT WINAPI
548 DSPCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
549 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
550 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
554 static const IClassFactoryVtbl DSPCF_Vtbl
= {
555 DSPCF_QueryInterface
,
558 DSPCF_CreateInstance
,
562 static IClassFactoryImpl DSOUND_PRIVATE_CF
= { &DSPCF_Vtbl
, 1 };
564 /*******************************************************************************
565 * DllGetClassObject [DSOUND.@]
566 * Retrieves class object from a DLL object
569 * Docs say returns STDAPI
572 * rclsid [I] CLSID for the class object
573 * riid [I] Reference to identifier of interface for class object
574 * ppv [O] Address of variable to receive interface pointer for riid
578 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
581 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
583 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
586 WARN("invalid parameter\n");
592 if ( IsEqualCLSID( &CLSID_DirectSound
, rclsid
) ||
593 IsEqualCLSID( &CLSID_DirectSound8
, rclsid
) ) {
594 if ( IsEqualCLSID( &IID_IClassFactory
, riid
) ) {
595 *ppv
= (LPVOID
)&DSOUND_CF
;
596 IClassFactory_AddRef((IClassFactory
*)*ppv
);
599 WARN("(%s,%s,%p): no interface found.\n",
600 debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
604 if ( IsEqualCLSID( &CLSID_DirectSoundCapture
, rclsid
) ||
605 IsEqualCLSID( &CLSID_DirectSoundCapture8
, rclsid
) ) {
606 if ( IsEqualCLSID( &IID_IClassFactory
, riid
) ) {
607 *ppv
= (LPVOID
)&DSOUND_CAPTURE_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_DirectSoundFullDuplex
, rclsid
) ) {
617 if ( IsEqualCLSID( &IID_IClassFactory
, riid
) ) {
618 *ppv
= (LPVOID
)&DSOUND_FULLDUPLEX_CF
;
619 IClassFactory_AddRef((IClassFactory
*)*ppv
);
622 WARN("(%s,%s,%p): no interface found.\n",
623 debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
627 if ( IsEqualCLSID( &CLSID_DirectSoundPrivate
, rclsid
) ) {
628 if ( IsEqualCLSID( &IID_IClassFactory
, riid
) ) {
629 *ppv
= (LPVOID
)&DSOUND_PRIVATE_CF
;
630 IClassFactory_AddRef((IClassFactory
*)*ppv
);
633 WARN("(%s,%s,%p): no interface found.\n",
634 debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
638 WARN("(%s,%s,%p): no class found.\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
639 return CLASS_E_CLASSNOTAVAILABLE
;
643 /*******************************************************************************
644 * DllCanUnloadNow [DSOUND.4]
645 * Determines whether the DLL is in use.
651 HRESULT WINAPI
DllCanUnloadNow(void)
653 FIXME("(void): stub\n");
657 #define INIT_GUID(guid, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
658 guid.Data1 = l; guid.Data2 = w1; guid.Data3 = w2; \
659 guid.Data4[0] = b1; guid.Data4[1] = b2; guid.Data4[2] = b3; \
660 guid.Data4[3] = b4; guid.Data4[4] = b5; guid.Data4[5] = b6; \
661 guid.Data4[6] = b7; guid.Data4[7] = b8;
663 /***********************************************************************
664 * DllMain (DSOUND.init)
666 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
669 TRACE("(%p %ld %p)\n", hInstDLL
, fdwReason
, lpvReserved
);
672 case DLL_PROCESS_ATTACH
:
673 TRACE("DLL_PROCESS_ATTACH\n");
674 for (i
= 0; i
< MAXWAVEDRIVERS
; i
++) {
675 DSOUND_renderer
[i
] = NULL
;
676 DSOUND_capture
[i
] = NULL
;
677 INIT_GUID(DSOUND_renderer_guids
[i
], 0xbd6dd71a, 0x3deb, 0x11d1, 0xb1, 0x71, 0x00, 0xc0, 0x4f, 0xc2, 0x00, 0x00 + i
);
678 INIT_GUID(DSOUND_capture_guids
[i
], 0xbd6dd71b, 0x3deb, 0x11d1, 0xb1, 0x71, 0x00, 0xc0, 0x4f, 0xc2, 0x00, 0x00 + i
);
681 case DLL_PROCESS_DETACH
:
682 TRACE("DLL_PROCESS_DETACH\n");
684 case DLL_THREAD_ATTACH
:
685 TRACE("DLL_THREAD_ATTACH\n");
687 case DLL_THREAD_DETACH
:
688 TRACE("DLL_THREAD_DETACH\n");
691 TRACE("UNKNOWN REASON\n");