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 static IMMDeviceEnumerator
*g_devenum
;
92 static CRITICAL_SECTION g_devenum_lock
;
93 static CRITICAL_SECTION_DEBUG g_devenum_lock_debug
=
95 0, 0, &g_devenum_lock
,
96 { &g_devenum_lock_debug
.ProcessLocksList
, &g_devenum_lock_debug
.ProcessLocksList
},
97 0, 0, { (DWORD_PTR
)(__FILE__
": g_devenum_lock") }
99 static CRITICAL_SECTION g_devenum_lock
= { &g_devenum_lock_debug
, -1, 0, 0, 0, 0 };
100 static HANDLE g_devenum_thread
;
102 WCHAR wine_vxd_drv
[] = { 'w','i','n','e','m','m','.','v','x','d', 0 };
104 /* All default settings, you most likely don't want to touch these, see wiki on UsefulRegistryKeys */
105 int ds_hel_buflen
= 32768 * 2;
106 int ds_snd_queue_max
= 10;
107 int ds_snd_shadow_maxsize
= 2;
108 int ds_default_sample_rate
= 44100;
109 int ds_default_bits_per_sample
= 16;
110 static HINSTANCE instance
;
113 * Get a config key from either the app-specific or the default config
116 static inline DWORD
get_config_key( HKEY defkey
, HKEY appkey
, const char *name
,
117 char *buffer
, DWORD size
)
119 if (appkey
&& !RegQueryValueExA( appkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
120 if (defkey
&& !RegQueryValueExA( defkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
121 return ERROR_FILE_NOT_FOUND
;
126 * Setup the dsound options.
129 void setup_dsound_options(void)
131 char buffer
[MAX_PATH
+16];
132 HKEY hkey
, appkey
= 0;
135 buffer
[MAX_PATH
]='\0';
137 /* @@ Wine registry key: HKCU\Software\Wine\DirectSound */
138 if (RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\DirectSound", &hkey
)) hkey
= 0;
140 len
= GetModuleFileNameA( 0, buffer
, MAX_PATH
);
141 if (len
&& len
< MAX_PATH
)
144 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectSound */
145 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\AppDefaults", &tmpkey
))
147 char *p
, *appname
= buffer
;
148 if ((p
= strrchr( appname
, '/' ))) appname
= p
+ 1;
149 if ((p
= strrchr( appname
, '\\' ))) appname
= p
+ 1;
150 strcat( appname
, "\\DirectSound" );
151 TRACE("appname = [%s]\n", appname
);
152 if (RegOpenKeyA( tmpkey
, appname
, &appkey
)) appkey
= 0;
153 RegCloseKey( tmpkey
);
159 if (!get_config_key( hkey
, appkey
, "HelBuflen", buffer
, MAX_PATH
))
160 ds_hel_buflen
= atoi(buffer
);
162 if (!get_config_key( hkey
, appkey
, "SndQueueMax", buffer
, MAX_PATH
))
163 ds_snd_queue_max
= atoi(buffer
);
165 if (!get_config_key( hkey
, appkey
, "MaxShadowSize", buffer
, MAX_PATH
))
166 ds_snd_shadow_maxsize
= atoi(buffer
);
168 if (!get_config_key( hkey
, appkey
, "DefaultSampleRate", buffer
, MAX_PATH
))
169 ds_default_sample_rate
= atoi(buffer
);
171 if (!get_config_key( hkey
, appkey
, "DefaultBitsPerSample", buffer
, MAX_PATH
))
172 ds_default_bits_per_sample
= atoi(buffer
);
174 if (appkey
) RegCloseKey( appkey
);
175 if (hkey
) RegCloseKey( hkey
);
177 TRACE("ds_hel_buflen = %d\n", ds_hel_buflen
);
178 TRACE("ds_snd_queue_max = %d\n", ds_snd_queue_max
);
179 TRACE("ds_default_sample_rate = %d\n", ds_default_sample_rate
);
180 TRACE("ds_default_bits_per_sample = %d\n", ds_default_bits_per_sample
);
181 TRACE("ds_snd_shadow_maxsize = %d\n", ds_snd_shadow_maxsize
);
184 static const char * get_device_id(LPCGUID pGuid
)
186 if (IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuid
))
187 return "DSDEVID_DefaultPlayback";
188 else if (IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuid
))
189 return "DSDEVID_DefaultVoicePlayback";
190 else if (IsEqualGUID(&DSDEVID_DefaultCapture
, pGuid
))
191 return "DSDEVID_DefaultCapture";
192 else if (IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuid
))
193 return "DSDEVID_DefaultVoiceCapture";
194 return debugstr_guid(pGuid
);
197 /* The MMDeviceEnumerator object has to be created & destroyed
198 * from the same thread. */
199 static DWORD WINAPI
devenum_thread_proc(void *arg
)
205 hr
= CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
207 ERR("CoInitializeEx failed: %08x\n", hr
);
211 hr
= CoCreateInstance(&CLSID_MMDeviceEnumerator
, NULL
,
212 CLSCTX_INPROC_SERVER
, &IID_IMMDeviceEnumerator
, (void**)&g_devenum
);
214 ERR("CoCreateInstance failed: %08x\n", hr
);
221 PeekMessageW(&msg
, NULL
, WM_USER
, WM_USER
, PM_NOREMOVE
);
223 while(GetMessageW(&msg
, NULL
, 0, 0)){
225 DispatchMessageW(&msg
);
227 ERR("Unknown message: %04x\n", msg
.message
);
230 IMMDeviceEnumerator_Release(g_devenum
);
237 static IMMDeviceEnumerator
*get_mmdevenum(void)
242 EnterCriticalSection(&g_devenum_lock
);
245 LeaveCriticalSection(&g_devenum_lock
);
249 events
[0] = CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
251 g_devenum_thread
= CreateThread(NULL
, 0, devenum_thread_proc
,
253 if(!g_devenum_thread
){
254 LeaveCriticalSection(&g_devenum_lock
);
255 CloseHandle(events
[0]);
259 events
[1] = g_devenum_thread
;
260 wait
= WaitForMultipleObjects(2, events
, FALSE
, INFINITE
);
261 CloseHandle(events
[0]);
262 if(wait
!= WAIT_OBJECT_0
){
263 if(wait
== 1 + WAIT_OBJECT_0
){
264 CloseHandle(g_devenum_thread
);
265 g_devenum_thread
= NULL
;
267 LeaveCriticalSection(&g_devenum_lock
);
271 LeaveCriticalSection(&g_devenum_lock
);
276 static HRESULT
get_mmdevice_guid(IMMDevice
*device
, IPropertyStore
*ps
,
283 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
285 WARN("OpenPropertyStore failed: %08x\n", hr
);
289 IPropertyStore_AddRef(ps
);
291 PropVariantInit(&pv
);
293 hr
= IPropertyStore_GetValue(ps
, &PKEY_AudioEndpoint_GUID
, &pv
);
295 IPropertyStore_Release(ps
);
296 WARN("GetValue(GUID) failed: %08x\n", hr
);
300 CLSIDFromString(pv
.u
.pwszVal
, guid
);
302 PropVariantClear(&pv
);
303 IPropertyStore_Release(ps
);
308 /***************************************************************************
309 * GetDeviceID [DSOUND.9]
311 * Retrieves unique identifier of default device specified
314 * pGuidSrc [I] Address of device GUID.
315 * pGuidDest [O] Address to receive unique device GUID.
319 * Failure: DSERR_INVALIDPARAM
322 * pGuidSrc is a valid device GUID or DSDEVID_DefaultPlayback,
323 * DSDEVID_DefaultCapture, DSDEVID_DefaultVoicePlayback, or
324 * DSDEVID_DefaultVoiceCapture.
325 * Returns pGuidSrc if pGuidSrc is a valid device or the device
326 * GUID for the specified constants.
328 HRESULT WINAPI
GetDeviceID(LPCGUID pGuidSrc
, LPGUID pGuidDest
)
330 IMMDeviceEnumerator
*devenum
;
331 EDataFlow flow
= (EDataFlow
)-1;
332 ERole role
= (ERole
)-1;
335 TRACE("(%s,%p)\n", get_device_id(pGuidSrc
),pGuidDest
);
337 if(!pGuidSrc
|| !pGuidDest
)
338 return DSERR_INVALIDPARAM
;
340 devenum
= get_mmdevenum();
342 return DSERR_GENERIC
;
344 if(IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuidSrc
)){
347 }else if(IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuidSrc
)){
348 role
= eCommunications
;
350 }else if(IsEqualGUID(&DSDEVID_DefaultCapture
, pGuidSrc
)){
353 }else if(IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuidSrc
)){
354 role
= eCommunications
;
358 if(role
!= (ERole
)-1 && flow
!= (EDataFlow
)-1){
361 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
,
362 flow
, role
, &device
);
364 WARN("GetDefaultAudioEndpoint failed: %08x\n", hr
);
365 return DSERR_NODRIVER
;
368 hr
= get_mmdevice_guid(device
, NULL
, pGuidDest
);
369 IMMDevice_Release(device
);
371 return (hr
== S_OK
) ? DS_OK
: hr
;
374 *pGuidDest
= *pGuidSrc
;
381 LPDSENUMCALLBACKA callA
;
385 static BOOL CALLBACK
a_to_w_callback(LPGUID guid
, LPCWSTR descW
, LPCWSTR modW
, LPVOID data
)
387 struct morecontext
*context
= data
;
388 char descA
[MAXPNAMELEN
], modA
[MAXPNAMELEN
];
390 WideCharToMultiByte(CP_ACP
, 0, descW
, -1, descA
, sizeof(descA
), NULL
, NULL
);
391 WideCharToMultiByte(CP_ACP
, 0, modW
, -1, modA
, sizeof(modA
), NULL
, NULL
);
393 return context
->callA(guid
, descA
, modA
, context
->data
);
396 /***************************************************************************
397 * DirectSoundEnumerateA [DSOUND.2]
399 * Enumerate all DirectSound drivers installed in the system
402 * lpDSEnumCallback [I] Address of callback function.
403 * lpContext [I] Address of user defined context passed to callback function.
407 * Failure: DSERR_INVALIDPARAM
409 HRESULT WINAPI
DirectSoundEnumerateA(
410 LPDSENUMCALLBACKA lpDSEnumCallback
,
413 struct morecontext context
;
415 if (lpDSEnumCallback
== NULL
) {
416 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
417 return DSERR_INVALIDPARAM
;
420 context
.callA
= lpDSEnumCallback
;
421 context
.data
= lpContext
;
423 return DirectSoundEnumerateW(a_to_w_callback
, &context
);
426 HRESULT
get_mmdevice(EDataFlow flow
, const GUID
*tgt
, IMMDevice
**device
)
428 IMMDeviceEnumerator
*devenum
;
429 IMMDeviceCollection
*coll
;
433 devenum
= get_mmdevenum();
435 return DSERR_GENERIC
;
437 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(devenum
, flow
,
438 DEVICE_STATE_ACTIVE
, &coll
);
440 WARN("EnumAudioEndpoints failed: %08x\n", hr
);
444 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
446 IMMDeviceCollection_Release(coll
);
447 WARN("GetCount failed: %08x\n", hr
);
451 for(i
= 0; i
< count
; ++i
){
454 hr
= IMMDeviceCollection_Item(coll
, i
, device
);
458 hr
= get_mmdevice_guid(*device
, NULL
, &guid
);
460 IMMDevice_Release(*device
);
464 if(IsEqualGUID(&guid
, tgt
))
467 IMMDevice_Release(*device
);
470 WARN("No device with GUID %s found!\n", wine_dbgstr_guid(tgt
));
472 return DSERR_INVALIDPARAM
;
475 static BOOL
send_device(IMMDevice
*device
, GUID
*guid
,
476 LPDSENUMCALLBACKW cb
, void *user
)
483 PropVariantInit(&pv
);
485 hr
= IMMDevice_OpenPropertyStore(device
, STGM_READ
, &ps
);
487 WARN("OpenPropertyStore failed: %08x\n", hr
);
491 hr
= get_mmdevice_guid(device
, ps
, guid
);
493 IPropertyStore_Release(ps
);
497 hr
= IPropertyStore_GetValue(ps
,
498 (const PROPERTYKEY
*)&DEVPKEY_Device_FriendlyName
, &pv
);
500 IPropertyStore_Release(ps
);
501 WARN("GetValue(FriendlyName) failed: %08x\n", hr
);
505 TRACE("Calling back with %s (%s)\n", wine_dbgstr_guid(guid
),
506 wine_dbgstr_w(pv
.u
.pwszVal
));
508 keep_going
= cb(guid
, pv
.u
.pwszVal
, wine_vxd_drv
, user
);
510 PropVariantClear(&pv
);
511 IPropertyStore_Release(ps
);
516 /* S_FALSE means the callback returned FALSE at some point
517 * S_OK means the callback always returned TRUE */
518 HRESULT
enumerate_mmdevices(EDataFlow flow
, GUID
*guids
,
519 LPDSENUMCALLBACKW cb
, void *user
)
521 IMMDeviceEnumerator
*devenum
;
522 IMMDeviceCollection
*coll
;
523 IMMDevice
*defdev
= NULL
;
528 static const WCHAR primary_desc
[] = {'P','r','i','m','a','r','y',' ',
529 'S','o','u','n','d',' ','D','r','i','v','e','r',0};
530 static const WCHAR empty_drv
[] = {0};
532 devenum
= get_mmdevenum();
536 hr
= IMMDeviceEnumerator_EnumAudioEndpoints(g_devenum
, flow
,
537 DEVICE_STATE_ACTIVE
, &coll
);
539 WARN("EnumAudioEndpoints failed: %08x\n", hr
);
543 hr
= IMMDeviceCollection_GetCount(coll
, &count
);
545 IMMDeviceCollection_Release(coll
);
546 WARN("GetCount failed: %08x\n", hr
);
553 TRACE("Calling back with NULL (%s)\n", wine_dbgstr_w(primary_desc
));
554 keep_going
= cb(NULL
, primary_desc
, empty_drv
, user
);
556 /* always send the default device first */
558 hr
= IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum
, flow
,
559 eMultimedia
, &defdev
);
564 keep_going
= send_device(defdev
, &guids
[0], cb
, user
);
569 for(i
= 0; keep_going
&& i
< count
; ++i
){
572 hr
= IMMDeviceCollection_Item(coll
, i
, &device
);
574 WARN("Item failed: %08x\n", hr
);
578 if(device
!= defdev
){
579 send_device(device
, &guids
[n
], cb
, user
);
583 IMMDevice_Release(device
);
587 IMMDevice_Release(defdev
);
588 IMMDeviceCollection_Release(coll
);
590 return (keep_going
== TRUE
) ? S_OK
: S_FALSE
;
593 /***************************************************************************
594 * DirectSoundEnumerateW [DSOUND.3]
596 * Enumerate all DirectSound drivers installed in the system
599 * lpDSEnumCallback [I] Address of callback function.
600 * lpContext [I] Address of user defined context passed to callback function.
604 * Failure: DSERR_INVALIDPARAM
606 HRESULT WINAPI
DirectSoundEnumerateW(
607 LPDSENUMCALLBACKW lpDSEnumCallback
,
612 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
614 if (lpDSEnumCallback
== NULL
) {
615 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
616 return DSERR_INVALIDPARAM
;
619 setup_dsound_options();
621 hr
= enumerate_mmdevices(eRender
, DSOUND_renderer_guids
,
622 lpDSEnumCallback
, lpContext
);
623 return SUCCEEDED(hr
) ? DS_OK
: hr
;
626 /***************************************************************************
627 * DirectSoundCaptureEnumerateA [DSOUND.7]
629 * Enumerate all DirectSound drivers installed in the system.
632 * lpDSEnumCallback [I] Address of callback function.
633 * lpContext [I] Address of user defined context passed to callback function.
637 * Failure: DSERR_INVALIDPARAM
639 HRESULT WINAPI
DirectSoundCaptureEnumerateA(
640 LPDSENUMCALLBACKA lpDSEnumCallback
,
643 struct morecontext context
;
645 if (lpDSEnumCallback
== NULL
) {
646 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
647 return DSERR_INVALIDPARAM
;
650 context
.callA
= lpDSEnumCallback
;
651 context
.data
= lpContext
;
653 return DirectSoundCaptureEnumerateW(a_to_w_callback
, &context
);
656 /***************************************************************************
657 * DirectSoundCaptureEnumerateW [DSOUND.8]
659 * Enumerate all DirectSound drivers installed in the system.
662 * lpDSEnumCallback [I] Address of callback function.
663 * lpContext [I] Address of user defined context passed to callback function.
667 * Failure: DSERR_INVALIDPARAM
670 DirectSoundCaptureEnumerateW(
671 LPDSENUMCALLBACKW lpDSEnumCallback
,
676 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
678 if (lpDSEnumCallback
== NULL
) {
679 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
680 return DSERR_INVALIDPARAM
;
683 setup_dsound_options();
685 hr
= enumerate_mmdevices(eCapture
, DSOUND_capture_guids
,
686 lpDSEnumCallback
, lpContext
);
687 return SUCCEEDED(hr
) ? DS_OK
: hr
;
690 /*******************************************************************************
691 * DirectSound ClassFactory
694 typedef HRESULT (*FnCreateInstance
)(REFIID riid
, LPVOID
*ppobj
);
697 IClassFactory IClassFactory_iface
;
699 FnCreateInstance pfnCreateInstance
;
702 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
704 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
707 static HRESULT WINAPI
708 DSCF_QueryInterface(LPCLASSFACTORY iface
, REFIID riid
, LPVOID
*ppobj
)
710 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
711 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppobj
);
714 if (IsEqualIID(riid
, &IID_IUnknown
) ||
715 IsEqualIID(riid
, &IID_IClassFactory
))
718 IUnknown_AddRef(iface
);
722 return E_NOINTERFACE
;
725 static ULONG WINAPI
DSCF_AddRef(LPCLASSFACTORY iface
)
730 static ULONG WINAPI
DSCF_Release(LPCLASSFACTORY iface
)
732 /* static class, won't be freed */
736 static HRESULT WINAPI
DSCF_CreateInstance(
737 LPCLASSFACTORY iface
,
742 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
743 TRACE("(%p, %p, %s, %p)\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
746 return CLASS_E_NOAGGREGATION
;
749 WARN("invalid parameter\n");
750 return DSERR_INVALIDPARAM
;
753 return This
->pfnCreateInstance(riid
, ppobj
);
756 static HRESULT WINAPI
DSCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
758 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
759 FIXME("(%p, %d) stub!\n", This
, dolock
);
763 static const IClassFactoryVtbl DSCF_Vtbl
= {
771 static IClassFactoryImpl DSOUND_CF
[] = {
772 { { &DSCF_Vtbl
}, &CLSID_DirectSound
, (FnCreateInstance
)DSOUND_Create
},
773 { { &DSCF_Vtbl
}, &CLSID_DirectSound8
, (FnCreateInstance
)DSOUND_Create8
},
774 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture
, (FnCreateInstance
)DSOUND_CaptureCreate
},
775 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture8
, (FnCreateInstance
)DSOUND_CaptureCreate8
},
776 { { &DSCF_Vtbl
}, &CLSID_DirectSoundFullDuplex
, (FnCreateInstance
)DSOUND_FullDuplexCreate
},
777 { { &DSCF_Vtbl
}, &CLSID_DirectSoundPrivate
, (FnCreateInstance
)IKsPrivatePropertySetImpl_Create
},
778 { { NULL
}, NULL
, NULL
}
781 /*******************************************************************************
782 * DllGetClassObject [DSOUND.@]
783 * Retrieves class object from a DLL object
786 * Docs say returns STDAPI
789 * rclsid [I] CLSID for the class object
790 * riid [I] Reference to identifier of interface for class object
791 * ppv [O] Address of variable to receive interface pointer for riid
795 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
798 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
801 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
804 WARN("invalid parameter\n");
810 if (!IsEqualIID(riid
, &IID_IClassFactory
) &&
811 !IsEqualIID(riid
, &IID_IUnknown
)) {
812 WARN("no interface for %s\n", debugstr_guid(riid
));
813 return E_NOINTERFACE
;
816 while (NULL
!= DSOUND_CF
[i
].rclsid
) {
817 if (IsEqualGUID(rclsid
, DSOUND_CF
[i
].rclsid
)) {
818 DSCF_AddRef(&DSOUND_CF
[i
].IClassFactory_iface
);
819 *ppv
= &DSOUND_CF
[i
];
825 WARN("(%s, %s, %p): no class found.\n", debugstr_guid(rclsid
),
826 debugstr_guid(riid
), ppv
);
827 return CLASS_E_CLASSNOTAVAILABLE
;
831 /*******************************************************************************
832 * DllCanUnloadNow [DSOUND.4]
833 * Determines whether the DLL is in use.
836 * Can unload now: S_OK
837 * Cannot unload now (the DLL is still active): S_FALSE
839 HRESULT WINAPI
DllCanUnloadNow(void)
844 #define INIT_GUID(guid, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
845 guid.Data1 = l; guid.Data2 = w1; guid.Data3 = w2; \
846 guid.Data4[0] = b1; guid.Data4[1] = b2; guid.Data4[2] = b3; \
847 guid.Data4[3] = b4; guid.Data4[4] = b5; guid.Data4[5] = b6; \
848 guid.Data4[6] = b7; guid.Data4[7] = b8;
850 /***********************************************************************
851 * DllMain (DSOUND.init)
853 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
855 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpvReserved
);
858 case DLL_PROCESS_ATTACH
:
859 TRACE("DLL_PROCESS_ATTACH\n");
861 DisableThreadLibraryCalls(hInstDLL
);
862 /* Increase refcount on dsound by 1 */
863 GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
, (LPCWSTR
)hInstDLL
, &hInstDLL
);
865 case DLL_PROCESS_DETACH
:
866 TRACE("DLL_PROCESS_DETACH\n");
867 DeleteCriticalSection(&DSOUND_renderers_lock
);
868 DeleteCriticalSection(&DSOUND_capturers_lock
);
869 DeleteCriticalSection(&g_devenum_lock
);
872 TRACE("UNKNOWN REASON\n");
878 /***********************************************************************
879 * DllRegisterServer (DSOUND.@)
881 HRESULT WINAPI
DllRegisterServer(void)
883 return __wine_register_resources( instance
);
886 /***********************************************************************
887 * DllUnregisterServer (DSOUND.@)
889 HRESULT WINAPI
DllUnregisterServer(void)
891 return __wine_unregister_resources( instance
);