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"
57 #include "dsound_private.h"
59 WINE_DEFAULT_DEBUG_CHANNEL(dsound
);
61 DirectSoundDevice
* DSOUND_renderer
[MAXWAVEDRIVERS
];
62 GUID DSOUND_renderer_guids
[MAXWAVEDRIVERS
];
63 GUID DSOUND_capture_guids
[MAXWAVEDRIVERS
];
65 HRESULT
mmErr(UINT err
)
68 case MMSYSERR_NOERROR
:
70 case MMSYSERR_ALLOCATED
:
71 return DSERR_ALLOCATED
;
73 case MMSYSERR_INVALHANDLE
:
74 case WAVERR_STILLPLAYING
:
75 return DSERR_GENERIC
; /* FIXME */
76 case MMSYSERR_NODRIVER
:
77 return DSERR_NODRIVER
;
79 return DSERR_OUTOFMEMORY
;
80 case MMSYSERR_INVALPARAM
:
81 case WAVERR_BADFORMAT
:
82 case WAVERR_UNPREPARED
:
83 return DSERR_INVALIDPARAM
;
84 case MMSYSERR_NOTSUPPORTED
:
85 return DSERR_UNSUPPORTED
;
87 FIXME("Unknown MMSYS error %d\n",err
);
92 /* All default settings, you most likely don't want to touch these, see wiki on UsefulRegistryKeys */
93 int ds_emuldriver
= 0;
94 int ds_hel_buflen
= 32768 * 2;
95 int ds_snd_queue_max
= 10;
96 int ds_snd_queue_min
= 6;
97 int ds_snd_shadow_maxsize
= 2;
98 int ds_hw_accel
= DS_HW_ACCEL_FULL
;
99 int ds_default_sample_rate
= 44100;
100 int ds_default_bits_per_sample
= 16;
101 static int ds_default_playback
;
102 static int ds_default_capture
;
103 static HINSTANCE instance
;
106 * Get a config key from either the app-specific or the default config
109 static inline DWORD
get_config_key( HKEY defkey
, HKEY appkey
, const char *name
,
110 char *buffer
, DWORD size
)
112 if (appkey
&& !RegQueryValueExA( appkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
113 if (defkey
&& !RegQueryValueExA( defkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
)) return 0;
114 return ERROR_FILE_NOT_FOUND
;
119 * Setup the dsound options.
122 void setup_dsound_options(void)
124 char buffer
[MAX_PATH
+16];
125 HKEY hkey
, appkey
= 0;
128 buffer
[MAX_PATH
]='\0';
130 /* @@ Wine registry key: HKCU\Software\Wine\DirectSound */
131 if (RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\DirectSound", &hkey
)) hkey
= 0;
133 len
= GetModuleFileNameA( 0, buffer
, MAX_PATH
);
134 if (len
&& len
< MAX_PATH
)
137 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectSound */
138 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\AppDefaults", &tmpkey
))
140 char *p
, *appname
= buffer
;
141 if ((p
= strrchr( appname
, '/' ))) appname
= p
+ 1;
142 if ((p
= strrchr( appname
, '\\' ))) appname
= p
+ 1;
143 strcat( appname
, "\\DirectSound" );
144 TRACE("appname = [%s]\n", appname
);
145 if (RegOpenKeyA( tmpkey
, appname
, &appkey
)) appkey
= 0;
146 RegCloseKey( tmpkey
);
152 if (!get_config_key( hkey
, appkey
, "EmulDriver", buffer
, MAX_PATH
))
153 ds_emuldriver
= strcmp(buffer
, "N");
155 if (!get_config_key( hkey
, appkey
, "HelBuflen", buffer
, MAX_PATH
))
156 ds_hel_buflen
= atoi(buffer
);
158 if (!get_config_key( hkey
, appkey
, "SndQueueMax", buffer
, MAX_PATH
))
159 ds_snd_queue_max
= atoi(buffer
);
161 if (!get_config_key( hkey
, appkey
, "SndQueueMin", buffer
, MAX_PATH
))
162 ds_snd_queue_min
= atoi(buffer
);
164 if (!get_config_key( hkey
, appkey
, "HardwareAcceleration", buffer
, MAX_PATH
)) {
165 if (strcmp(buffer
, "Full") == 0)
166 ds_hw_accel
= DS_HW_ACCEL_FULL
;
167 else if (strcmp(buffer
, "Standard") == 0)
168 ds_hw_accel
= DS_HW_ACCEL_STANDARD
;
169 else if (strcmp(buffer
, "Basic") == 0)
170 ds_hw_accel
= DS_HW_ACCEL_BASIC
;
171 else if (strcmp(buffer
, "Emulation") == 0)
172 ds_hw_accel
= DS_HW_ACCEL_EMULATION
;
175 if (!get_config_key( hkey
, appkey
, "DefaultPlayback", buffer
, MAX_PATH
))
176 ds_default_playback
= atoi(buffer
);
178 if (!get_config_key( hkey
, appkey
, "MaxShadowSize", buffer
, MAX_PATH
))
179 ds_snd_shadow_maxsize
= atoi(buffer
);
181 if (!get_config_key( hkey
, appkey
, "DefaultCapture", buffer
, MAX_PATH
))
182 ds_default_capture
= atoi(buffer
);
184 if (!get_config_key( hkey
, appkey
, "DefaultSampleRate", buffer
, MAX_PATH
))
185 ds_default_sample_rate
= atoi(buffer
);
187 if (!get_config_key( hkey
, appkey
, "DefaultBitsPerSample", buffer
, MAX_PATH
))
188 ds_default_bits_per_sample
= atoi(buffer
);
190 if (appkey
) RegCloseKey( appkey
);
191 if (hkey
) RegCloseKey( hkey
);
193 TRACE("ds_emuldriver = %d\n", ds_emuldriver
);
194 TRACE("ds_hel_buflen = %d\n", ds_hel_buflen
);
195 TRACE("ds_snd_queue_max = %d\n", ds_snd_queue_max
);
196 TRACE("ds_snd_queue_min = %d\n", ds_snd_queue_min
);
197 TRACE("ds_hw_accel = %s\n",
198 ds_hw_accel
==DS_HW_ACCEL_FULL
? "Full" :
199 ds_hw_accel
==DS_HW_ACCEL_STANDARD
? "Standard" :
200 ds_hw_accel
==DS_HW_ACCEL_BASIC
? "Basic" :
201 ds_hw_accel
==DS_HW_ACCEL_EMULATION
? "Emulation" :
203 TRACE("ds_default_playback = %d\n", ds_default_playback
);
204 TRACE("ds_default_capture = %d\n", ds_default_playback
);
205 TRACE("ds_default_sample_rate = %d\n", ds_default_sample_rate
);
206 TRACE("ds_default_bits_per_sample = %d\n", ds_default_bits_per_sample
);
207 TRACE("ds_snd_shadow_maxsize = %d\n", ds_snd_shadow_maxsize
);
210 static const char * get_device_id(LPCGUID pGuid
)
212 if (IsEqualGUID(&DSDEVID_DefaultPlayback
, pGuid
))
213 return "DSDEVID_DefaultPlayback";
214 else if (IsEqualGUID(&DSDEVID_DefaultVoicePlayback
, pGuid
))
215 return "DSDEVID_DefaultVoicePlayback";
216 else if (IsEqualGUID(&DSDEVID_DefaultCapture
, pGuid
))
217 return "DSDEVID_DefaultCapture";
218 else if (IsEqualGUID(&DSDEVID_DefaultVoiceCapture
, pGuid
))
219 return "DSDEVID_DefaultVoiceCapture";
220 return debugstr_guid(pGuid
);
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 TRACE("(%s,%p)\n", get_device_id(pGuidSrc
),pGuidDest
);
247 if ( pGuidSrc
== NULL
) {
248 WARN("invalid parameter: pGuidSrc == NULL\n");
249 return DSERR_INVALIDPARAM
;
252 if ( pGuidDest
== NULL
) {
253 WARN("invalid parameter: pGuidDest == NULL\n");
254 return DSERR_INVALIDPARAM
;
257 if ( IsEqualGUID( &DSDEVID_DefaultPlayback
, pGuidSrc
) ||
258 IsEqualGUID( &DSDEVID_DefaultVoicePlayback
, pGuidSrc
) ) {
259 *pGuidDest
= DSOUND_renderer_guids
[ds_default_playback
];
260 TRACE("returns %s\n", get_device_id(pGuidDest
));
264 if ( IsEqualGUID( &DSDEVID_DefaultCapture
, pGuidSrc
) ||
265 IsEqualGUID( &DSDEVID_DefaultVoiceCapture
, pGuidSrc
) ) {
266 *pGuidDest
= DSOUND_capture_guids
[ds_default_capture
];
267 TRACE("returns %s\n", get_device_id(pGuidDest
));
271 *pGuidDest
= *pGuidSrc
;
272 TRACE("returns %s\n", get_device_id(pGuidDest
));
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 /***************************************************************************
325 * DirectSoundEnumerateW [DSOUND.3]
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
DirectSoundEnumerateW(
338 LPDSENUMCALLBACKW lpDSEnumCallback
,
345 WCHAR wDesc
[MAXPNAMELEN
];
346 WCHAR wName
[MAXPNAMELEN
];
348 TRACE("lpDSEnumCallback = %p, lpContext = %p\n",
349 lpDSEnumCallback
, lpContext
);
351 if (lpDSEnumCallback
== NULL
) {
352 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
353 return DSERR_INVALIDPARAM
;
356 devs
= waveOutGetNumDevs();
358 if (GetDeviceID(&DSDEVID_DefaultPlayback
, &guid
) == DS_OK
) {
359 static const WCHAR empty
[] = { 0 };
360 for (wod
= 0; wod
< devs
; ++wod
) {
361 if (IsEqualGUID( &guid
, &DSOUND_renderer_guids
[wod
] ) ) {
362 err
= mmErr(waveOutMessage(UlongToHandle(wod
),DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
364 TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
365 "Primary Sound Driver",desc
.szDrvname
,lpContext
);
366 MultiByteToWideChar( CP_ACP
, 0, "Primary Sound Driver", -1,
367 wDesc
, sizeof(wDesc
)/sizeof(WCHAR
) );
368 if (lpDSEnumCallback(NULL
, wDesc
, empty
, lpContext
) == FALSE
)
376 for (wod
= 0; wod
< devs
; ++wod
) {
377 err
= mmErr(waveOutMessage(UlongToHandle(wod
),DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
379 TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
380 debugstr_guid(&DSOUND_renderer_guids
[wod
]),desc
.szDesc
,desc
.szDrvname
,lpContext
);
381 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1,
382 wDesc
, sizeof(wDesc
)/sizeof(WCHAR
) );
383 wDesc
[(sizeof(wDesc
)/sizeof(WCHAR
)) - 1] = '\0';
385 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1,
386 wName
, sizeof(wName
)/sizeof(WCHAR
) );
387 wName
[(sizeof(wName
)/sizeof(WCHAR
)) - 1] = '\0';
389 if (lpDSEnumCallback(&DSOUND_renderer_guids
[wod
], wDesc
, wName
, lpContext
) == FALSE
)
396 /***************************************************************************
397 * DirectSoundCaptureEnumerateA [DSOUND.7]
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
DirectSoundCaptureEnumerateA(
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 DirectSoundCaptureEnumerateW(a_to_w_callback
, &context
);
426 /***************************************************************************
427 * DirectSoundCaptureEnumerateW [DSOUND.8]
429 * Enumerate all DirectSound drivers installed in the system.
432 * lpDSEnumCallback [I] Address of callback function.
433 * lpContext [I] Address of user defined context passed to callback function.
437 * Failure: DSERR_INVALIDPARAM
440 DirectSoundCaptureEnumerateW(
441 LPDSENUMCALLBACKW lpDSEnumCallback
,
448 WCHAR wDesc
[MAXPNAMELEN
];
449 WCHAR wName
[MAXPNAMELEN
];
451 TRACE("(%p,%p)\n", lpDSEnumCallback
, lpContext
);
453 if (lpDSEnumCallback
== NULL
) {
454 WARN("invalid parameter: lpDSEnumCallback == NULL\n");
455 return DSERR_INVALIDPARAM
;
458 devs
= waveInGetNumDevs();
460 if (GetDeviceID(&DSDEVID_DefaultCapture
, &guid
) == DS_OK
) {
461 for (wid
= 0; wid
< devs
; ++wid
) {
462 if (IsEqualGUID( &guid
, &DSOUND_capture_guids
[wid
] ) ) {
463 err
= mmErr(waveInMessage(UlongToHandle(wid
),DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
465 TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
466 "Primary Sound Capture Driver",desc
.szDrvname
,lpContext
);
467 MultiByteToWideChar( CP_ACP
, 0, "Primary Sound Capture Driver", -1,
468 wDesc
, sizeof(wDesc
)/sizeof(WCHAR
) );
469 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1,
470 wName
, sizeof(wName
)/sizeof(WCHAR
) );
471 wName
[(sizeof(wName
)/sizeof(WCHAR
)) - 1] = '\0';
473 if (lpDSEnumCallback(NULL
, wDesc
, wName
, lpContext
) == FALSE
)
481 for (wid
= 0; wid
< devs
; ++wid
) {
482 err
= mmErr(waveInMessage(UlongToHandle(wid
),DRV_QUERYDSOUNDDESC
,(DWORD_PTR
)&desc
,0));
484 TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
485 debugstr_guid(&DSOUND_capture_guids
[wid
]),desc
.szDesc
,desc
.szDrvname
,lpContext
);
486 MultiByteToWideChar( CP_ACP
, 0, desc
.szDesc
, -1,
487 wDesc
, sizeof(wDesc
)/sizeof(WCHAR
) );
488 wDesc
[(sizeof(wDesc
)/sizeof(WCHAR
)) - 1] = '\0';
490 MultiByteToWideChar( CP_ACP
, 0, desc
.szDrvname
, -1,
491 wName
, sizeof(wName
)/sizeof(WCHAR
) );
492 wName
[(sizeof(wName
)/sizeof(WCHAR
)) - 1] = '\0';
494 if (lpDSEnumCallback(&DSOUND_capture_guids
[wid
], wDesc
, wName
, lpContext
) == FALSE
)
502 /*******************************************************************************
503 * DirectSound ClassFactory
506 typedef HRESULT (*FnCreateInstance
)(REFIID riid
, LPVOID
*ppobj
);
509 IClassFactory IClassFactory_iface
;
511 FnCreateInstance pfnCreateInstance
;
514 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
516 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
519 static HRESULT WINAPI
520 DSCF_QueryInterface(LPCLASSFACTORY iface
, REFIID riid
, LPVOID
*ppobj
)
522 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
523 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppobj
);
526 if (IsEqualIID(riid
, &IID_IUnknown
) ||
527 IsEqualIID(riid
, &IID_IClassFactory
))
530 IUnknown_AddRef(iface
);
534 return E_NOINTERFACE
;
537 static ULONG WINAPI
DSCF_AddRef(LPCLASSFACTORY iface
)
542 static ULONG WINAPI
DSCF_Release(LPCLASSFACTORY iface
)
544 /* static class, won't be freed */
548 static HRESULT WINAPI
DSCF_CreateInstance(
549 LPCLASSFACTORY iface
,
554 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
555 TRACE("(%p, %p, %s, %p)\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
558 return CLASS_E_NOAGGREGATION
;
561 WARN("invalid parameter\n");
562 return DSERR_INVALIDPARAM
;
565 return This
->pfnCreateInstance(riid
, ppobj
);
568 static HRESULT WINAPI
DSCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
570 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
571 FIXME("(%p, %d) stub!\n", This
, dolock
);
575 static const IClassFactoryVtbl DSCF_Vtbl
= {
583 static IClassFactoryImpl DSOUND_CF
[] = {
584 { { &DSCF_Vtbl
}, &CLSID_DirectSound
, (FnCreateInstance
)DSOUND_Create
},
585 { { &DSCF_Vtbl
}, &CLSID_DirectSound8
, (FnCreateInstance
)DSOUND_Create8
},
586 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture
, (FnCreateInstance
)DSOUND_CaptureCreate
},
587 { { &DSCF_Vtbl
}, &CLSID_DirectSoundCapture8
, (FnCreateInstance
)DSOUND_CaptureCreate8
},
588 { { &DSCF_Vtbl
}, &CLSID_DirectSoundFullDuplex
, (FnCreateInstance
)DSOUND_FullDuplexCreate
},
589 { { &DSCF_Vtbl
}, &CLSID_DirectSoundPrivate
, (FnCreateInstance
)IKsPrivatePropertySetImpl_Create
},
590 { { NULL
}, NULL
, NULL
}
593 /*******************************************************************************
594 * DllGetClassObject [DSOUND.@]
595 * Retrieves class object from a DLL object
598 * Docs say returns STDAPI
601 * rclsid [I] CLSID for the class object
602 * riid [I] Reference to identifier of interface for class object
603 * ppv [O] Address of variable to receive interface pointer for riid
607 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
610 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
613 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
616 WARN("invalid parameter\n");
622 if (!IsEqualIID(riid
, &IID_IClassFactory
) &&
623 !IsEqualIID(riid
, &IID_IUnknown
)) {
624 WARN("no interface for %s\n", debugstr_guid(riid
));
625 return E_NOINTERFACE
;
628 while (NULL
!= DSOUND_CF
[i
].rclsid
) {
629 if (IsEqualGUID(rclsid
, DSOUND_CF
[i
].rclsid
)) {
630 DSCF_AddRef(&DSOUND_CF
[i
].IClassFactory_iface
);
631 *ppv
= &DSOUND_CF
[i
];
637 WARN("(%s, %s, %p): no class found.\n", debugstr_guid(rclsid
),
638 debugstr_guid(riid
), ppv
);
639 return CLASS_E_CLASSNOTAVAILABLE
;
643 /*******************************************************************************
644 * DllCanUnloadNow [DSOUND.4]
645 * Determines whether the DLL is in use.
648 * Can unload now: S_OK
649 * Cannot unload now (the DLL is still active): S_FALSE
651 HRESULT WINAPI
DllCanUnloadNow(void)
656 #define INIT_GUID(guid, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
657 guid.Data1 = l; guid.Data2 = w1; guid.Data3 = w2; \
658 guid.Data4[0] = b1; guid.Data4[1] = b2; guid.Data4[2] = b3; \
659 guid.Data4[3] = b4; guid.Data4[4] = b5; guid.Data4[5] = b6; \
660 guid.Data4[6] = b7; guid.Data4[7] = b8;
662 /***********************************************************************
663 * DllMain (DSOUND.init)
665 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
668 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpvReserved
);
671 case DLL_PROCESS_ATTACH
:
672 TRACE("DLL_PROCESS_ATTACH\n");
673 for (i
= 0; i
< MAXWAVEDRIVERS
; i
++) {
674 DSOUND_renderer
[i
] = NULL
;
675 DSOUND_capture
[i
] = NULL
;
676 INIT_GUID(DSOUND_renderer_guids
[i
], 0xbd6dd71a, 0x3deb, 0x11d1, 0xb1, 0x71, 0x00, 0xc0, 0x4f, 0xc2, 0x00, 0x00 + i
);
677 INIT_GUID(DSOUND_capture_guids
[i
], 0xbd6dd71b, 0x3deb, 0x11d1, 0xb1, 0x71, 0x00, 0xc0, 0x4f, 0xc2, 0x00, 0x00 + i
);
680 DisableThreadLibraryCalls(hInstDLL
);
681 /* Increase refcount on dsound by 1 */
682 GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
, (LPCWSTR
)hInstDLL
, &hInstDLL
);
684 case DLL_PROCESS_DETACH
:
685 TRACE("DLL_PROCESS_DETACH\n");
688 TRACE("UNKNOWN REASON\n");
694 /***********************************************************************
695 * DllRegisterServer (DSOUND.@)
697 HRESULT WINAPI
DllRegisterServer(void)
699 return __wine_register_resources( instance
, NULL
);
702 /***********************************************************************
703 * DllUnregisterServer (DSOUND.@)
705 HRESULT WINAPI
DllUnregisterServer(void)
707 return __wine_unregister_resources( instance
, NULL
);