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
35 #include "dsound_private.h"
40 struct list DSOUND_renderers
= LIST_INIT(DSOUND_renderers
);
41 CRITICAL_SECTION DSOUND_renderers_lock
;
42 static CRITICAL_SECTION_DEBUG DSOUND_renderers_lock_debug
=
44 0, 0, &DSOUND_renderers_lock
,
45 { &DSOUND_renderers_lock_debug
.ProcessLocksList
, &DSOUND_renderers_lock_debug
.ProcessLocksList
},
46 0, 0, { (DWORD_PTR
)(__FILE__
": DSOUND_renderers_lock") }
48 CRITICAL_SECTION DSOUND_renderers_lock
= { &DSOUND_renderers_lock_debug
, -1, 0, 0, 0, 0 };
50 struct list DSOUND_capturers
= LIST_INIT(DSOUND_capturers
);
51 CRITICAL_SECTION DSOUND_capturers_lock
;
52 static CRITICAL_SECTION_DEBUG DSOUND_capturers_lock_debug
=
54 0, 0, &DSOUND_capturers_lock
,
55 { &DSOUND_capturers_lock_debug
.ProcessLocksList
, &DSOUND_capturers_lock_debug
.ProcessLocksList
},
56 0, 0, { (DWORD_PTR
)(__FILE__
": DSOUND_capturers_lock") }
58 CRITICAL_SECTION DSOUND_capturers_lock
= { &DSOUND_capturers_lock_debug
, -1, 0, 0, 0, 0 };
60 GUID DSOUND_renderer_guids
[MAXWAVEDRIVERS
];
61 GUID DSOUND_capture_guids
[MAXWAVEDRIVERS
];
63 WCHAR wine_vxd_drv
[] = { 'w','i','n','e','m','m','.','v','x','d', 0 };
65 /* All default settings, you most likely don't want to touch these, see wiki on UsefulRegistryKeys */
66 int ds_hel_buflen
= 32768 * 2;
67 int ds_snd_queue_max
= 10;
68 static HINSTANCE instance
;
71 * Get a config key from either the app-specific or the default config
74 static inline DWORD
get_config_key( HKEY defkey
, HKEY appkey
, const char *name
,
75 char *buffer
, DWORD size
)
77 if (appkey
&& !RegQueryValueExA( appkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
78 if (defkey
&& !RegQueryValueExA( defkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
79 return ERROR_FILE_NOT_FOUND
;
84 * Setup the dsound options.
87 void setup_dsound_options(void)
89 char buffer
[MAX_PATH
+16];
90 HKEY hkey
, appkey
= 0;
93 buffer
[MAX_PATH
]='\0';
95 /* @@ Wine registry key: HKCU\Software\Wine\DirectSound */
96 if (RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\DirectSound", &hkey
)) hkey
= 0;
98 len
= GetModuleFileNameA( 0, buffer
, MAX_PATH
);
99 if (len
&& len
< MAX_PATH
)
102 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectSound */
103 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\AppDefaults", &tmpkey
))
105 char *p
, *appname
= buffer
;
106 if ((p
= strrchr( appname
, '/' ))) appname
= p
+ 1;
107 if ((p
= strrchr( appname
, '\\' ))) appname
= p
+ 1;
108 strcat( appname
, "\\DirectSound" );
109 TRACE("appname = [%s]\n", appname
);
110 if (RegOpenKeyA( tmpkey
, appname
, &appkey
)) appkey
= 0;
111 RegCloseKey( tmpkey
);
117 if (!get_config_key( hkey
, appkey
, "HelBuflen", buffer
, MAX_PATH
))
118 ds_hel_buflen
= atoi(buffer
);
120 if (!get_config_key( hkey
, appkey
, "SndQueueMax", buffer
, MAX_PATH
))
121 ds_snd_queue_max
= atoi(buffer
);
124 if (appkey
) RegCloseKey( appkey
);
125 if (hkey
) RegCloseKey( hkey
);
127 TRACE("ds_hel_buflen = %d\n", ds_hel_buflen
);
128 TRACE("ds_snd_queue_max = %d\n", ds_snd_queue_max
);
131 static const char * get_device_id(LPCGUID pGuid
)
133 if (IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuid
))
134 return "DSDEVID_DefaultPlayback";
135 else if (IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuid
))
136 return "DSDEVID_DefaultVoicePlayback";
137 else if (IsEqualGUID(&DSDEVID_DefaultCapture
, pGuid
))
138 return "DSDEVID_DefaultCapture";
139 else if (IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuid
))
140 return "DSDEVID_DefaultVoiceCapture";
141 return debugstr_guid(pGuid
);
144 static HRESULT
get_mmdevenum(IMMDeviceEnumerator
**devenum
)
148 init_hr
= CoInitialize(NULL
);
150 hr
= CoCreateInstance(&CLSID_MMDeviceEnumerator
, NULL
,
151 CLSCTX_INPROC_SERVER
, &IID_IMMDeviceEnumerator
, (void**)devenum
);
153 if(SUCCEEDED(init_hr
))
156 ERR("CoCreateInstance failed: %08x\n", hr
);
163 static void release_mmdevenum(IMMDeviceEnumerator
*devenum
, HRESULT init_hr
)
165 IMMDeviceEnumerator_Release(devenum
);
166 if(SUCCEEDED(init_hr
))
170 static HRESULT
get_mmdevice_guid(IMMDevice
*device
, IPropertyStore
*ps
,
177 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
179 WARN("OpenPropertyStore failed: %08x\n", hr
);
183 IPropertyStore_AddRef(ps
);
185 PropVariantInit(&pv
);
187 hr
= IPropertyStore_GetValue(ps
, &PKEY_AudioEndpoint_GUID
, &pv
);
189 IPropertyStore_Release(ps
);
190 WARN("GetValue(GUID) failed: %08x\n", hr
);
194 CLSIDFromString(pv
.u
.pwszVal
, guid
);
196 PropVariantClear(&pv
);
197 IPropertyStore_Release(ps
);
202 /***************************************************************************
203 * GetDeviceID [DSOUND.9]
205 * Retrieves unique identifier of default device specified
208 * pGuidSrc [I] Address of device GUID.
209 * pGuidDest [O] Address to receive unique device GUID.
213 * Failure: DSERR_INVALIDPARAM
216 * pGuidSrc is a valid device GUID or DSDEVID_DefaultPlayback,
217 * DSDEVID_DefaultCapture, DSDEVID_DefaultVoicePlayback, or
218 * DSDEVID_DefaultVoiceCapture.
219 * Returns pGuidSrc if pGuidSrc is a valid device or the device
220 * GUID for the specified constants.
222 HRESULT WINAPI
GetDeviceID(LPCGUID pGuidSrc
, LPGUID pGuidDest
)
224 IMMDeviceEnumerator
*devenum
;
225 EDataFlow flow
= (EDataFlow
)-1;
226 ERole role
= (ERole
)-1;
229 TRACE("(%s,%p)\n", get_device_id(pGuidSrc
),pGuidDest
);
231 if(!pGuidSrc
|| !pGuidDest
)
232 return DSERR_INVALIDPARAM
;
234 init_hr
= get_mmdevenum(&devenum
);
238 if(IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuidSrc
)){
241 }else if(IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuidSrc
)){
242 role
= eCommunications
;
244 }else if(IsEqualGUID(&DSDEVID_DefaultCapture
, pGuidSrc
)){
247 }else if(IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuidSrc
)){
248 role
= eCommunications
;
252 if(role
!= (ERole
)-1 && flow
!= (EDataFlow
)-1){
255 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
,
256 flow
, role
, &device
);
258 WARN("GetDefaultAudioEndpoint failed: %08x\n", hr
);
259 release_mmdevenum(devenum
, init_hr
);
260 return DSERR_NODRIVER
;
263 hr
= get_mmdevice_guid(device
, NULL
, pGuidDest
);
264 IMMDevice_Release(device
);
266 release_mmdevenum(devenum
, init_hr
);
268 return (hr
== S_OK
) ? DS_OK
: hr
;
271 release_mmdevenum(devenum
, init_hr
);
273 *pGuidDest
= *pGuidSrc
;
280 LPDSENUMCALLBACKA callA
;
284 static BOOL CALLBACK
a_to_w_callback(LPGUID guid
, LPCWSTR descW
, LPCWSTR modW
, LPVOID data
)
286 struct morecontext
*context
= data
;
287 char descA
[MAXPNAMELEN
], modA
[MAXPNAMELEN
];
289 WideCharToMultiByte(CP_ACP
, 0, descW
, -1, descA
, sizeof(descA
), NULL
, NULL
);
290 WideCharToMultiByte(CP_ACP
, 0, modW
, -1, modA
, sizeof(modA
), NULL
, NULL
);
292 return context
->callA(guid
, descA
, modA
, context
->data
);
295 /***************************************************************************
296 * DirectSoundEnumerateA [DSOUND.2]
298 * Enumerate all DirectSound drivers installed in the system
301 * lpDSEnumCallback [I] Address of callback function.
302 * lpContext [I] Address of user defined context passed to callback function.
306 * Failure: DSERR_INVALIDPARAM
308 HRESULT WINAPI
DirectSoundEnumerateA(
309 LPDSENUMCALLBACKA lpDSEnumCallback
,
312 struct morecontext context
;
314 if (lpDSEnumCallback
== NULL
) {
315 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
316 return DSERR_INVALIDPARAM
;
319 context
.callA
= lpDSEnumCallback
;
320 context
.data
= lpContext
;
322 return DirectSoundEnumerateW(a_to_w_callback
, &context
);
325 HRESULT
get_mmdevice(EDataFlow flow
, const GUID
*tgt
, IMMDevice
**device
)
327 IMMDeviceEnumerator
*devenum
;
328 IMMDeviceCollection
*coll
;
332 init_hr
= get_mmdevenum(&devenum
);
336 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(devenum
, flow
,
337 DEVICE_STATE_ACTIVE
, &coll
);
339 WARN("EnumAudioEndpoints failed: %08x\n", hr
);
340 release_mmdevenum(devenum
, init_hr
);
344 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
346 IMMDeviceCollection_Release(coll
);
347 release_mmdevenum(devenum
, init_hr
);
348 WARN("GetCount failed: %08x\n", hr
);
352 for(i
= 0; i
< count
; ++i
){
355 hr
= IMMDeviceCollection_Item(coll
, i
, device
);
359 hr
= get_mmdevice_guid(*device
, NULL
, &guid
);
361 IMMDevice_Release(*device
);
365 if(IsEqualGUID(&guid
, tgt
)){
366 IMMDeviceCollection_Release(coll
);
367 release_mmdevenum(devenum
, init_hr
);
371 IMMDevice_Release(*device
);
374 WARN("No device with GUID %s found!\n", wine_dbgstr_guid(tgt
));
376 IMMDeviceCollection_Release(coll
);
377 release_mmdevenum(devenum
, init_hr
);
379 return DSERR_INVALIDPARAM
;
382 static BOOL
send_device(IMMDevice
*device
, GUID
*guid
,
383 LPDSENUMCALLBACKW cb
, void *user
)
390 PropVariantInit(&pv
);
392 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
394 WARN("OpenPropertyStore failed: %08x\n", hr
);
398 hr
= get_mmdevice_guid(device
, ps
, guid
);
400 IPropertyStore_Release(ps
);
404 hr
= IPropertyStore_GetValue(ps
,
405 (const PROPERTYKEY
*)&DEVPKEY_Device_FriendlyName
, &pv
);
407 IPropertyStore_Release(ps
);
408 WARN("GetValue(FriendlyName) failed: %08x\n", hr
);
412 TRACE("Calling back with %s (%s)\n", wine_dbgstr_guid(guid
),
413 wine_dbgstr_w(pv
.u
.pwszVal
));
415 keep_going
= cb(guid
, pv
.u
.pwszVal
, wine_vxd_drv
, user
);
417 PropVariantClear(&pv
);
418 IPropertyStore_Release(ps
);
423 /* S_FALSE means the callback returned FALSE at some point
424 * S_OK means the callback always returned TRUE */
425 HRESULT
enumerate_mmdevices(EDataFlow flow
, GUID
*guids
,
426 LPDSENUMCALLBACKW cb
, void *user
)
428 IMMDeviceEnumerator
*devenum
;
429 IMMDeviceCollection
*coll
;
430 IMMDevice
*defdev
= NULL
;
435 static const WCHAR primary_desc
[] = {'P','r','i','m','a','r','y',' ',
436 'S','o','u','n','d',' ','D','r','i','v','e','r',0};
437 static const WCHAR empty_drv
[] = {0};
439 init_hr
= get_mmdevenum(&devenum
);
443 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(devenum
, flow
,
444 DEVICE_STATE_ACTIVE
, &coll
);
446 release_mmdevenum(devenum
, init_hr
);
447 WARN("EnumAudioEndpoints failed: %08x\n", hr
);
451 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
453 IMMDeviceCollection_Release(coll
);
454 release_mmdevenum(devenum
, init_hr
);
455 WARN("GetCount failed: %08x\n", hr
);
460 release_mmdevenum(devenum
, init_hr
);
464 TRACE("Calling back with NULL (%s)\n", wine_dbgstr_w(primary_desc
));
465 keep_going
= cb(NULL
, primary_desc
, empty_drv
, user
);
467 /* always send the default device first */
469 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
, flow
,
470 eMultimedia
, &defdev
);
475 keep_going
= send_device(defdev
, &guids
[0], cb
, user
);
480 for(i
= 0; keep_going
&& i
< count
; ++i
){
483 hr
= IMMDeviceCollection_Item(coll
, i
, &device
);
485 WARN("Item failed: %08x\n", hr
);
489 if(device
!= defdev
){
490 send_device(device
, &guids
[n
], cb
, user
);
494 IMMDevice_Release(device
);
498 IMMDevice_Release(defdev
);
499 IMMDeviceCollection_Release(coll
);
501 release_mmdevenum(devenum
, init_hr
);
503 return (keep_going
== TRUE
) ? S_OK
: S_FALSE
;
506 /***************************************************************************
507 * DirectSoundEnumerateW [DSOUND.3]
509 * Enumerate all DirectSound drivers installed in the system
512 * lpDSEnumCallback [I] Address of callback function.
513 * lpContext [I] Address of user defined context passed to callback function.
517 * Failure: DSERR_INVALIDPARAM
519 HRESULT WINAPI
DirectSoundEnumerateW(
520 LPDSENUMCALLBACKW lpDSEnumCallback
,
525 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
527 if (lpDSEnumCallback
== NULL
) {
528 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
529 return DSERR_INVALIDPARAM
;
532 setup_dsound_options();
534 hr
= enumerate_mmdevices(eRender
, DSOUND_renderer_guids
,
535 lpDSEnumCallback
, lpContext
);
536 return SUCCEEDED(hr
) ? DS_OK
: hr
;
539 /***************************************************************************
540 * DirectSoundCaptureEnumerateA [DSOUND.7]
542 * Enumerate all DirectSound drivers installed in the system.
545 * lpDSEnumCallback [I] Address of callback function.
546 * lpContext [I] Address of user defined context passed to callback function.
550 * Failure: DSERR_INVALIDPARAM
552 HRESULT WINAPI
DirectSoundCaptureEnumerateA(
553 LPDSENUMCALLBACKA lpDSEnumCallback
,
556 struct morecontext context
;
558 if (lpDSEnumCallback
== NULL
) {
559 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
560 return DSERR_INVALIDPARAM
;
563 context
.callA
= lpDSEnumCallback
;
564 context
.data
= lpContext
;
566 return DirectSoundCaptureEnumerateW(a_to_w_callback
, &context
);
569 /***************************************************************************
570 * DirectSoundCaptureEnumerateW [DSOUND.8]
572 * Enumerate all DirectSound drivers installed in the system.
575 * lpDSEnumCallback [I] Address of callback function.
576 * lpContext [I] Address of user defined context passed to callback function.
580 * Failure: DSERR_INVALIDPARAM
583 DirectSoundCaptureEnumerateW(
584 LPDSENUMCALLBACKW lpDSEnumCallback
,
589 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
591 if (lpDSEnumCallback
== NULL
) {
592 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
593 return DSERR_INVALIDPARAM
;
596 setup_dsound_options();
598 hr
= enumerate_mmdevices(eCapture
, DSOUND_capture_guids
,
599 lpDSEnumCallback
, lpContext
);
600 return SUCCEEDED(hr
) ? DS_OK
: hr
;
603 /*******************************************************************************
604 * DirectSound ClassFactory
607 typedef HRESULT (*FnCreateInstance
)(REFIID riid
, LPVOID
*ppobj
);
610 IClassFactory IClassFactory_iface
;
612 FnCreateInstance pfnCreateInstance
;
615 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
617 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
620 static HRESULT WINAPI
621 DSCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, LPVOID
*ppobj
)
623 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
624 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppobj
);
627 if (IsEqualIID(riid
, &IID_IUnknown
) ||
628 IsEqualIID(riid
, &IID_IClassFactory
))
631 IClassFactory_AddRef(iface
);
635 return E_NOINTERFACE
;
638 static ULONG WINAPI
DSCF_AddRef(LPCLASSFACTORY iface
)
643 static ULONG WINAPI
DSCF_Release(LPCLASSFACTORY iface
)
645 /* static class, won't be freed */
649 static HRESULT WINAPI
DSCF_CreateInstance(
650 LPCLASSFACTORY iface
,
655 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
656 TRACE("(%p, %p, %s, %p)\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
659 return CLASS_E_NOAGGREGATION
;
662 WARN("invalid parameter\n");
663 return DSERR_INVALIDPARAM
;
666 return This
->pfnCreateInstance(riid
, ppobj
);
669 static HRESULT WINAPI
DSCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
671 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
672 FIXME("(%p, %d) stub!\n", This
, dolock
);
676 static const IClassFactoryVtbl DSCF_Vtbl
= {
684 static IClassFactoryImpl DSOUND_CF
[] = {
685 { { &DSCF_Vtbl
}, &CLSID_DirectSound
, DSOUND_Create
},
686 { { &DSCF_Vtbl
}, &CLSID_DirectSound8
, DSOUND_Create8
},
687 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture
, DSOUND_CaptureCreate
},
688 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture8
, DSOUND_CaptureCreate8
},
689 { { &DSCF_Vtbl
}, &CLSID_DirectSoundFullDuplex
, DSOUND_FullDuplexCreate
},
690 { { &DSCF_Vtbl
}, &CLSID_DirectSoundPrivate
, IKsPrivatePropertySetImpl_Create
},
691 { { NULL
}, NULL
, NULL
}
694 /*******************************************************************************
695 * DllGetClassObject [DSOUND.@]
696 * Retrieves class object from a DLL object
699 * Docs say returns STDAPI
702 * rclsid [I] CLSID for the class object
703 * riid [I] Reference to identifier of interface for class object
704 * ppv [O] Address of variable to receive interface pointer for riid
708 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
711 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
714 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
717 WARN("invalid parameter\n");
723 if (!IsEqualIID(riid
, &IID_IClassFactory
) &&
724 !IsEqualIID(riid
, &IID_IUnknown
)) {
725 WARN("no interface for %s\n", debugstr_guid(riid
));
726 return E_NOINTERFACE
;
729 while (NULL
!= DSOUND_CF
[i
].rclsid
) {
730 if (IsEqualGUID(rclsid
, DSOUND_CF
[i
].rclsid
)) {
731 DSCF_AddRef(&DSOUND_CF
[i
].IClassFactory_iface
);
732 *ppv
= &DSOUND_CF
[i
];
738 WARN("(%s, %s, %p): no class found.\n", debugstr_guid(rclsid
),
739 debugstr_guid(riid
), ppv
);
740 return CLASS_E_CLASSNOTAVAILABLE
;
744 /*******************************************************************************
745 * DllCanUnloadNow [DSOUND.4]
746 * Determines whether the DLL is in use.
749 * Can unload now: S_OK
750 * Cannot unload now (the DLL is still active): S_FALSE
752 HRESULT WINAPI
DllCanUnloadNow(void)
757 #define INIT_GUID(guid, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
758 guid.Data1 = l; guid.Data2 = w1; guid.Data3 = w2; \
759 guid.Data4[0] = b1; guid.Data4[1] = b2; guid.Data4[2] = b3; \
760 guid.Data4[3] = b4; guid.Data4[4] = b5; guid.Data4[5] = b6; \
761 guid.Data4[6] = b7; guid.Data4[7] = b8;
763 /***********************************************************************
764 * DllMain (DSOUND.init)
766 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
768 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpvReserved
);
771 case DLL_PROCESS_ATTACH
:
772 TRACE("DLL_PROCESS_ATTACH\n");
774 DisableThreadLibraryCalls(hInstDLL
);
775 /* Increase refcount on dsound by 1 */
776 GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
, (LPCWSTR
)hInstDLL
, &hInstDLL
);
778 case DLL_PROCESS_DETACH
:
779 TRACE("DLL_PROCESS_DETACH\n");
780 DeleteCriticalSection(&DSOUND_renderers_lock
);
781 DeleteCriticalSection(&DSOUND_capturers_lock
);
784 TRACE("UNKNOWN REASON\n");
790 /***********************************************************************
791 * DllRegisterServer (DSOUND.@)
793 HRESULT WINAPI
DllRegisterServer(void)
795 return __wine_register_resources( instance
);
798 /***********************************************************************
799 * DllUnregisterServer (DSOUND.@)
801 HRESULT WINAPI
DllUnregisterServer(void)
803 return __wine_unregister_resources( instance
);