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
21 * Most thread locking is complete. There may be a few race
22 * conditions still lurking.
25 * Implement SetCooperativeLevel properly (need to address focus issues)
26 * Implement DirectSound3DBuffers (stubs in place)
27 * Use hardware 3D support if available
28 * Add critical section locking inside Release and AddRef methods
29 * Handle static buffers - put those in hardware, non-static not in hardware
30 * Hardware DuplicateSoundBuffer
31 * Proper volume calculation for 3d buffers
32 * Remove DS_HEL_FRAGS and use mixer fragment length for it
38 #define NONAMELESSSTRUCT
39 #define NONAMELESSUNION
48 #include "wine/debug.h"
64 #include "dsound_private.h"
66 WINE_DEFAULT_DEBUG_CHANNEL(dsound
);
68 struct list DSOUND_renderers
= LIST_INIT(DSOUND_renderers
);
69 CRITICAL_SECTION DSOUND_renderers_lock
;
70 static CRITICAL_SECTION_DEBUG DSOUND_renderers_lock_debug
=
72 0, 0, &DSOUND_renderers_lock
,
73 { &DSOUND_renderers_lock_debug
.ProcessLocksList
, &DSOUND_renderers_lock_debug
.ProcessLocksList
},
74 0, 0, { (DWORD_PTR
)(__FILE__
": DSOUND_renderers_lock") }
76 CRITICAL_SECTION DSOUND_renderers_lock
= { &DSOUND_renderers_lock_debug
, -1, 0, 0, 0, 0 };
78 struct list DSOUND_capturers
= LIST_INIT(DSOUND_capturers
);
79 CRITICAL_SECTION DSOUND_capturers_lock
;
80 static CRITICAL_SECTION_DEBUG DSOUND_capturers_lock_debug
=
82 0, 0, &DSOUND_capturers_lock
,
83 { &DSOUND_capturers_lock_debug
.ProcessLocksList
, &DSOUND_capturers_lock_debug
.ProcessLocksList
},
84 0, 0, { (DWORD_PTR
)(__FILE__
": DSOUND_capturers_lock") }
86 CRITICAL_SECTION DSOUND_capturers_lock
= { &DSOUND_capturers_lock_debug
, -1, 0, 0, 0, 0 };
88 GUID DSOUND_renderer_guids
[MAXWAVEDRIVERS
];
89 GUID DSOUND_capture_guids
[MAXWAVEDRIVERS
];
91 WCHAR wine_vxd_drv
[] = { 'w','i','n','e','m','m','.','v','x','d', 0 };
93 /* All default settings, you most likely don't want to touch these, see wiki on UsefulRegistryKeys */
94 int ds_hel_buflen
= 32768 * 2;
95 int ds_snd_queue_max
= 10;
96 int ds_default_sample_rate
= 44100;
97 int ds_default_bits_per_sample
= 16;
98 static HINSTANCE instance
;
101 * Get a config key from either the app-specific or the default config
104 static inline DWORD
get_config_key( HKEY defkey
, HKEY appkey
, const char *name
,
105 char *buffer
, DWORD size
)
107 if (appkey
&& !RegQueryValueExA( appkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
108 if (defkey
&& !RegQueryValueExA( defkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
109 return ERROR_FILE_NOT_FOUND
;
114 * Setup the dsound options.
117 void setup_dsound_options(void)
119 char buffer
[MAX_PATH
+16];
120 HKEY hkey
, appkey
= 0;
123 buffer
[MAX_PATH
]='\0';
125 /* @@ Wine registry key: HKCU\Software\Wine\DirectSound */
126 if (RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\DirectSound", &hkey
)) hkey
= 0;
128 len
= GetModuleFileNameA( 0, buffer
, MAX_PATH
);
129 if (len
&& len
< MAX_PATH
)
132 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectSound */
133 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\AppDefaults", &tmpkey
))
135 char *p
, *appname
= buffer
;
136 if ((p
= strrchr( appname
, '/' ))) appname
= p
+ 1;
137 if ((p
= strrchr( appname
, '\\' ))) appname
= p
+ 1;
138 strcat( appname
, "\\DirectSound" );
139 TRACE("appname = [%s]\n", appname
);
140 if (RegOpenKeyA( tmpkey
, appname
, &appkey
)) appkey
= 0;
141 RegCloseKey( tmpkey
);
147 if (!get_config_key( hkey
, appkey
, "HelBuflen", buffer
, MAX_PATH
))
148 ds_hel_buflen
= atoi(buffer
);
150 if (!get_config_key( hkey
, appkey
, "SndQueueMax", buffer
, MAX_PATH
))
151 ds_snd_queue_max
= atoi(buffer
);
154 if (!get_config_key( hkey
, appkey
, "DefaultSampleRate", buffer
, MAX_PATH
))
155 ds_default_sample_rate
= atoi(buffer
);
157 if (!get_config_key( hkey
, appkey
, "DefaultBitsPerSample", buffer
, MAX_PATH
))
158 ds_default_bits_per_sample
= atoi(buffer
);
160 if (appkey
) RegCloseKey( appkey
);
161 if (hkey
) RegCloseKey( hkey
);
163 TRACE("ds_hel_buflen = %d\n", ds_hel_buflen
);
164 TRACE("ds_snd_queue_max = %d\n", ds_snd_queue_max
);
165 TRACE("ds_default_sample_rate = %d\n", ds_default_sample_rate
);
166 TRACE("ds_default_bits_per_sample = %d\n", ds_default_bits_per_sample
);
169 static const char * get_device_id(LPCGUID pGuid
)
171 if (IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuid
))
172 return "DSDEVID_DefaultPlayback";
173 else if (IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuid
))
174 return "DSDEVID_DefaultVoicePlayback";
175 else if (IsEqualGUID(&DSDEVID_DefaultCapture
, pGuid
))
176 return "DSDEVID_DefaultCapture";
177 else if (IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuid
))
178 return "DSDEVID_DefaultVoiceCapture";
179 return debugstr_guid(pGuid
);
182 static HRESULT
get_mmdevenum(IMMDeviceEnumerator
**devenum
)
186 init_hr
= CoInitialize(NULL
);
188 hr
= CoCreateInstance(&CLSID_MMDeviceEnumerator
, NULL
,
189 CLSCTX_INPROC_SERVER
, &IID_IMMDeviceEnumerator
, (void**)devenum
);
193 ERR("CoCreateInstance failed: %08x\n", hr
);
200 static void release_mmdevenum(IMMDeviceEnumerator
*devenum
, HRESULT init_hr
)
202 IMMDeviceEnumerator_Release(devenum
);
203 if(SUCCEEDED(init_hr
))
207 static HRESULT
get_mmdevice_guid(IMMDevice
*device
, IPropertyStore
*ps
,
214 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
216 WARN("OpenPropertyStore failed: %08x\n", hr
);
220 IPropertyStore_AddRef(ps
);
222 PropVariantInit(&pv
);
224 hr
= IPropertyStore_GetValue(ps
, &PKEY_AudioEndpoint_GUID
, &pv
);
226 IPropertyStore_Release(ps
);
227 WARN("GetValue(GUID) failed: %08x\n", hr
);
231 CLSIDFromString(pv
.u
.pwszVal
, guid
);
233 PropVariantClear(&pv
);
234 IPropertyStore_Release(ps
);
239 /***************************************************************************
240 * GetDeviceID [DSOUND.9]
242 * Retrieves unique identifier of default device specified
245 * pGuidSrc [I] Address of device GUID.
246 * pGuidDest [O] Address to receive unique device GUID.
250 * Failure: DSERR_INVALIDPARAM
253 * pGuidSrc is a valid device GUID or DSDEVID_DefaultPlayback,
254 * DSDEVID_DefaultCapture, DSDEVID_DefaultVoicePlayback, or
255 * DSDEVID_DefaultVoiceCapture.
256 * Returns pGuidSrc if pGuidSrc is a valid device or the device
257 * GUID for the specified constants.
259 HRESULT WINAPI
GetDeviceID(LPCGUID pGuidSrc
, LPGUID pGuidDest
)
261 IMMDeviceEnumerator
*devenum
;
262 EDataFlow flow
= (EDataFlow
)-1;
263 ERole role
= (ERole
)-1;
266 TRACE("(%s,%p)\n", get_device_id(pGuidSrc
),pGuidDest
);
268 if(!pGuidSrc
|| !pGuidDest
)
269 return DSERR_INVALIDPARAM
;
271 init_hr
= get_mmdevenum(&devenum
);
275 if(IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuidSrc
)){
278 }else if(IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuidSrc
)){
279 role
= eCommunications
;
281 }else if(IsEqualGUID(&DSDEVID_DefaultCapture
, pGuidSrc
)){
284 }else if(IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuidSrc
)){
285 role
= eCommunications
;
289 if(role
!= (ERole
)-1 && flow
!= (EDataFlow
)-1){
292 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
,
293 flow
, role
, &device
);
295 WARN("GetDefaultAudioEndpoint failed: %08x\n", hr
);
296 release_mmdevenum(devenum
, init_hr
);
297 return DSERR_NODRIVER
;
300 hr
= get_mmdevice_guid(device
, NULL
, pGuidDest
);
301 IMMDevice_Release(device
);
303 release_mmdevenum(devenum
, init_hr
);
305 return (hr
== S_OK
) ? DS_OK
: hr
;
308 release_mmdevenum(devenum
, init_hr
);
310 *pGuidDest
= *pGuidSrc
;
317 LPDSENUMCALLBACKA callA
;
321 static BOOL CALLBACK
a_to_w_callback(LPGUID guid
, LPCWSTR descW
, LPCWSTR modW
, LPVOID data
)
323 struct morecontext
*context
= data
;
324 char descA
[MAXPNAMELEN
], modA
[MAXPNAMELEN
];
326 WideCharToMultiByte(CP_ACP
, 0, descW
, -1, descA
, sizeof(descA
), NULL
, NULL
);
327 WideCharToMultiByte(CP_ACP
, 0, modW
, -1, modA
, sizeof(modA
), NULL
, NULL
);
329 return context
->callA(guid
, descA
, modA
, context
->data
);
332 /***************************************************************************
333 * DirectSoundEnumerateA [DSOUND.2]
335 * Enumerate all DirectSound drivers installed in the system
338 * lpDSEnumCallback [I] Address of callback function.
339 * lpContext [I] Address of user defined context passed to callback function.
343 * Failure: DSERR_INVALIDPARAM
345 HRESULT WINAPI
DirectSoundEnumerateA(
346 LPDSENUMCALLBACKA lpDSEnumCallback
,
349 struct morecontext context
;
351 if (lpDSEnumCallback
== NULL
) {
352 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
353 return DSERR_INVALIDPARAM
;
356 context
.callA
= lpDSEnumCallback
;
357 context
.data
= lpContext
;
359 return DirectSoundEnumerateW(a_to_w_callback
, &context
);
362 HRESULT
get_mmdevice(EDataFlow flow
, const GUID
*tgt
, IMMDevice
**device
)
364 IMMDeviceEnumerator
*devenum
;
365 IMMDeviceCollection
*coll
;
369 init_hr
= get_mmdevenum(&devenum
);
373 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(devenum
, flow
,
374 DEVICE_STATE_ACTIVE
, &coll
);
376 WARN("EnumAudioEndpoints failed: %08x\n", hr
);
377 release_mmdevenum(devenum
, init_hr
);
381 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
383 IMMDeviceCollection_Release(coll
);
384 release_mmdevenum(devenum
, init_hr
);
385 WARN("GetCount failed: %08x\n", hr
);
389 for(i
= 0; i
< count
; ++i
){
392 hr
= IMMDeviceCollection_Item(coll
, i
, device
);
396 hr
= get_mmdevice_guid(*device
, NULL
, &guid
);
398 IMMDevice_Release(*device
);
402 if(IsEqualGUID(&guid
, tgt
)){
403 IMMDeviceCollection_Release(coll
);
404 release_mmdevenum(devenum
, init_hr
);
408 IMMDevice_Release(*device
);
411 WARN("No device with GUID %s found!\n", wine_dbgstr_guid(tgt
));
413 IMMDeviceCollection_Release(coll
);
414 release_mmdevenum(devenum
, init_hr
);
416 return DSERR_INVALIDPARAM
;
419 static BOOL
send_device(IMMDevice
*device
, GUID
*guid
,
420 LPDSENUMCALLBACKW cb
, void *user
)
427 PropVariantInit(&pv
);
429 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
431 WARN("OpenPropertyStore failed: %08x\n", hr
);
435 hr
= get_mmdevice_guid(device
, ps
, guid
);
437 IPropertyStore_Release(ps
);
441 hr
= IPropertyStore_GetValue(ps
,
442 (const PROPERTYKEY
*)&DEVPKEY_Device_FriendlyName
, &pv
);
444 IPropertyStore_Release(ps
);
445 WARN("GetValue(FriendlyName) failed: %08x\n", hr
);
449 TRACE("Calling back with %s (%s)\n", wine_dbgstr_guid(guid
),
450 wine_dbgstr_w(pv
.u
.pwszVal
));
452 keep_going
= cb(guid
, pv
.u
.pwszVal
, wine_vxd_drv
, user
);
454 PropVariantClear(&pv
);
455 IPropertyStore_Release(ps
);
460 /* S_FALSE means the callback returned FALSE at some point
461 * S_OK means the callback always returned TRUE */
462 HRESULT
enumerate_mmdevices(EDataFlow flow
, GUID
*guids
,
463 LPDSENUMCALLBACKW cb
, void *user
)
465 IMMDeviceEnumerator
*devenum
;
466 IMMDeviceCollection
*coll
;
467 IMMDevice
*defdev
= NULL
;
472 static const WCHAR primary_desc
[] = {'P','r','i','m','a','r','y',' ',
473 'S','o','u','n','d',' ','D','r','i','v','e','r',0};
474 static const WCHAR empty_drv
[] = {0};
476 init_hr
= get_mmdevenum(&devenum
);
480 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(devenum
, flow
,
481 DEVICE_STATE_ACTIVE
, &coll
);
483 release_mmdevenum(devenum
, init_hr
);
484 WARN("EnumAudioEndpoints failed: %08x\n", hr
);
488 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
490 IMMDeviceCollection_Release(coll
);
491 release_mmdevenum(devenum
, init_hr
);
492 WARN("GetCount failed: %08x\n", hr
);
497 release_mmdevenum(devenum
, init_hr
);
501 TRACE("Calling back with NULL (%s)\n", wine_dbgstr_w(primary_desc
));
502 keep_going
= cb(NULL
, primary_desc
, empty_drv
, user
);
504 /* always send the default device first */
506 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
, flow
,
507 eMultimedia
, &defdev
);
512 keep_going
= send_device(defdev
, &guids
[0], cb
, user
);
517 for(i
= 0; keep_going
&& i
< count
; ++i
){
520 hr
= IMMDeviceCollection_Item(coll
, i
, &device
);
522 WARN("Item failed: %08x\n", hr
);
526 if(device
!= defdev
){
527 send_device(device
, &guids
[n
], cb
, user
);
531 IMMDevice_Release(device
);
535 IMMDevice_Release(defdev
);
536 IMMDeviceCollection_Release(coll
);
538 release_mmdevenum(devenum
, init_hr
);
540 return (keep_going
== TRUE
) ? S_OK
: S_FALSE
;
543 /***************************************************************************
544 * DirectSoundEnumerateW [DSOUND.3]
546 * Enumerate all DirectSound drivers installed in the system
549 * lpDSEnumCallback [I] Address of callback function.
550 * lpContext [I] Address of user defined context passed to callback function.
554 * Failure: DSERR_INVALIDPARAM
556 HRESULT WINAPI
DirectSoundEnumerateW(
557 LPDSENUMCALLBACKW lpDSEnumCallback
,
562 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
564 if (lpDSEnumCallback
== NULL
) {
565 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
566 return DSERR_INVALIDPARAM
;
569 setup_dsound_options();
571 hr
= enumerate_mmdevices(eRender
, DSOUND_renderer_guids
,
572 lpDSEnumCallback
, lpContext
);
573 return SUCCEEDED(hr
) ? DS_OK
: hr
;
576 /***************************************************************************
577 * DirectSoundCaptureEnumerateA [DSOUND.7]
579 * Enumerate all DirectSound drivers installed in the system.
582 * lpDSEnumCallback [I] Address of callback function.
583 * lpContext [I] Address of user defined context passed to callback function.
587 * Failure: DSERR_INVALIDPARAM
589 HRESULT WINAPI
DirectSoundCaptureEnumerateA(
590 LPDSENUMCALLBACKA lpDSEnumCallback
,
593 struct morecontext context
;
595 if (lpDSEnumCallback
== NULL
) {
596 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
597 return DSERR_INVALIDPARAM
;
600 context
.callA
= lpDSEnumCallback
;
601 context
.data
= lpContext
;
603 return DirectSoundCaptureEnumerateW(a_to_w_callback
, &context
);
606 /***************************************************************************
607 * DirectSoundCaptureEnumerateW [DSOUND.8]
609 * Enumerate all DirectSound drivers installed in the system.
612 * lpDSEnumCallback [I] Address of callback function.
613 * lpContext [I] Address of user defined context passed to callback function.
617 * Failure: DSERR_INVALIDPARAM
620 DirectSoundCaptureEnumerateW(
621 LPDSENUMCALLBACKW lpDSEnumCallback
,
626 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
628 if (lpDSEnumCallback
== NULL
) {
629 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
630 return DSERR_INVALIDPARAM
;
633 setup_dsound_options();
635 hr
= enumerate_mmdevices(eCapture
, DSOUND_capture_guids
,
636 lpDSEnumCallback
, lpContext
);
637 return SUCCEEDED(hr
) ? DS_OK
: hr
;
640 /*******************************************************************************
641 * DirectSound ClassFactory
644 typedef HRESULT (*FnCreateInstance
)(REFIID riid
, LPVOID
*ppobj
);
647 IClassFactory IClassFactory_iface
;
649 FnCreateInstance pfnCreateInstance
;
652 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
654 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
657 static HRESULT WINAPI
658 DSCF_QueryInterface(LPCLASSFACTORY iface
, REFIID riid
, LPVOID
*ppobj
)
660 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
661 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppobj
);
664 if (IsEqualIID(riid
, &IID_IUnknown
) ||
665 IsEqualIID(riid
, &IID_IClassFactory
))
668 IUnknown_AddRef(iface
);
672 return E_NOINTERFACE
;
675 static ULONG WINAPI
DSCF_AddRef(LPCLASSFACTORY iface
)
680 static ULONG WINAPI
DSCF_Release(LPCLASSFACTORY iface
)
682 /* static class, won't be freed */
686 static HRESULT WINAPI
DSCF_CreateInstance(
687 LPCLASSFACTORY iface
,
692 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
693 TRACE("(%p, %p, %s, %p)\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
696 return CLASS_E_NOAGGREGATION
;
699 WARN("invalid parameter\n");
700 return DSERR_INVALIDPARAM
;
703 return This
->pfnCreateInstance(riid
, ppobj
);
706 static HRESULT WINAPI
DSCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
708 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
709 FIXME("(%p, %d) stub!\n", This
, dolock
);
713 static const IClassFactoryVtbl DSCF_Vtbl
= {
721 static IClassFactoryImpl DSOUND_CF
[] = {
722 { { &DSCF_Vtbl
}, &CLSID_DirectSound
, (FnCreateInstance
)DSOUND_Create
},
723 { { &DSCF_Vtbl
}, &CLSID_DirectSound8
, (FnCreateInstance
)DSOUND_Create8
},
724 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture
, (FnCreateInstance
)DSOUND_CaptureCreate
},
725 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture8
, (FnCreateInstance
)DSOUND_CaptureCreate8
},
726 { { &DSCF_Vtbl
}, &CLSID_DirectSoundFullDuplex
, (FnCreateInstance
)DSOUND_FullDuplexCreate
},
727 { { &DSCF_Vtbl
}, &CLSID_DirectSoundPrivate
, (FnCreateInstance
)IKsPrivatePropertySetImpl_Create
},
728 { { NULL
}, NULL
, NULL
}
731 /*******************************************************************************
732 * DllGetClassObject [DSOUND.@]
733 * Retrieves class object from a DLL object
736 * Docs say returns STDAPI
739 * rclsid [I] CLSID for the class object
740 * riid [I] Reference to identifier of interface for class object
741 * ppv [O] Address of variable to receive interface pointer for riid
745 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
748 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
751 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
754 WARN("invalid parameter\n");
760 if (!IsEqualIID(riid
, &IID_IClassFactory
) &&
761 !IsEqualIID(riid
, &IID_IUnknown
)) {
762 WARN("no interface for %s\n", debugstr_guid(riid
));
763 return E_NOINTERFACE
;
766 while (NULL
!= DSOUND_CF
[i
].rclsid
) {
767 if (IsEqualGUID(rclsid
, DSOUND_CF
[i
].rclsid
)) {
768 DSCF_AddRef(&DSOUND_CF
[i
].IClassFactory_iface
);
769 *ppv
= &DSOUND_CF
[i
];
775 WARN("(%s, %s, %p): no class found.\n", debugstr_guid(rclsid
),
776 debugstr_guid(riid
), ppv
);
777 return CLASS_E_CLASSNOTAVAILABLE
;
781 /*******************************************************************************
782 * DllCanUnloadNow [DSOUND.4]
783 * Determines whether the DLL is in use.
786 * Can unload now: S_OK
787 * Cannot unload now (the DLL is still active): S_FALSE
789 HRESULT WINAPI
DllCanUnloadNow(void)
794 #define INIT_GUID(guid, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
795 guid.Data1 = l; guid.Data2 = w1; guid.Data3 = w2; \
796 guid.Data4[0] = b1; guid.Data4[1] = b2; guid.Data4[2] = b3; \
797 guid.Data4[3] = b4; guid.Data4[4] = b5; guid.Data4[5] = b6; \
798 guid.Data4[6] = b7; guid.Data4[7] = b8;
800 /***********************************************************************
801 * DllMain (DSOUND.init)
803 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
805 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpvReserved
);
808 case DLL_PROCESS_ATTACH
:
809 TRACE("DLL_PROCESS_ATTACH\n");
811 DisableThreadLibraryCalls(hInstDLL
);
812 /* Increase refcount on dsound by 1 */
813 GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
, (LPCWSTR
)hInstDLL
, &hInstDLL
);
815 case DLL_PROCESS_DETACH
:
816 TRACE("DLL_PROCESS_DETACH\n");
817 DeleteCriticalSection(&DSOUND_renderers_lock
);
818 DeleteCriticalSection(&DSOUND_capturers_lock
);
821 TRACE("UNKNOWN REASON\n");
827 /***********************************************************************
828 * DllRegisterServer (DSOUND.@)
830 HRESULT WINAPI
DllRegisterServer(void)
832 return __wine_register_resources( instance
);
835 /***********************************************************************
836 * DllUnregisterServer (DSOUND.@)
838 HRESULT WINAPI
DllUnregisterServer(void)
840 return __wine_unregister_resources( instance
);