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
);
155 ERR("CoCreateInstance failed: %08x\n", hr
);
162 static void release_mmdevenum(IMMDeviceEnumerator
*devenum
, HRESULT init_hr
)
164 IMMDeviceEnumerator_Release(devenum
);
165 if(SUCCEEDED(init_hr
))
169 static HRESULT
get_mmdevice_guid(IMMDevice
*device
, IPropertyStore
*ps
,
176 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
178 WARN("OpenPropertyStore failed: %08x\n", hr
);
182 IPropertyStore_AddRef(ps
);
184 PropVariantInit(&pv
);
186 hr
= IPropertyStore_GetValue(ps
, &PKEY_AudioEndpoint_GUID
, &pv
);
188 IPropertyStore_Release(ps
);
189 WARN("GetValue(GUID) failed: %08x\n", hr
);
193 CLSIDFromString(pv
.u
.pwszVal
, guid
);
195 PropVariantClear(&pv
);
196 IPropertyStore_Release(ps
);
201 /***************************************************************************
202 * GetDeviceID [DSOUND.9]
204 * Retrieves unique identifier of default device specified
207 * pGuidSrc [I] Address of device GUID.
208 * pGuidDest [O] Address to receive unique device GUID.
212 * Failure: DSERR_INVALIDPARAM
215 * pGuidSrc is a valid device GUID or DSDEVID_DefaultPlayback,
216 * DSDEVID_DefaultCapture, DSDEVID_DefaultVoicePlayback, or
217 * DSDEVID_DefaultVoiceCapture.
218 * Returns pGuidSrc if pGuidSrc is a valid device or the device
219 * GUID for the specified constants.
221 HRESULT WINAPI
GetDeviceID(LPCGUID pGuidSrc
, LPGUID pGuidDest
)
223 IMMDeviceEnumerator
*devenum
;
224 EDataFlow flow
= (EDataFlow
)-1;
225 ERole role
= (ERole
)-1;
228 TRACE("(%s,%p)\n", get_device_id(pGuidSrc
),pGuidDest
);
230 if(!pGuidSrc
|| !pGuidDest
)
231 return DSERR_INVALIDPARAM
;
233 init_hr
= get_mmdevenum(&devenum
);
237 if(IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuidSrc
)){
240 }else if(IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuidSrc
)){
241 role
= eCommunications
;
243 }else if(IsEqualGUID(&DSDEVID_DefaultCapture
, pGuidSrc
)){
246 }else if(IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuidSrc
)){
247 role
= eCommunications
;
251 if(role
!= (ERole
)-1 && flow
!= (EDataFlow
)-1){
254 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
,
255 flow
, role
, &device
);
257 WARN("GetDefaultAudioEndpoint failed: %08x\n", hr
);
258 release_mmdevenum(devenum
, init_hr
);
259 return DSERR_NODRIVER
;
262 hr
= get_mmdevice_guid(device
, NULL
, pGuidDest
);
263 IMMDevice_Release(device
);
265 release_mmdevenum(devenum
, init_hr
);
267 return (hr
== S_OK
) ? DS_OK
: hr
;
270 release_mmdevenum(devenum
, init_hr
);
272 *pGuidDest
= *pGuidSrc
;
279 LPDSENUMCALLBACKA callA
;
283 static BOOL CALLBACK
a_to_w_callback(LPGUID guid
, LPCWSTR descW
, LPCWSTR modW
, LPVOID data
)
285 struct morecontext
*context
= data
;
286 char descA
[MAXPNAMELEN
], modA
[MAXPNAMELEN
];
288 WideCharToMultiByte(CP_ACP
, 0, descW
, -1, descA
, sizeof(descA
), NULL
, NULL
);
289 WideCharToMultiByte(CP_ACP
, 0, modW
, -1, modA
, sizeof(modA
), NULL
, NULL
);
291 return context
->callA(guid
, descA
, modA
, context
->data
);
294 /***************************************************************************
295 * DirectSoundEnumerateA [DSOUND.2]
297 * Enumerate all DirectSound drivers installed in the system
300 * lpDSEnumCallback [I] Address of callback function.
301 * lpContext [I] Address of user defined context passed to callback function.
305 * Failure: DSERR_INVALIDPARAM
307 HRESULT WINAPI
DirectSoundEnumerateA(
308 LPDSENUMCALLBACKA lpDSEnumCallback
,
311 struct morecontext context
;
313 if (lpDSEnumCallback
== NULL
) {
314 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
315 return DSERR_INVALIDPARAM
;
318 context
.callA
= lpDSEnumCallback
;
319 context
.data
= lpContext
;
321 return DirectSoundEnumerateW(a_to_w_callback
, &context
);
324 HRESULT
get_mmdevice(EDataFlow flow
, const GUID
*tgt
, IMMDevice
**device
)
326 IMMDeviceEnumerator
*devenum
;
327 IMMDeviceCollection
*coll
;
331 init_hr
= get_mmdevenum(&devenum
);
335 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(devenum
, flow
,
336 DEVICE_STATE_ACTIVE
, &coll
);
338 WARN("EnumAudioEndpoints failed: %08x\n", hr
);
339 release_mmdevenum(devenum
, init_hr
);
343 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
345 IMMDeviceCollection_Release(coll
);
346 release_mmdevenum(devenum
, init_hr
);
347 WARN("GetCount failed: %08x\n", hr
);
351 for(i
= 0; i
< count
; ++i
){
354 hr
= IMMDeviceCollection_Item(coll
, i
, device
);
358 hr
= get_mmdevice_guid(*device
, NULL
, &guid
);
360 IMMDevice_Release(*device
);
364 if(IsEqualGUID(&guid
, tgt
)){
365 IMMDeviceCollection_Release(coll
);
366 release_mmdevenum(devenum
, init_hr
);
370 IMMDevice_Release(*device
);
373 WARN("No device with GUID %s found!\n", wine_dbgstr_guid(tgt
));
375 IMMDeviceCollection_Release(coll
);
376 release_mmdevenum(devenum
, init_hr
);
378 return DSERR_INVALIDPARAM
;
381 static BOOL
send_device(IMMDevice
*device
, GUID
*guid
,
382 LPDSENUMCALLBACKW cb
, void *user
)
389 PropVariantInit(&pv
);
391 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
393 WARN("OpenPropertyStore failed: %08x\n", hr
);
397 hr
= get_mmdevice_guid(device
, ps
, guid
);
399 IPropertyStore_Release(ps
);
403 hr
= IPropertyStore_GetValue(ps
,
404 (const PROPERTYKEY
*)&DEVPKEY_Device_FriendlyName
, &pv
);
406 IPropertyStore_Release(ps
);
407 WARN("GetValue(FriendlyName) failed: %08x\n", hr
);
411 TRACE("Calling back with %s (%s)\n", wine_dbgstr_guid(guid
),
412 wine_dbgstr_w(pv
.u
.pwszVal
));
414 keep_going
= cb(guid
, pv
.u
.pwszVal
, wine_vxd_drv
, user
);
416 PropVariantClear(&pv
);
417 IPropertyStore_Release(ps
);
422 /* S_FALSE means the callback returned FALSE at some point
423 * S_OK means the callback always returned TRUE */
424 HRESULT
enumerate_mmdevices(EDataFlow flow
, GUID
*guids
,
425 LPDSENUMCALLBACKW cb
, void *user
)
427 IMMDeviceEnumerator
*devenum
;
428 IMMDeviceCollection
*coll
;
429 IMMDevice
*defdev
= NULL
;
434 static const WCHAR primary_desc
[] = {'P','r','i','m','a','r','y',' ',
435 'S','o','u','n','d',' ','D','r','i','v','e','r',0};
436 static const WCHAR empty_drv
[] = {0};
438 init_hr
= get_mmdevenum(&devenum
);
442 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(devenum
, flow
,
443 DEVICE_STATE_ACTIVE
, &coll
);
445 release_mmdevenum(devenum
, init_hr
);
446 WARN("EnumAudioEndpoints failed: %08x\n", hr
);
450 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
452 IMMDeviceCollection_Release(coll
);
453 release_mmdevenum(devenum
, init_hr
);
454 WARN("GetCount failed: %08x\n", hr
);
459 release_mmdevenum(devenum
, init_hr
);
463 TRACE("Calling back with NULL (%s)\n", wine_dbgstr_w(primary_desc
));
464 keep_going
= cb(NULL
, primary_desc
, empty_drv
, user
);
466 /* always send the default device first */
468 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
, flow
,
469 eMultimedia
, &defdev
);
474 keep_going
= send_device(defdev
, &guids
[0], cb
, user
);
479 for(i
= 0; keep_going
&& i
< count
; ++i
){
482 hr
= IMMDeviceCollection_Item(coll
, i
, &device
);
484 WARN("Item failed: %08x\n", hr
);
488 if(device
!= defdev
){
489 send_device(device
, &guids
[n
], cb
, user
);
493 IMMDevice_Release(device
);
497 IMMDevice_Release(defdev
);
498 IMMDeviceCollection_Release(coll
);
500 release_mmdevenum(devenum
, init_hr
);
502 return (keep_going
== TRUE
) ? S_OK
: S_FALSE
;
505 /***************************************************************************
506 * DirectSoundEnumerateW [DSOUND.3]
508 * Enumerate all DirectSound drivers installed in the system
511 * lpDSEnumCallback [I] Address of callback function.
512 * lpContext [I] Address of user defined context passed to callback function.
516 * Failure: DSERR_INVALIDPARAM
518 HRESULT WINAPI
DirectSoundEnumerateW(
519 LPDSENUMCALLBACKW lpDSEnumCallback
,
524 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
526 if (lpDSEnumCallback
== NULL
) {
527 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
528 return DSERR_INVALIDPARAM
;
531 setup_dsound_options();
533 hr
= enumerate_mmdevices(eRender
, DSOUND_renderer_guids
,
534 lpDSEnumCallback
, lpContext
);
535 return SUCCEEDED(hr
) ? DS_OK
: hr
;
538 /***************************************************************************
539 * DirectSoundCaptureEnumerateA [DSOUND.7]
541 * Enumerate all DirectSound drivers installed in the system.
544 * lpDSEnumCallback [I] Address of callback function.
545 * lpContext [I] Address of user defined context passed to callback function.
549 * Failure: DSERR_INVALIDPARAM
551 HRESULT WINAPI
DirectSoundCaptureEnumerateA(
552 LPDSENUMCALLBACKA lpDSEnumCallback
,
555 struct morecontext context
;
557 if (lpDSEnumCallback
== NULL
) {
558 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
559 return DSERR_INVALIDPARAM
;
562 context
.callA
= lpDSEnumCallback
;
563 context
.data
= lpContext
;
565 return DirectSoundCaptureEnumerateW(a_to_w_callback
, &context
);
568 /***************************************************************************
569 * DirectSoundCaptureEnumerateW [DSOUND.8]
571 * Enumerate all DirectSound drivers installed in the system.
574 * lpDSEnumCallback [I] Address of callback function.
575 * lpContext [I] Address of user defined context passed to callback function.
579 * Failure: DSERR_INVALIDPARAM
582 DirectSoundCaptureEnumerateW(
583 LPDSENUMCALLBACKW lpDSEnumCallback
,
588 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
590 if (lpDSEnumCallback
== NULL
) {
591 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
592 return DSERR_INVALIDPARAM
;
595 setup_dsound_options();
597 hr
= enumerate_mmdevices(eCapture
, DSOUND_capture_guids
,
598 lpDSEnumCallback
, lpContext
);
599 return SUCCEEDED(hr
) ? DS_OK
: hr
;
602 /*******************************************************************************
603 * DirectSound ClassFactory
606 typedef HRESULT (*FnCreateInstance
)(REFIID riid
, LPVOID
*ppobj
);
609 IClassFactory IClassFactory_iface
;
611 FnCreateInstance pfnCreateInstance
;
614 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
616 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
619 static HRESULT WINAPI
620 DSCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, LPVOID
*ppobj
)
622 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
623 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppobj
);
626 if (IsEqualIID(riid
, &IID_IUnknown
) ||
627 IsEqualIID(riid
, &IID_IClassFactory
))
630 IClassFactory_AddRef(iface
);
634 return E_NOINTERFACE
;
637 static ULONG WINAPI
DSCF_AddRef(LPCLASSFACTORY iface
)
642 static ULONG WINAPI
DSCF_Release(LPCLASSFACTORY iface
)
644 /* static class, won't be freed */
648 static HRESULT WINAPI
DSCF_CreateInstance(
649 LPCLASSFACTORY iface
,
654 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
655 TRACE("(%p, %p, %s, %p)\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
658 return CLASS_E_NOAGGREGATION
;
661 WARN("invalid parameter\n");
662 return DSERR_INVALIDPARAM
;
665 return This
->pfnCreateInstance(riid
, ppobj
);
668 static HRESULT WINAPI
DSCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
670 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
671 FIXME("(%p, %d) stub!\n", This
, dolock
);
675 static const IClassFactoryVtbl DSCF_Vtbl
= {
683 static IClassFactoryImpl DSOUND_CF
[] = {
684 { { &DSCF_Vtbl
}, &CLSID_DirectSound
, DSOUND_Create
},
685 { { &DSCF_Vtbl
}, &CLSID_DirectSound8
, DSOUND_Create8
},
686 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture
, DSOUND_CaptureCreate
},
687 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture8
, DSOUND_CaptureCreate8
},
688 { { &DSCF_Vtbl
}, &CLSID_DirectSoundFullDuplex
, DSOUND_FullDuplexCreate
},
689 { { &DSCF_Vtbl
}, &CLSID_DirectSoundPrivate
, IKsPrivatePropertySetImpl_Create
},
690 { { NULL
}, NULL
, NULL
}
693 /*******************************************************************************
694 * DllGetClassObject [DSOUND.@]
695 * Retrieves class object from a DLL object
698 * Docs say returns STDAPI
701 * rclsid [I] CLSID for the class object
702 * riid [I] Reference to identifier of interface for class object
703 * ppv [O] Address of variable to receive interface pointer for riid
707 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
710 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
713 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
716 WARN("invalid parameter\n");
722 if (!IsEqualIID(riid
, &IID_IClassFactory
) &&
723 !IsEqualIID(riid
, &IID_IUnknown
)) {
724 WARN("no interface for %s\n", debugstr_guid(riid
));
725 return E_NOINTERFACE
;
728 while (NULL
!= DSOUND_CF
[i
].rclsid
) {
729 if (IsEqualGUID(rclsid
, DSOUND_CF
[i
].rclsid
)) {
730 DSCF_AddRef(&DSOUND_CF
[i
].IClassFactory_iface
);
731 *ppv
= &DSOUND_CF
[i
];
737 WARN("(%s, %s, %p): no class found.\n", debugstr_guid(rclsid
),
738 debugstr_guid(riid
), ppv
);
739 return CLASS_E_CLASSNOTAVAILABLE
;
743 /*******************************************************************************
744 * DllCanUnloadNow [DSOUND.4]
745 * Determines whether the DLL is in use.
748 * Can unload now: S_OK
749 * Cannot unload now (the DLL is still active): S_FALSE
751 HRESULT WINAPI
DllCanUnloadNow(void)
756 #define INIT_GUID(guid, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
757 guid.Data1 = l; guid.Data2 = w1; guid.Data3 = w2; \
758 guid.Data4[0] = b1; guid.Data4[1] = b2; guid.Data4[2] = b3; \
759 guid.Data4[3] = b4; guid.Data4[4] = b5; guid.Data4[5] = b6; \
760 guid.Data4[6] = b7; guid.Data4[7] = b8;
762 /***********************************************************************
763 * DllMain (DSOUND.init)
765 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
767 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpvReserved
);
770 case DLL_PROCESS_ATTACH
:
771 TRACE("DLL_PROCESS_ATTACH\n");
773 DisableThreadLibraryCalls(hInstDLL
);
774 /* Increase refcount on dsound by 1 */
775 GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
, (LPCWSTR
)hInstDLL
, &hInstDLL
);
777 case DLL_PROCESS_DETACH
:
778 TRACE("DLL_PROCESS_DETACH\n");
779 DeleteCriticalSection(&DSOUND_renderers_lock
);
780 DeleteCriticalSection(&DSOUND_capturers_lock
);
783 TRACE("UNKNOWN REASON\n");
789 /***********************************************************************
790 * DllRegisterServer (DSOUND.@)
792 HRESULT WINAPI
DllRegisterServer(void)
794 return __wine_register_resources( instance
);
797 /***********************************************************************
798 * DllUnregisterServer (DSOUND.@)
800 HRESULT WINAPI
DllUnregisterServer(void)
802 return __wine_unregister_resources( instance
);