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 static HINSTANCE instance
;
99 * Get a config key from either the app-specific or the default config
102 static inline DWORD
get_config_key( HKEY defkey
, HKEY appkey
, const char *name
,
103 char *buffer
, DWORD size
)
105 if (appkey
&& !RegQueryValueExA( appkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
106 if (defkey
&& !RegQueryValueExA( defkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
107 return ERROR_FILE_NOT_FOUND
;
112 * Setup the dsound options.
115 void setup_dsound_options(void)
117 char buffer
[MAX_PATH
+16];
118 HKEY hkey
, appkey
= 0;
121 buffer
[MAX_PATH
]='\0';
123 /* @@ Wine registry key: HKCU\Software\Wine\DirectSound */
124 if (RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\DirectSound", &hkey
)) hkey
= 0;
126 len
= GetModuleFileNameA( 0, buffer
, MAX_PATH
);
127 if (len
&& len
< MAX_PATH
)
130 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectSound */
131 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\AppDefaults", &tmpkey
))
133 char *p
, *appname
= buffer
;
134 if ((p
= strrchr( appname
, '/' ))) appname
= p
+ 1;
135 if ((p
= strrchr( appname
, '\\' ))) appname
= p
+ 1;
136 strcat( appname
, "\\DirectSound" );
137 TRACE("appname = [%s]\n", appname
);
138 if (RegOpenKeyA( tmpkey
, appname
, &appkey
)) appkey
= 0;
139 RegCloseKey( tmpkey
);
145 if (!get_config_key( hkey
, appkey
, "HelBuflen", buffer
, MAX_PATH
))
146 ds_hel_buflen
= atoi(buffer
);
148 if (!get_config_key( hkey
, appkey
, "SndQueueMax", buffer
, MAX_PATH
))
149 ds_snd_queue_max
= atoi(buffer
);
152 if (appkey
) RegCloseKey( appkey
);
153 if (hkey
) RegCloseKey( hkey
);
155 TRACE("ds_hel_buflen = %d\n", ds_hel_buflen
);
156 TRACE("ds_snd_queue_max = %d\n", ds_snd_queue_max
);
159 static const char * get_device_id(LPCGUID pGuid
)
161 if (IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuid
))
162 return "DSDEVID_DefaultPlayback";
163 else if (IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuid
))
164 return "DSDEVID_DefaultVoicePlayback";
165 else if (IsEqualGUID(&DSDEVID_DefaultCapture
, pGuid
))
166 return "DSDEVID_DefaultCapture";
167 else if (IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuid
))
168 return "DSDEVID_DefaultVoiceCapture";
169 return debugstr_guid(pGuid
);
172 static HRESULT
get_mmdevenum(IMMDeviceEnumerator
**devenum
)
176 init_hr
= CoInitialize(NULL
);
178 hr
= CoCreateInstance(&CLSID_MMDeviceEnumerator
, NULL
,
179 CLSCTX_INPROC_SERVER
, &IID_IMMDeviceEnumerator
, (void**)devenum
);
181 if(SUCCEEDED(init_hr
))
184 ERR("CoCreateInstance failed: %08x\n", hr
);
191 static void release_mmdevenum(IMMDeviceEnumerator
*devenum
, HRESULT init_hr
)
193 IMMDeviceEnumerator_Release(devenum
);
194 if(SUCCEEDED(init_hr
))
198 static HRESULT
get_mmdevice_guid(IMMDevice
*device
, IPropertyStore
*ps
,
205 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
207 WARN("OpenPropertyStore failed: %08x\n", hr
);
211 IPropertyStore_AddRef(ps
);
213 PropVariantInit(&pv
);
215 hr
= IPropertyStore_GetValue(ps
, &PKEY_AudioEndpoint_GUID
, &pv
);
217 IPropertyStore_Release(ps
);
218 WARN("GetValue(GUID) failed: %08x\n", hr
);
222 CLSIDFromString(pv
.u
.pwszVal
, guid
);
224 PropVariantClear(&pv
);
225 IPropertyStore_Release(ps
);
230 /***************************************************************************
231 * GetDeviceID [DSOUND.9]
233 * Retrieves unique identifier of default device specified
236 * pGuidSrc [I] Address of device GUID.
237 * pGuidDest [O] Address to receive unique device GUID.
241 * Failure: DSERR_INVALIDPARAM
244 * pGuidSrc is a valid device GUID or DSDEVID_DefaultPlayback,
245 * DSDEVID_DefaultCapture, DSDEVID_DefaultVoicePlayback, or
246 * DSDEVID_DefaultVoiceCapture.
247 * Returns pGuidSrc if pGuidSrc is a valid device or the device
248 * GUID for the specified constants.
250 HRESULT WINAPI
GetDeviceID(LPCGUID pGuidSrc
, LPGUID pGuidDest
)
252 IMMDeviceEnumerator
*devenum
;
253 EDataFlow flow
= (EDataFlow
)-1;
254 ERole role
= (ERole
)-1;
257 TRACE("(%s,%p)\n", get_device_id(pGuidSrc
),pGuidDest
);
259 if(!pGuidSrc
|| !pGuidDest
)
260 return DSERR_INVALIDPARAM
;
262 init_hr
= get_mmdevenum(&devenum
);
266 if(IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuidSrc
)){
269 }else if(IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuidSrc
)){
270 role
= eCommunications
;
272 }else if(IsEqualGUID(&DSDEVID_DefaultCapture
, pGuidSrc
)){
275 }else if(IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuidSrc
)){
276 role
= eCommunications
;
280 if(role
!= (ERole
)-1 && flow
!= (EDataFlow
)-1){
283 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
,
284 flow
, role
, &device
);
286 WARN("GetDefaultAudioEndpoint failed: %08x\n", hr
);
287 release_mmdevenum(devenum
, init_hr
);
288 return DSERR_NODRIVER
;
291 hr
= get_mmdevice_guid(device
, NULL
, pGuidDest
);
292 IMMDevice_Release(device
);
294 release_mmdevenum(devenum
, init_hr
);
296 return (hr
== S_OK
) ? DS_OK
: hr
;
299 release_mmdevenum(devenum
, init_hr
);
301 *pGuidDest
= *pGuidSrc
;
308 LPDSENUMCALLBACKA callA
;
312 static BOOL CALLBACK
a_to_w_callback(LPGUID guid
, LPCWSTR descW
, LPCWSTR modW
, LPVOID data
)
314 struct morecontext
*context
= data
;
315 char descA
[MAXPNAMELEN
], modA
[MAXPNAMELEN
];
317 WideCharToMultiByte(CP_ACP
, 0, descW
, -1, descA
, sizeof(descA
), NULL
, NULL
);
318 WideCharToMultiByte(CP_ACP
, 0, modW
, -1, modA
, sizeof(modA
), NULL
, NULL
);
320 return context
->callA(guid
, descA
, modA
, context
->data
);
323 /***************************************************************************
324 * DirectSoundEnumerateA [DSOUND.2]
326 * Enumerate all DirectSound drivers installed in the system
329 * lpDSEnumCallback [I] Address of callback function.
330 * lpContext [I] Address of user defined context passed to callback function.
334 * Failure: DSERR_INVALIDPARAM
336 HRESULT WINAPI
DirectSoundEnumerateA(
337 LPDSENUMCALLBACKA lpDSEnumCallback
,
340 struct morecontext context
;
342 if (lpDSEnumCallback
== NULL
) {
343 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
344 return DSERR_INVALIDPARAM
;
347 context
.callA
= lpDSEnumCallback
;
348 context
.data
= lpContext
;
350 return DirectSoundEnumerateW(a_to_w_callback
, &context
);
353 HRESULT
get_mmdevice(EDataFlow flow
, const GUID
*tgt
, IMMDevice
**device
)
355 IMMDeviceEnumerator
*devenum
;
356 IMMDeviceCollection
*coll
;
360 init_hr
= get_mmdevenum(&devenum
);
364 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(devenum
, flow
,
365 DEVICE_STATE_ACTIVE
, &coll
);
367 WARN("EnumAudioEndpoints failed: %08x\n", hr
);
368 release_mmdevenum(devenum
, init_hr
);
372 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
374 IMMDeviceCollection_Release(coll
);
375 release_mmdevenum(devenum
, init_hr
);
376 WARN("GetCount failed: %08x\n", hr
);
380 for(i
= 0; i
< count
; ++i
){
383 hr
= IMMDeviceCollection_Item(coll
, i
, device
);
387 hr
= get_mmdevice_guid(*device
, NULL
, &guid
);
389 IMMDevice_Release(*device
);
393 if(IsEqualGUID(&guid
, tgt
)){
394 IMMDeviceCollection_Release(coll
);
395 release_mmdevenum(devenum
, init_hr
);
399 IMMDevice_Release(*device
);
402 WARN("No device with GUID %s found!\n", wine_dbgstr_guid(tgt
));
404 IMMDeviceCollection_Release(coll
);
405 release_mmdevenum(devenum
, init_hr
);
407 return DSERR_INVALIDPARAM
;
410 static BOOL
send_device(IMMDevice
*device
, GUID
*guid
,
411 LPDSENUMCALLBACKW cb
, void *user
)
418 PropVariantInit(&pv
);
420 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
422 WARN("OpenPropertyStore failed: %08x\n", hr
);
426 hr
= get_mmdevice_guid(device
, ps
, guid
);
428 IPropertyStore_Release(ps
);
432 hr
= IPropertyStore_GetValue(ps
,
433 (const PROPERTYKEY
*)&DEVPKEY_Device_FriendlyName
, &pv
);
435 IPropertyStore_Release(ps
);
436 WARN("GetValue(FriendlyName) failed: %08x\n", hr
);
440 TRACE("Calling back with %s (%s)\n", wine_dbgstr_guid(guid
),
441 wine_dbgstr_w(pv
.u
.pwszVal
));
443 keep_going
= cb(guid
, pv
.u
.pwszVal
, wine_vxd_drv
, user
);
445 PropVariantClear(&pv
);
446 IPropertyStore_Release(ps
);
451 /* S_FALSE means the callback returned FALSE at some point
452 * S_OK means the callback always returned TRUE */
453 HRESULT
enumerate_mmdevices(EDataFlow flow
, GUID
*guids
,
454 LPDSENUMCALLBACKW cb
, void *user
)
456 IMMDeviceEnumerator
*devenum
;
457 IMMDeviceCollection
*coll
;
458 IMMDevice
*defdev
= NULL
;
463 static const WCHAR primary_desc
[] = {'P','r','i','m','a','r','y',' ',
464 'S','o','u','n','d',' ','D','r','i','v','e','r',0};
465 static const WCHAR empty_drv
[] = {0};
467 init_hr
= get_mmdevenum(&devenum
);
471 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(devenum
, flow
,
472 DEVICE_STATE_ACTIVE
, &coll
);
474 release_mmdevenum(devenum
, init_hr
);
475 WARN("EnumAudioEndpoints failed: %08x\n", hr
);
479 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
481 IMMDeviceCollection_Release(coll
);
482 release_mmdevenum(devenum
, init_hr
);
483 WARN("GetCount failed: %08x\n", hr
);
488 release_mmdevenum(devenum
, init_hr
);
492 TRACE("Calling back with NULL (%s)\n", wine_dbgstr_w(primary_desc
));
493 keep_going
= cb(NULL
, primary_desc
, empty_drv
, user
);
495 /* always send the default device first */
497 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
, flow
,
498 eMultimedia
, &defdev
);
503 keep_going
= send_device(defdev
, &guids
[0], cb
, user
);
508 for(i
= 0; keep_going
&& i
< count
; ++i
){
511 hr
= IMMDeviceCollection_Item(coll
, i
, &device
);
513 WARN("Item failed: %08x\n", hr
);
517 if(device
!= defdev
){
518 send_device(device
, &guids
[n
], cb
, user
);
522 IMMDevice_Release(device
);
526 IMMDevice_Release(defdev
);
527 IMMDeviceCollection_Release(coll
);
529 release_mmdevenum(devenum
, init_hr
);
531 return (keep_going
== TRUE
) ? S_OK
: S_FALSE
;
534 /***************************************************************************
535 * DirectSoundEnumerateW [DSOUND.3]
537 * Enumerate all DirectSound drivers installed in the system
540 * lpDSEnumCallback [I] Address of callback function.
541 * lpContext [I] Address of user defined context passed to callback function.
545 * Failure: DSERR_INVALIDPARAM
547 HRESULT WINAPI
DirectSoundEnumerateW(
548 LPDSENUMCALLBACKW lpDSEnumCallback
,
553 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
555 if (lpDSEnumCallback
== NULL
) {
556 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
557 return DSERR_INVALIDPARAM
;
560 setup_dsound_options();
562 hr
= enumerate_mmdevices(eRender
, DSOUND_renderer_guids
,
563 lpDSEnumCallback
, lpContext
);
564 return SUCCEEDED(hr
) ? DS_OK
: hr
;
567 /***************************************************************************
568 * DirectSoundCaptureEnumerateA [DSOUND.7]
570 * Enumerate all DirectSound drivers installed in the system.
573 * lpDSEnumCallback [I] Address of callback function.
574 * lpContext [I] Address of user defined context passed to callback function.
578 * Failure: DSERR_INVALIDPARAM
580 HRESULT WINAPI
DirectSoundCaptureEnumerateA(
581 LPDSENUMCALLBACKA lpDSEnumCallback
,
584 struct morecontext context
;
586 if (lpDSEnumCallback
== NULL
) {
587 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
588 return DSERR_INVALIDPARAM
;
591 context
.callA
= lpDSEnumCallback
;
592 context
.data
= lpContext
;
594 return DirectSoundCaptureEnumerateW(a_to_w_callback
, &context
);
597 /***************************************************************************
598 * DirectSoundCaptureEnumerateW [DSOUND.8]
600 * Enumerate all DirectSound drivers installed in the system.
603 * lpDSEnumCallback [I] Address of callback function.
604 * lpContext [I] Address of user defined context passed to callback function.
608 * Failure: DSERR_INVALIDPARAM
611 DirectSoundCaptureEnumerateW(
612 LPDSENUMCALLBACKW lpDSEnumCallback
,
617 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
619 if (lpDSEnumCallback
== NULL
) {
620 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
621 return DSERR_INVALIDPARAM
;
624 setup_dsound_options();
626 hr
= enumerate_mmdevices(eCapture
, DSOUND_capture_guids
,
627 lpDSEnumCallback
, lpContext
);
628 return SUCCEEDED(hr
) ? DS_OK
: hr
;
631 /*******************************************************************************
632 * DirectSound ClassFactory
635 typedef HRESULT (*FnCreateInstance
)(REFIID riid
, LPVOID
*ppobj
);
638 IClassFactory IClassFactory_iface
;
640 FnCreateInstance pfnCreateInstance
;
643 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
645 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
648 static HRESULT WINAPI
649 DSCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, LPVOID
*ppobj
)
651 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
652 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppobj
);
655 if (IsEqualIID(riid
, &IID_IUnknown
) ||
656 IsEqualIID(riid
, &IID_IClassFactory
))
659 IClassFactory_AddRef(iface
);
663 return E_NOINTERFACE
;
666 static ULONG WINAPI
DSCF_AddRef(LPCLASSFACTORY iface
)
671 static ULONG WINAPI
DSCF_Release(LPCLASSFACTORY iface
)
673 /* static class, won't be freed */
677 static HRESULT WINAPI
DSCF_CreateInstance(
678 LPCLASSFACTORY iface
,
683 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
684 TRACE("(%p, %p, %s, %p)\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
687 return CLASS_E_NOAGGREGATION
;
690 WARN("invalid parameter\n");
691 return DSERR_INVALIDPARAM
;
694 return This
->pfnCreateInstance(riid
, ppobj
);
697 static HRESULT WINAPI
DSCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
699 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
700 FIXME("(%p, %d) stub!\n", This
, dolock
);
704 static const IClassFactoryVtbl DSCF_Vtbl
= {
712 static IClassFactoryImpl DSOUND_CF
[] = {
713 { { &DSCF_Vtbl
}, &CLSID_DirectSound
, DSOUND_Create
},
714 { { &DSCF_Vtbl
}, &CLSID_DirectSound8
, DSOUND_Create8
},
715 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture
, DSOUND_CaptureCreate
},
716 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture8
, DSOUND_CaptureCreate8
},
717 { { &DSCF_Vtbl
}, &CLSID_DirectSoundFullDuplex
, DSOUND_FullDuplexCreate
},
718 { { &DSCF_Vtbl
}, &CLSID_DirectSoundPrivate
, IKsPrivatePropertySetImpl_Create
},
719 { { NULL
}, NULL
, NULL
}
722 /*******************************************************************************
723 * DllGetClassObject [DSOUND.@]
724 * Retrieves class object from a DLL object
727 * Docs say returns STDAPI
730 * rclsid [I] CLSID for the class object
731 * riid [I] Reference to identifier of interface for class object
732 * ppv [O] Address of variable to receive interface pointer for riid
736 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
739 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
742 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
745 WARN("invalid parameter\n");
751 if (!IsEqualIID(riid
, &IID_IClassFactory
) &&
752 !IsEqualIID(riid
, &IID_IUnknown
)) {
753 WARN("no interface for %s\n", debugstr_guid(riid
));
754 return E_NOINTERFACE
;
757 while (NULL
!= DSOUND_CF
[i
].rclsid
) {
758 if (IsEqualGUID(rclsid
, DSOUND_CF
[i
].rclsid
)) {
759 DSCF_AddRef(&DSOUND_CF
[i
].IClassFactory_iface
);
760 *ppv
= &DSOUND_CF
[i
];
766 WARN("(%s, %s, %p): no class found.\n", debugstr_guid(rclsid
),
767 debugstr_guid(riid
), ppv
);
768 return CLASS_E_CLASSNOTAVAILABLE
;
772 /*******************************************************************************
773 * DllCanUnloadNow [DSOUND.4]
774 * Determines whether the DLL is in use.
777 * Can unload now: S_OK
778 * Cannot unload now (the DLL is still active): S_FALSE
780 HRESULT WINAPI
DllCanUnloadNow(void)
785 #define INIT_GUID(guid, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
786 guid.Data1 = l; guid.Data2 = w1; guid.Data3 = w2; \
787 guid.Data4[0] = b1; guid.Data4[1] = b2; guid.Data4[2] = b3; \
788 guid.Data4[3] = b4; guid.Data4[4] = b5; guid.Data4[5] = b6; \
789 guid.Data4[6] = b7; guid.Data4[7] = b8;
791 /***********************************************************************
792 * DllMain (DSOUND.init)
794 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
796 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpvReserved
);
799 case DLL_PROCESS_ATTACH
:
801 DisableThreadLibraryCalls(hInstDLL
);
802 /* Increase refcount on dsound by 1 */
803 GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
, (LPCWSTR
)hInstDLL
, &hInstDLL
);
805 case DLL_PROCESS_DETACH
:
806 if (lpvReserved
) break;
807 DeleteCriticalSection(&DSOUND_renderers_lock
);
808 DeleteCriticalSection(&DSOUND_capturers_lock
);
814 /***********************************************************************
815 * DllRegisterServer (DSOUND.@)
817 HRESULT WINAPI
DllRegisterServer(void)
819 return __wine_register_resources( instance
);
822 /***********************************************************************
823 * DllUnregisterServer (DSOUND.@)
825 HRESULT WINAPI
DllUnregisterServer(void)
827 return __wine_unregister_resources( instance
);