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 NONAMELESSUNION
48 #include "wine/debug.h"
65 #include "dsound_private.h"
67 WINE_DEFAULT_DEBUG_CHANNEL(dsound
);
69 struct list DSOUND_renderers
= LIST_INIT(DSOUND_renderers
);
70 CRITICAL_SECTION DSOUND_renderers_lock
;
71 static CRITICAL_SECTION_DEBUG DSOUND_renderers_lock_debug
=
73 0, 0, &DSOUND_renderers_lock
,
74 { &DSOUND_renderers_lock_debug
.ProcessLocksList
, &DSOUND_renderers_lock_debug
.ProcessLocksList
},
75 0, 0, { (DWORD_PTR
)(__FILE__
": DSOUND_renderers_lock") }
77 CRITICAL_SECTION DSOUND_renderers_lock
= { &DSOUND_renderers_lock_debug
, -1, 0, 0, 0, 0 };
79 struct list DSOUND_capturers
= LIST_INIT(DSOUND_capturers
);
80 CRITICAL_SECTION DSOUND_capturers_lock
;
81 static CRITICAL_SECTION_DEBUG DSOUND_capturers_lock_debug
=
83 0, 0, &DSOUND_capturers_lock
,
84 { &DSOUND_capturers_lock_debug
.ProcessLocksList
, &DSOUND_capturers_lock_debug
.ProcessLocksList
},
85 0, 0, { (DWORD_PTR
)(__FILE__
": DSOUND_capturers_lock") }
87 CRITICAL_SECTION DSOUND_capturers_lock
= { &DSOUND_capturers_lock_debug
, -1, 0, 0, 0, 0 };
89 GUID DSOUND_renderer_guids
[MAXWAVEDRIVERS
];
90 GUID DSOUND_capture_guids
[MAXWAVEDRIVERS
];
92 WCHAR wine_vxd_drv
[] = { 'w','i','n','e','m','m','.','v','x','d', 0 };
94 /* All default settings, you most likely don't want to touch these, see wiki on UsefulRegistryKeys */
95 int ds_hel_buflen
= 32768 * 2;
96 int ds_snd_queue_max
= 10;
97 static HINSTANCE instance
;
100 * Get a config key from either the app-specific or the default config
103 static inline DWORD
get_config_key( HKEY defkey
, HKEY appkey
, const char *name
,
104 char *buffer
, DWORD size
)
106 if (appkey
&& !RegQueryValueExA( appkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
107 if (defkey
&& !RegQueryValueExA( defkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
108 return ERROR_FILE_NOT_FOUND
;
113 * Setup the dsound options.
116 void setup_dsound_options(void)
118 char buffer
[MAX_PATH
+16];
119 HKEY hkey
, appkey
= 0;
122 buffer
[MAX_PATH
]='\0';
124 /* @@ Wine registry key: HKCU\Software\Wine\DirectSound */
125 if (RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\DirectSound", &hkey
)) hkey
= 0;
127 len
= GetModuleFileNameA( 0, buffer
, MAX_PATH
);
128 if (len
&& len
< MAX_PATH
)
131 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectSound */
132 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\AppDefaults", &tmpkey
))
134 char *p
, *appname
= buffer
;
135 if ((p
= strrchr( appname
, '/' ))) appname
= p
+ 1;
136 if ((p
= strrchr( appname
, '\\' ))) appname
= p
+ 1;
137 strcat( appname
, "\\DirectSound" );
138 TRACE("appname = [%s]\n", appname
);
139 if (RegOpenKeyA( tmpkey
, appname
, &appkey
)) appkey
= 0;
140 RegCloseKey( tmpkey
);
146 if (!get_config_key( hkey
, appkey
, "HelBuflen", buffer
, MAX_PATH
))
147 ds_hel_buflen
= atoi(buffer
);
149 if (!get_config_key( hkey
, appkey
, "SndQueueMax", buffer
, MAX_PATH
))
150 ds_snd_queue_max
= atoi(buffer
);
153 if (appkey
) RegCloseKey( appkey
);
154 if (hkey
) RegCloseKey( hkey
);
156 TRACE("ds_hel_buflen = %d\n", ds_hel_buflen
);
157 TRACE("ds_snd_queue_max = %d\n", ds_snd_queue_max
);
160 static const char * get_device_id(LPCGUID pGuid
)
162 if (IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuid
))
163 return "DSDEVID_DefaultPlayback";
164 else if (IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuid
))
165 return "DSDEVID_DefaultVoicePlayback";
166 else if (IsEqualGUID(&DSDEVID_DefaultCapture
, pGuid
))
167 return "DSDEVID_DefaultCapture";
168 else if (IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuid
))
169 return "DSDEVID_DefaultVoiceCapture";
170 return debugstr_guid(pGuid
);
173 static HRESULT
get_mmdevenum(IMMDeviceEnumerator
**devenum
)
177 init_hr
= CoInitialize(NULL
);
179 hr
= CoCreateInstance(&CLSID_MMDeviceEnumerator
, NULL
,
180 CLSCTX_INPROC_SERVER
, &IID_IMMDeviceEnumerator
, (void**)devenum
);
182 if(SUCCEEDED(init_hr
))
185 ERR("CoCreateInstance failed: %08x\n", hr
);
192 static void release_mmdevenum(IMMDeviceEnumerator
*devenum
, HRESULT init_hr
)
194 IMMDeviceEnumerator_Release(devenum
);
195 if(SUCCEEDED(init_hr
))
199 static HRESULT
get_mmdevice_guid(IMMDevice
*device
, IPropertyStore
*ps
,
206 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
208 WARN("OpenPropertyStore failed: %08x\n", hr
);
212 IPropertyStore_AddRef(ps
);
214 PropVariantInit(&pv
);
216 hr
= IPropertyStore_GetValue(ps
, &PKEY_AudioEndpoint_GUID
, &pv
);
218 IPropertyStore_Release(ps
);
219 WARN("GetValue(GUID) failed: %08x\n", hr
);
223 CLSIDFromString(pv
.u
.pwszVal
, guid
);
225 PropVariantClear(&pv
);
226 IPropertyStore_Release(ps
);
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 IMMDeviceEnumerator
*devenum
;
254 EDataFlow flow
= (EDataFlow
)-1;
255 ERole role
= (ERole
)-1;
258 TRACE("(%s,%p)\n", get_device_id(pGuidSrc
),pGuidDest
);
260 if(!pGuidSrc
|| !pGuidDest
)
261 return DSERR_INVALIDPARAM
;
263 init_hr
= get_mmdevenum(&devenum
);
267 if(IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuidSrc
)){
270 }else if(IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuidSrc
)){
271 role
= eCommunications
;
273 }else if(IsEqualGUID(&DSDEVID_DefaultCapture
, pGuidSrc
)){
276 }else if(IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuidSrc
)){
277 role
= eCommunications
;
281 if(role
!= (ERole
)-1 && flow
!= (EDataFlow
)-1){
284 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
,
285 flow
, role
, &device
);
287 WARN("GetDefaultAudioEndpoint failed: %08x\n", hr
);
288 release_mmdevenum(devenum
, init_hr
);
289 return DSERR_NODRIVER
;
292 hr
= get_mmdevice_guid(device
, NULL
, pGuidDest
);
293 IMMDevice_Release(device
);
295 release_mmdevenum(devenum
, init_hr
);
297 return (hr
== S_OK
) ? DS_OK
: hr
;
300 release_mmdevenum(devenum
, init_hr
);
302 *pGuidDest
= *pGuidSrc
;
309 LPDSENUMCALLBACKA callA
;
313 static BOOL CALLBACK
a_to_w_callback(LPGUID guid
, LPCWSTR descW
, LPCWSTR modW
, LPVOID data
)
315 struct morecontext
*context
= data
;
316 char descA
[MAXPNAMELEN
], modA
[MAXPNAMELEN
];
318 WideCharToMultiByte(CP_ACP
, 0, descW
, -1, descA
, sizeof(descA
), NULL
, NULL
);
319 WideCharToMultiByte(CP_ACP
, 0, modW
, -1, modA
, sizeof(modA
), NULL
, NULL
);
321 return context
->callA(guid
, descA
, modA
, context
->data
);
324 /***************************************************************************
325 * DirectSoundEnumerateA [DSOUND.2]
327 * Enumerate all DirectSound drivers installed in the system
330 * lpDSEnumCallback [I] Address of callback function.
331 * lpContext [I] Address of user defined context passed to callback function.
335 * Failure: DSERR_INVALIDPARAM
337 HRESULT WINAPI
DirectSoundEnumerateA(
338 LPDSENUMCALLBACKA lpDSEnumCallback
,
341 struct morecontext context
;
343 if (lpDSEnumCallback
== NULL
) {
344 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
345 return DSERR_INVALIDPARAM
;
348 context
.callA
= lpDSEnumCallback
;
349 context
.data
= lpContext
;
351 return DirectSoundEnumerateW(a_to_w_callback
, &context
);
354 HRESULT
get_mmdevice(EDataFlow flow
, const GUID
*tgt
, IMMDevice
**device
)
356 IMMDeviceEnumerator
*devenum
;
357 IMMDeviceCollection
*coll
;
361 init_hr
= get_mmdevenum(&devenum
);
365 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(devenum
, flow
,
366 DEVICE_STATE_ACTIVE
, &coll
);
368 WARN("EnumAudioEndpoints failed: %08x\n", hr
);
369 release_mmdevenum(devenum
, init_hr
);
373 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
375 IMMDeviceCollection_Release(coll
);
376 release_mmdevenum(devenum
, init_hr
);
377 WARN("GetCount failed: %08x\n", hr
);
381 for(i
= 0; i
< count
; ++i
){
384 hr
= IMMDeviceCollection_Item(coll
, i
, device
);
388 hr
= get_mmdevice_guid(*device
, NULL
, &guid
);
390 IMMDevice_Release(*device
);
394 if(IsEqualGUID(&guid
, tgt
)){
395 IMMDeviceCollection_Release(coll
);
396 release_mmdevenum(devenum
, init_hr
);
400 IMMDevice_Release(*device
);
403 WARN("No device with GUID %s found!\n", wine_dbgstr_guid(tgt
));
405 IMMDeviceCollection_Release(coll
);
406 release_mmdevenum(devenum
, init_hr
);
408 return DSERR_INVALIDPARAM
;
411 static BOOL
send_device(IMMDevice
*device
, GUID
*guid
,
412 LPDSENUMCALLBACKW cb
, void *user
)
419 PropVariantInit(&pv
);
421 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
423 WARN("OpenPropertyStore failed: %08x\n", hr
);
427 hr
= get_mmdevice_guid(device
, ps
, guid
);
429 IPropertyStore_Release(ps
);
433 hr
= IPropertyStore_GetValue(ps
,
434 (const PROPERTYKEY
*)&DEVPKEY_Device_FriendlyName
, &pv
);
436 IPropertyStore_Release(ps
);
437 WARN("GetValue(FriendlyName) failed: %08x\n", hr
);
441 TRACE("Calling back with %s (%s)\n", wine_dbgstr_guid(guid
),
442 wine_dbgstr_w(pv
.u
.pwszVal
));
444 keep_going
= cb(guid
, pv
.u
.pwszVal
, wine_vxd_drv
, user
);
446 PropVariantClear(&pv
);
447 IPropertyStore_Release(ps
);
452 /* S_FALSE means the callback returned FALSE at some point
453 * S_OK means the callback always returned TRUE */
454 HRESULT
enumerate_mmdevices(EDataFlow flow
, GUID
*guids
,
455 LPDSENUMCALLBACKW cb
, void *user
)
457 IMMDeviceEnumerator
*devenum
;
458 IMMDeviceCollection
*coll
;
459 IMMDevice
*defdev
= NULL
;
464 static const WCHAR primary_desc
[] = {'P','r','i','m','a','r','y',' ',
465 'S','o','u','n','d',' ','D','r','i','v','e','r',0};
466 static const WCHAR empty_drv
[] = {0};
468 init_hr
= get_mmdevenum(&devenum
);
472 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(devenum
, flow
,
473 DEVICE_STATE_ACTIVE
, &coll
);
475 release_mmdevenum(devenum
, init_hr
);
476 WARN("EnumAudioEndpoints failed: %08x\n", hr
);
480 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
482 IMMDeviceCollection_Release(coll
);
483 release_mmdevenum(devenum
, init_hr
);
484 WARN("GetCount failed: %08x\n", hr
);
489 release_mmdevenum(devenum
, init_hr
);
493 TRACE("Calling back with NULL (%s)\n", wine_dbgstr_w(primary_desc
));
494 keep_going
= cb(NULL
, primary_desc
, empty_drv
, user
);
496 /* always send the default device first */
498 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
, flow
,
499 eMultimedia
, &defdev
);
504 keep_going
= send_device(defdev
, &guids
[0], cb
, user
);
509 for(i
= 0; keep_going
&& i
< count
; ++i
){
512 hr
= IMMDeviceCollection_Item(coll
, i
, &device
);
514 WARN("Item failed: %08x\n", hr
);
518 if(device
!= defdev
){
519 send_device(device
, &guids
[n
], cb
, user
);
523 IMMDevice_Release(device
);
527 IMMDevice_Release(defdev
);
528 IMMDeviceCollection_Release(coll
);
530 release_mmdevenum(devenum
, init_hr
);
532 return keep_going
? S_OK
: S_FALSE
;
535 /***************************************************************************
536 * DirectSoundEnumerateW [DSOUND.3]
538 * Enumerate all DirectSound drivers installed in the system
541 * lpDSEnumCallback [I] Address of callback function.
542 * lpContext [I] Address of user defined context passed to callback function.
546 * Failure: DSERR_INVALIDPARAM
548 HRESULT WINAPI
DirectSoundEnumerateW(
549 LPDSENUMCALLBACKW lpDSEnumCallback
,
554 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
556 if (lpDSEnumCallback
== NULL
) {
557 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
558 return DSERR_INVALIDPARAM
;
561 setup_dsound_options();
563 hr
= enumerate_mmdevices(eRender
, DSOUND_renderer_guids
,
564 lpDSEnumCallback
, lpContext
);
565 return SUCCEEDED(hr
) ? DS_OK
: hr
;
568 /***************************************************************************
569 * DirectSoundCaptureEnumerateA [DSOUND.7]
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
581 HRESULT WINAPI
DirectSoundCaptureEnumerateA(
582 LPDSENUMCALLBACKA lpDSEnumCallback
,
585 struct morecontext context
;
587 if (lpDSEnumCallback
== NULL
) {
588 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
589 return DSERR_INVALIDPARAM
;
592 context
.callA
= lpDSEnumCallback
;
593 context
.data
= lpContext
;
595 return DirectSoundCaptureEnumerateW(a_to_w_callback
, &context
);
598 /***************************************************************************
599 * DirectSoundCaptureEnumerateW [DSOUND.8]
601 * Enumerate all DirectSound drivers installed in the system.
604 * lpDSEnumCallback [I] Address of callback function.
605 * lpContext [I] Address of user defined context passed to callback function.
609 * Failure: DSERR_INVALIDPARAM
612 DirectSoundCaptureEnumerateW(
613 LPDSENUMCALLBACKW lpDSEnumCallback
,
618 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
620 if (lpDSEnumCallback
== NULL
) {
621 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
622 return DSERR_INVALIDPARAM
;
625 setup_dsound_options();
627 hr
= enumerate_mmdevices(eCapture
, DSOUND_capture_guids
,
628 lpDSEnumCallback
, lpContext
);
629 return SUCCEEDED(hr
) ? DS_OK
: hr
;
632 /*******************************************************************************
633 * DirectSound ClassFactory
636 typedef HRESULT (*FnCreateInstance
)(REFIID riid
, LPVOID
*ppobj
);
639 IClassFactory IClassFactory_iface
;
641 FnCreateInstance pfnCreateInstance
;
644 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
646 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
649 static HRESULT WINAPI
650 DSCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, LPVOID
*ppobj
)
652 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
653 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppobj
);
656 if (IsEqualIID(riid
, &IID_IUnknown
) ||
657 IsEqualIID(riid
, &IID_IClassFactory
))
660 IClassFactory_AddRef(iface
);
664 return E_NOINTERFACE
;
667 static ULONG WINAPI
DSCF_AddRef(LPCLASSFACTORY iface
)
672 static ULONG WINAPI
DSCF_Release(LPCLASSFACTORY iface
)
674 /* static class, won't be freed */
678 static HRESULT WINAPI
DSCF_CreateInstance(
679 LPCLASSFACTORY iface
,
684 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
685 TRACE("(%p, %p, %s, %p)\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
688 return CLASS_E_NOAGGREGATION
;
691 WARN("invalid parameter\n");
692 return DSERR_INVALIDPARAM
;
695 return This
->pfnCreateInstance(riid
, ppobj
);
698 static HRESULT WINAPI
DSCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
700 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
701 FIXME("(%p, %d) stub!\n", This
, dolock
);
705 static const IClassFactoryVtbl DSCF_Vtbl
= {
713 static IClassFactoryImpl DSOUND_CF
[] = {
714 { { &DSCF_Vtbl
}, &CLSID_DirectSound
, DSOUND_Create
},
715 { { &DSCF_Vtbl
}, &CLSID_DirectSound8
, DSOUND_Create8
},
716 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture
, DSOUND_CaptureCreate
},
717 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture8
, DSOUND_CaptureCreate8
},
718 { { &DSCF_Vtbl
}, &CLSID_DirectSoundFullDuplex
, DSOUND_FullDuplexCreate
},
719 { { &DSCF_Vtbl
}, &CLSID_DirectSoundPrivate
, IKsPrivatePropertySetImpl_Create
},
720 { { NULL
}, NULL
, NULL
}
723 /*******************************************************************************
724 * DllGetClassObject [DSOUND.@]
725 * Retrieves class object from a DLL object
728 * Docs say returns STDAPI
731 * rclsid [I] CLSID for the class object
732 * riid [I] Reference to identifier of interface for class object
733 * ppv [O] Address of variable to receive interface pointer for riid
737 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
740 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
743 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
746 WARN("invalid parameter\n");
752 if (!IsEqualIID(riid
, &IID_IClassFactory
) &&
753 !IsEqualIID(riid
, &IID_IUnknown
)) {
754 WARN("no interface for %s\n", debugstr_guid(riid
));
755 return E_NOINTERFACE
;
758 while (NULL
!= DSOUND_CF
[i
].rclsid
) {
759 if (IsEqualGUID(rclsid
, DSOUND_CF
[i
].rclsid
)) {
760 DSCF_AddRef(&DSOUND_CF
[i
].IClassFactory_iface
);
761 *ppv
= &DSOUND_CF
[i
];
767 WARN("(%s, %s, %p): no class found.\n", debugstr_guid(rclsid
),
768 debugstr_guid(riid
), ppv
);
769 return CLASS_E_CLASSNOTAVAILABLE
;
773 /*******************************************************************************
774 * DllCanUnloadNow [DSOUND.4]
775 * Determines whether the DLL is in use.
778 * Can unload now: S_OK
779 * Cannot unload now (the DLL is still active): S_FALSE
781 HRESULT WINAPI
DllCanUnloadNow(void)
786 #define INIT_GUID(guid, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
787 guid.Data1 = l; guid.Data2 = w1; guid.Data3 = w2; \
788 guid.Data4[0] = b1; guid.Data4[1] = b2; guid.Data4[2] = b3; \
789 guid.Data4[3] = b4; guid.Data4[4] = b5; guid.Data4[5] = b6; \
790 guid.Data4[6] = b7; guid.Data4[7] = b8;
792 /***********************************************************************
793 * DllMain (DSOUND.init)
795 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
797 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpvReserved
);
800 case DLL_PROCESS_ATTACH
:
802 DisableThreadLibraryCalls(hInstDLL
);
803 /* Increase refcount on dsound by 1 */
804 GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
, (LPCWSTR
)hInstDLL
, &hInstDLL
);
806 case DLL_PROCESS_DETACH
:
807 if (lpvReserved
) break;
808 DeleteCriticalSection(&DSOUND_renderers_lock
);
809 DeleteCriticalSection(&DSOUND_capturers_lock
);
815 /***********************************************************************
816 * DllRegisterServer (DSOUND.@)
818 HRESULT WINAPI
DllRegisterServer(void)
820 return __wine_register_resources( instance
);
823 /***********************************************************************
824 * DllUnregisterServer (DSOUND.@)
826 HRESULT WINAPI
DllUnregisterServer(void)
828 return __wine_unregister_resources( instance
);