Commit 5a3655fe authored by David Reid's avatar David Reid

DirectSound: Add support for specifying an explicit HWND.

Public issue https://github.com/mackron/miniaudio/issues/779
parent 4a5b74be
v0.11.22 - TBD
=====================
* DirectSound: Add support for specifying an explicit window handle for SetCooperativeLevel().
v0.11.21 - 2023-11-15 v0.11.21 - 2023-11-15
===================== =====================
* Add new ma_device_notification_type_unlocked notification. This is used on Web and will be fired after the user has performed a gesture and thus unlocked the ability to play audio. * Add new ma_device_notification_type_unlocked notification. This is used on Web and will be fired after the user has performed a gesture and thus unlocked the ability to play audio.
......
/* /*
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file. Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
miniaudio - v0.11.21 - 2023-11-15 miniaudio - v0.11.22 - TBD
David Reid - mackron@gmail.com David Reid - mackron@gmail.com
...@@ -7248,6 +7248,10 @@ struct ma_context_config ...@@ -7248,6 +7248,10 @@ struct ma_context_config
void* pUserData; void* pUserData;
ma_allocation_callbacks allocationCallbacks; ma_allocation_callbacks allocationCallbacks;
struct struct
{
ma_handle hWnd; /* HWND. Optional window handle to pass into SetCooperativeLevel(). Will default to the foreground window, and if that fails, the desktop window. */
} dsound;
struct
{ {
ma_bool32 useVerboseDeviceEnumeration; ma_bool32 useVerboseDeviceEnumeration;
} alsa; } alsa;
...@@ -7336,6 +7340,7 @@ struct ma_context ...@@ -7336,6 +7340,7 @@ struct ma_context
#ifdef MA_SUPPORT_DSOUND #ifdef MA_SUPPORT_DSOUND
struct struct
{ {
ma_handle hWnd; /* Can be null. */
ma_handle hDSoundDLL; ma_handle hDSoundDLL;
ma_proc DirectSoundCreate; ma_proc DirectSoundCreate;
ma_proc DirectSoundEnumerateA; ma_proc DirectSoundEnumerateA;
...@@ -24024,9 +24029,12 @@ static ma_result ma_context_create_IDirectSound__dsound(ma_context* pContext, ma ...@@ -24024,9 +24029,12 @@ static ma_result ma_context_create_IDirectSound__dsound(ma_context* pContext, ma
} }
/* The cooperative level must be set before doing anything else. */ /* The cooperative level must be set before doing anything else. */
hWnd = ((MA_PFN_GetForegroundWindow)pContext->win32.GetForegroundWindow)(); hWnd = (HWND)pContext->dsound.hWnd;
if (hWnd == 0) { if (hWnd == 0) {
hWnd = ((MA_PFN_GetDesktopWindow)pContext->win32.GetDesktopWindow)(); hWnd = ((MA_PFN_GetForegroundWindow)pContext->win32.GetForegroundWindow)();
if (hWnd == 0) {
hWnd = ((MA_PFN_GetDesktopWindow)pContext->win32.GetDesktopWindow)();
}
} }
hr = ma_IDirectSound_SetCooperativeLevel(pDirectSound, hWnd, (shareMode == ma_share_mode_exclusive) ? MA_DSSCL_EXCLUSIVE : MA_DSSCL_PRIORITY); hr = ma_IDirectSound_SetCooperativeLevel(pDirectSound, hWnd, (shareMode == ma_share_mode_exclusive) ? MA_DSSCL_EXCLUSIVE : MA_DSSCL_PRIORITY);
...@@ -25343,6 +25351,8 @@ static ma_result ma_context_init__dsound(ma_context* pContext, const ma_context_ ...@@ -25343,6 +25351,8 @@ static ma_result ma_context_init__dsound(ma_context* pContext, const ma_context_
return MA_API_NOT_FOUND; return MA_API_NOT_FOUND;
} }
pContext->dsound.hWnd = pConfig->dsound.hWnd;
pCallbacks->onContextInit = ma_context_init__dsound; pCallbacks->onContextInit = ma_context_init__dsound;
pCallbacks->onContextUninit = ma_context_uninit__dsound; pCallbacks->onContextUninit = ma_context_uninit__dsound;
pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__dsound; pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__dsound;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment