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
47 #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 const WCHAR wine_vxd_drv
[] = L
"winemm.vxd";
93 /* All default settings, you most likely don't want to touch these, see wiki on UsefulRegistryKeys */
94 int ds_hel_buflen
= 32768 * 2;
97 * Get a config key from either the app-specific or the default config
100 static inline DWORD
get_config_key( HKEY defkey
, HKEY appkey
, const char *name
,
101 char *buffer
, DWORD size
)
103 if (appkey
&& !RegQueryValueExA( appkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
104 if (defkey
&& !RegQueryValueExA( defkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
105 return ERROR_FILE_NOT_FOUND
;
110 * Setup the dsound options.
113 void setup_dsound_options(void)
115 char buffer
[MAX_PATH
+16];
116 HKEY hkey
, appkey
= 0;
119 buffer
[MAX_PATH
]='\0';
121 /* @@ Wine registry key: HKCU\Software\Wine\DirectSound */
122 if (RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\DirectSound", &hkey
)) hkey
= 0;
124 len
= GetModuleFileNameA( 0, buffer
, MAX_PATH
);
125 if (len
&& len
< MAX_PATH
)
128 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectSound */
129 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\AppDefaults", &tmpkey
))
131 char *p
, *appname
= buffer
;
132 if ((p
= strrchr( appname
, '/' ))) appname
= p
+ 1;
133 if ((p
= strrchr( appname
, '\\' ))) appname
= p
+ 1;
134 strcat( appname
, "\\DirectSound" );
135 TRACE("appname = [%s]\n", appname
);
136 if (RegOpenKeyA( tmpkey
, appname
, &appkey
)) appkey
= 0;
137 RegCloseKey( tmpkey
);
143 if (!get_config_key( hkey
, appkey
, "HelBuflen", buffer
, MAX_PATH
))
144 ds_hel_buflen
= atoi(buffer
);
146 if (appkey
) RegCloseKey( appkey
);
147 if (hkey
) RegCloseKey( hkey
);
149 TRACE("ds_hel_buflen = %d\n", ds_hel_buflen
);
152 static const char * get_device_id(LPCGUID pGuid
)
154 if (IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuid
))
155 return "DSDEVID_DefaultPlayback";
156 else if (IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuid
))
157 return "DSDEVID_DefaultVoicePlayback";
158 else if (IsEqualGUID(&DSDEVID_DefaultCapture
, pGuid
))
159 return "DSDEVID_DefaultCapture";
160 else if (IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuid
))
161 return "DSDEVID_DefaultVoiceCapture";
162 return debugstr_guid(pGuid
);
165 static HRESULT
get_mmdevenum(IMMDeviceEnumerator
**devenum
)
169 init_hr
= CoInitialize(NULL
);
171 hr
= CoCreateInstance(&CLSID_MMDeviceEnumerator
, NULL
,
172 CLSCTX_INPROC_SERVER
, &IID_IMMDeviceEnumerator
, (void**)devenum
);
174 if(SUCCEEDED(init_hr
))
177 ERR("CoCreateInstance failed: %08lx\n", hr
);
184 static void release_mmdevenum(IMMDeviceEnumerator
*devenum
, HRESULT init_hr
)
186 IMMDeviceEnumerator_Release(devenum
);
187 if(SUCCEEDED(init_hr
))
191 static HRESULT
get_mmdevice_guid(IMMDevice
*device
, IPropertyStore
*ps
,
198 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
200 WARN("OpenPropertyStore failed: %08lx\n", hr
);
204 IPropertyStore_AddRef(ps
);
206 PropVariantInit(&pv
);
208 hr
= IPropertyStore_GetValue(ps
, &PKEY_AudioEndpoint_GUID
, &pv
);
210 IPropertyStore_Release(ps
);
211 WARN("GetValue(GUID) failed: %08lx\n", hr
);
215 CLSIDFromString(pv
.pwszVal
, guid
);
217 PropVariantClear(&pv
);
218 IPropertyStore_Release(ps
);
223 /***************************************************************************
224 * GetDeviceID [DSOUND.9]
226 * Retrieves unique identifier of default device specified
229 * pGuidSrc [I] Address of device GUID.
230 * pGuidDest [O] Address to receive unique device GUID.
234 * Failure: DSERR_INVALIDPARAM
237 * pGuidSrc is a valid device GUID or DSDEVID_DefaultPlayback,
238 * DSDEVID_DefaultCapture, DSDEVID_DefaultVoicePlayback, or
239 * DSDEVID_DefaultVoiceCapture.
240 * Returns pGuidSrc if pGuidSrc is a valid device or the device
241 * GUID for the specified constants.
243 HRESULT WINAPI
GetDeviceID(LPCGUID pGuidSrc
, LPGUID pGuidDest
)
245 IMMDeviceEnumerator
*devenum
;
246 EDataFlow flow
= (EDataFlow
)-1;
247 ERole role
= (ERole
)-1;
250 TRACE("(%s,%p)\n", get_device_id(pGuidSrc
),pGuidDest
);
252 if(!pGuidSrc
|| !pGuidDest
)
253 return DSERR_INVALIDPARAM
;
255 init_hr
= get_mmdevenum(&devenum
);
259 if(IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuidSrc
)){
262 }else if(IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuidSrc
)){
263 role
= eCommunications
;
265 }else if(IsEqualGUID(&DSDEVID_DefaultCapture
, pGuidSrc
)){
268 }else if(IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuidSrc
)){
269 role
= eCommunications
;
273 if(role
!= (ERole
)-1 && flow
!= (EDataFlow
)-1){
276 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
,
277 flow
, role
, &device
);
279 WARN("GetDefaultAudioEndpoint failed: %08lx\n", hr
);
280 release_mmdevenum(devenum
, init_hr
);
281 return DSERR_NODRIVER
;
284 hr
= get_mmdevice_guid(device
, NULL
, pGuidDest
);
285 IMMDevice_Release(device
);
287 release_mmdevenum(devenum
, init_hr
);
289 return (hr
== S_OK
) ? DS_OK
: hr
;
292 release_mmdevenum(devenum
, init_hr
);
294 *pGuidDest
= *pGuidSrc
;
301 LPDSENUMCALLBACKA callA
;
305 static BOOL CALLBACK
a_to_w_callback(LPGUID guid
, LPCWSTR descW
, LPCWSTR modW
, LPVOID data
)
307 struct morecontext
*context
= data
;
308 char descA
[MAXPNAMELEN
], modA
[MAXPNAMELEN
];
310 WideCharToMultiByte(CP_ACP
, 0, descW
, -1, descA
, sizeof(descA
), NULL
, NULL
);
311 WideCharToMultiByte(CP_ACP
, 0, modW
, -1, modA
, sizeof(modA
), NULL
, NULL
);
313 return context
->callA(guid
, descA
, modA
, context
->data
);
316 /***************************************************************************
317 * DirectSoundEnumerateA [DSOUND.2]
319 * Enumerate all DirectSound drivers installed in the system
322 * lpDSEnumCallback [I] Address of callback function.
323 * lpContext [I] Address of user defined context passed to callback function.
327 * Failure: DSERR_INVALIDPARAM
329 HRESULT WINAPI
DirectSoundEnumerateA(
330 LPDSENUMCALLBACKA lpDSEnumCallback
,
333 struct morecontext context
;
335 if (lpDSEnumCallback
== NULL
) {
336 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
337 return DSERR_INVALIDPARAM
;
340 context
.callA
= lpDSEnumCallback
;
341 context
.data
= lpContext
;
343 return DirectSoundEnumerateW(a_to_w_callback
, &context
);
346 HRESULT
get_mmdevice(EDataFlow flow
, const GUID
*tgt
, IMMDevice
**device
)
348 IMMDeviceEnumerator
*devenum
;
349 IMMDeviceCollection
*coll
;
353 init_hr
= get_mmdevenum(&devenum
);
357 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(devenum
, flow
,
358 DEVICE_STATE_ACTIVE
, &coll
);
360 WARN("EnumAudioEndpoints failed: %08lx\n", hr
);
361 release_mmdevenum(devenum
, init_hr
);
365 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
367 IMMDeviceCollection_Release(coll
);
368 release_mmdevenum(devenum
, init_hr
);
369 WARN("GetCount failed: %08lx\n", hr
);
373 for(i
= 0; i
< count
; ++i
){
376 hr
= IMMDeviceCollection_Item(coll
, i
, device
);
380 hr
= get_mmdevice_guid(*device
, NULL
, &guid
);
382 IMMDevice_Release(*device
);
386 if(IsEqualGUID(&guid
, tgt
)){
387 IMMDeviceCollection_Release(coll
);
388 release_mmdevenum(devenum
, init_hr
);
392 IMMDevice_Release(*device
);
395 WARN("No device with GUID %s found!\n", wine_dbgstr_guid(tgt
));
397 IMMDeviceCollection_Release(coll
);
398 release_mmdevenum(devenum
, init_hr
);
400 return DSERR_INVALIDPARAM
;
403 static BOOL
send_device(IMMDevice
*device
, GUID
*guid
,
404 LPDSENUMCALLBACKW cb
, void *user
)
411 PropVariantInit(&pv
);
413 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
415 WARN("OpenPropertyStore failed: %08lx\n", hr
);
419 hr
= get_mmdevice_guid(device
, ps
, guid
);
421 IPropertyStore_Release(ps
);
425 hr
= IPropertyStore_GetValue(ps
,
426 (const PROPERTYKEY
*)&DEVPKEY_Device_FriendlyName
, &pv
);
428 IPropertyStore_Release(ps
);
429 WARN("GetValue(FriendlyName) failed: %08lx\n", hr
);
433 TRACE("Calling back with %s (%s)\n", wine_dbgstr_guid(guid
),
434 wine_dbgstr_w(pv
.pwszVal
));
436 keep_going
= cb(guid
, pv
.pwszVal
, wine_vxd_drv
, user
);
438 PropVariantClear(&pv
);
439 IPropertyStore_Release(ps
);
444 /* S_FALSE means the callback returned FALSE at some point
445 * S_OK means the callback always returned TRUE */
446 HRESULT
enumerate_mmdevices(EDataFlow flow
, GUID
*guids
,
447 LPDSENUMCALLBACKW cb
, void *user
)
449 IMMDeviceEnumerator
*devenum
;
450 IMMDeviceCollection
*coll
;
451 IMMDevice
*defdev
= NULL
;
456 init_hr
= get_mmdevenum(&devenum
);
460 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(devenum
, flow
,
461 DEVICE_STATE_ACTIVE
, &coll
);
463 release_mmdevenum(devenum
, init_hr
);
464 WARN("EnumAudioEndpoints failed: %08lx\n", hr
);
468 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
470 IMMDeviceCollection_Release(coll
);
471 release_mmdevenum(devenum
, init_hr
);
472 WARN("GetCount failed: %08lx\n", hr
);
477 IMMDeviceCollection_Release(coll
);
478 release_mmdevenum(devenum
, init_hr
);
482 TRACE("Calling back with NULL (Primary Sound Driver)\n");
483 keep_going
= cb(NULL
, L
"Primary Sound Driver", L
"", user
);
485 /* always send the default device first */
487 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
, flow
,
488 eMultimedia
, &defdev
);
493 keep_going
= send_device(defdev
, &guids
[0], cb
, user
);
498 for(i
= 0; keep_going
&& i
< count
; ++i
){
501 hr
= IMMDeviceCollection_Item(coll
, i
, &device
);
503 WARN("Item failed: %08lx\n", hr
);
507 if(device
!= defdev
){
508 keep_going
= send_device(device
, &guids
[n
], cb
, user
);
512 IMMDevice_Release(device
);
516 IMMDevice_Release(defdev
);
517 IMMDeviceCollection_Release(coll
);
519 release_mmdevenum(devenum
, init_hr
);
521 return keep_going
? S_OK
: S_FALSE
;
524 /***************************************************************************
525 * DirectSoundEnumerateW [DSOUND.3]
527 * Enumerate all DirectSound drivers installed in the system
530 * lpDSEnumCallback [I] Address of callback function.
531 * lpContext [I] Address of user defined context passed to callback function.
535 * Failure: DSERR_INVALIDPARAM
537 HRESULT WINAPI
DirectSoundEnumerateW(
538 LPDSENUMCALLBACKW lpDSEnumCallback
,
543 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
545 if (lpDSEnumCallback
== NULL
) {
546 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
547 return DSERR_INVALIDPARAM
;
550 setup_dsound_options();
552 hr
= enumerate_mmdevices(eRender
, DSOUND_renderer_guids
,
553 lpDSEnumCallback
, lpContext
);
554 return SUCCEEDED(hr
) ? DS_OK
: hr
;
557 /***************************************************************************
558 * DirectSoundCaptureEnumerateA [DSOUND.7]
560 * Enumerate all DirectSound drivers installed in the system.
563 * lpDSEnumCallback [I] Address of callback function.
564 * lpContext [I] Address of user defined context passed to callback function.
568 * Failure: DSERR_INVALIDPARAM
570 HRESULT WINAPI
DirectSoundCaptureEnumerateA(
571 LPDSENUMCALLBACKA lpDSEnumCallback
,
574 struct morecontext context
;
576 if (lpDSEnumCallback
== NULL
) {
577 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
578 return DSERR_INVALIDPARAM
;
581 context
.callA
= lpDSEnumCallback
;
582 context
.data
= lpContext
;
584 return DirectSoundCaptureEnumerateW(a_to_w_callback
, &context
);
587 /***************************************************************************
588 * DirectSoundCaptureEnumerateW [DSOUND.8]
590 * Enumerate all DirectSound drivers installed in the system.
593 * lpDSEnumCallback [I] Address of callback function.
594 * lpContext [I] Address of user defined context passed to callback function.
598 * Failure: DSERR_INVALIDPARAM
601 DirectSoundCaptureEnumerateW(
602 LPDSENUMCALLBACKW lpDSEnumCallback
,
607 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
609 if (lpDSEnumCallback
== NULL
) {
610 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
611 return DSERR_INVALIDPARAM
;
614 setup_dsound_options();
616 hr
= enumerate_mmdevices(eCapture
, DSOUND_capture_guids
,
617 lpDSEnumCallback
, lpContext
);
618 return SUCCEEDED(hr
) ? DS_OK
: hr
;
621 /*******************************************************************************
622 * DirectSound ClassFactory
625 typedef HRESULT (*FnCreateInstance
)(REFIID riid
, LPVOID
*ppobj
);
628 IClassFactory IClassFactory_iface
;
630 FnCreateInstance pfnCreateInstance
;
633 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
635 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
638 static HRESULT WINAPI
639 DSCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, LPVOID
*ppobj
)
641 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
642 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppobj
);
645 if (IsEqualIID(riid
, &IID_IUnknown
) ||
646 IsEqualIID(riid
, &IID_IClassFactory
))
649 IClassFactory_AddRef(iface
);
653 return E_NOINTERFACE
;
656 static ULONG WINAPI
DSCF_AddRef(LPCLASSFACTORY iface
)
661 static ULONG WINAPI
DSCF_Release(LPCLASSFACTORY iface
)
663 /* static class, won't be freed */
667 static HRESULT WINAPI
DSCF_CreateInstance(
668 LPCLASSFACTORY iface
,
673 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
674 TRACE("(%p, %p, %s, %p)\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
677 return CLASS_E_NOAGGREGATION
;
680 WARN("invalid parameter\n");
681 return DSERR_INVALIDPARAM
;
684 return This
->pfnCreateInstance(riid
, ppobj
);
687 static HRESULT WINAPI
DSCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
689 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
690 FIXME("(%p, %d) stub!\n", This
, dolock
);
694 static const IClassFactoryVtbl DSCF_Vtbl
= {
702 static IClassFactoryImpl DSOUND_CF
[] = {
703 { { &DSCF_Vtbl
}, &CLSID_DirectSound
, DSOUND_Create
},
704 { { &DSCF_Vtbl
}, &CLSID_DirectSound8
, DSOUND_Create8
},
705 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture
, DSOUND_CaptureCreate
},
706 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture8
, DSOUND_CaptureCreate8
},
707 { { &DSCF_Vtbl
}, &CLSID_DirectSoundFullDuplex
, DSOUND_FullDuplexCreate
},
708 { { &DSCF_Vtbl
}, &CLSID_DirectSoundPrivate
, IKsPrivatePropertySetImpl_Create
},
709 { { NULL
}, NULL
, NULL
}
712 /*******************************************************************************
713 * DllGetClassObject [DSOUND.@]
714 * Retrieves class object from a DLL object
717 * Docs say returns STDAPI
720 * rclsid [I] CLSID for the class object
721 * riid [I] Reference to identifier of interface for class object
722 * ppv [O] Address of variable to receive interface pointer for riid
726 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
729 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
732 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
735 WARN("invalid parameter\n");
741 if (!IsEqualIID(riid
, &IID_IClassFactory
) &&
742 !IsEqualIID(riid
, &IID_IUnknown
)) {
743 WARN("no interface for %s\n", debugstr_guid(riid
));
744 return E_NOINTERFACE
;
747 while (NULL
!= DSOUND_CF
[i
].rclsid
) {
748 if (IsEqualGUID(rclsid
, DSOUND_CF
[i
].rclsid
)) {
749 DSCF_AddRef(&DSOUND_CF
[i
].IClassFactory_iface
);
750 *ppv
= &DSOUND_CF
[i
];
756 WARN("(%s, %s, %p): no class found.\n", debugstr_guid(rclsid
),
757 debugstr_guid(riid
), ppv
);
758 return CLASS_E_CLASSNOTAVAILABLE
;
762 #define INIT_GUID(guid, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
763 guid.Data1 = l; guid.Data2 = w1; guid.Data3 = w2; \
764 guid.Data4[0] = b1; guid.Data4[1] = b2; guid.Data4[2] = b3; \
765 guid.Data4[3] = b4; guid.Data4[4] = b5; guid.Data4[5] = b6; \
766 guid.Data4[6] = b7; guid.Data4[7] = b8;
768 /***********************************************************************
769 * DllMain (DSOUND.init)
771 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
773 TRACE("(%p %ld %p)\n", hInstDLL
, fdwReason
, lpvReserved
);
776 case DLL_PROCESS_ATTACH
:
777 DisableThreadLibraryCalls(hInstDLL
);
778 /* Increase refcount on dsound by 1 */
779 GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
, (LPCWSTR
)hInstDLL
, &hInstDLL
);
781 case DLL_PROCESS_DETACH
:
782 if (lpvReserved
) break;
783 DeleteCriticalSection(&DSOUND_renderers_lock
);
784 DeleteCriticalSection(&DSOUND_capturers_lock
);