mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-21 15:56:58 +02:00
DirectSound: Add support for specifying an explicit HWND.
Public issue https://github.com/mackron/miniaudio/issues/779
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
v0.11.22 - TBD
|
||||
=====================
|
||||
* DirectSound: Add support for specifying an explicit window handle for SetCooperativeLevel().
|
||||
|
||||
|
||||
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.
|
||||
|
||||
+13
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
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
|
||||
|
||||
@@ -7248,6 +7248,10 @@ struct ma_context_config
|
||||
void* pUserData;
|
||||
ma_allocation_callbacks allocationCallbacks;
|
||||
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;
|
||||
} alsa;
|
||||
@@ -7336,6 +7340,7 @@ struct ma_context
|
||||
#ifdef MA_SUPPORT_DSOUND
|
||||
struct
|
||||
{
|
||||
ma_handle hWnd; /* Can be null. */
|
||||
ma_handle hDSoundDLL;
|
||||
ma_proc DirectSoundCreate;
|
||||
ma_proc DirectSoundEnumerateA;
|
||||
@@ -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. */
|
||||
hWnd = ((MA_PFN_GetForegroundWindow)pContext->win32.GetForegroundWindow)();
|
||||
hWnd = (HWND)pContext->dsound.hWnd;
|
||||
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);
|
||||
@@ -25343,6 +25351,8 @@ static ma_result ma_context_init__dsound(ma_context* pContext, const ma_context_
|
||||
return MA_API_NOT_FOUND;
|
||||
}
|
||||
|
||||
pContext->dsound.hWnd = pConfig->dsound.hWnd;
|
||||
|
||||
pCallbacks->onContextInit = ma_context_init__dsound;
|
||||
pCallbacks->onContextUninit = ma_context_uninit__dsound;
|
||||
pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__dsound;
|
||||
|
||||
Reference in New Issue
Block a user