mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 16:54:03 +02:00
Fix link errors with GCC/Clang on Windows.
This commit is contained in:
@@ -1289,6 +1289,11 @@ struct mal_context
|
|||||||
/*HMODULE*/ mal_handle hUser32DLL;
|
/*HMODULE*/ mal_handle hUser32DLL;
|
||||||
mal_proc GetForegroundWindow;
|
mal_proc GetForegroundWindow;
|
||||||
mal_proc GetDesktopWindow;
|
mal_proc GetDesktopWindow;
|
||||||
|
|
||||||
|
/*HMODULE*/ mal_handle hAdvapi32DLL;
|
||||||
|
mal_proc RegOpenKeyExA;
|
||||||
|
mal_proc RegCloseKey;
|
||||||
|
mal_proc RegQueryValueExA;
|
||||||
} win32;
|
} win32;
|
||||||
#endif
|
#endif
|
||||||
#ifdef MAL_POSIX
|
#ifdef MAL_POSIX
|
||||||
@@ -2681,6 +2686,10 @@ typedef int (WINAPI * MAL_PFN_StringFromGUID2)(const GUID* const rguid, LPOL
|
|||||||
|
|
||||||
typedef HWND (WINAPI * MAL_PFN_GetForegroundWindow)();
|
typedef HWND (WINAPI * MAL_PFN_GetForegroundWindow)();
|
||||||
typedef HWND (WINAPI * MAL_PFN_GetDesktopWindow)();
|
typedef HWND (WINAPI * MAL_PFN_GetDesktopWindow)();
|
||||||
|
|
||||||
|
typedef LSTATUS (WINAPI * MAL_PFN_RegOpenKeyExA)(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
|
||||||
|
typedef LSTATUS (WINAPI * MAL_PFN_RegCloseKey)(HKEY hKey);
|
||||||
|
typedef LSTATUS (WINAPI * MAL_PFN_RegQueryValueExA)(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -7029,12 +7038,12 @@ mal_result mal_context_get_device_info_from_WAVECAPS(mal_context* pContext, MAL_
|
|||||||
mal_strcat_s(keyStr, sizeof(keyStr), guidStr);
|
mal_strcat_s(keyStr, sizeof(keyStr), guidStr);
|
||||||
|
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
LONG result = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keyStr, 0, KEY_READ, &hKey);
|
LONG result = ((MAL_PFN_RegOpenKeyExA)pContext->win32.RegOpenKeyExA)(HKEY_LOCAL_MACHINE, keyStr, 0, KEY_READ, &hKey);
|
||||||
if (result == ERROR_SUCCESS) {
|
if (result == ERROR_SUCCESS) {
|
||||||
BYTE nameFromReg[512];
|
BYTE nameFromReg[512];
|
||||||
DWORD nameFromRegSize = sizeof(nameFromReg);
|
DWORD nameFromRegSize = sizeof(nameFromReg);
|
||||||
result = RegQueryValueExA(hKey, "Name", 0, NULL, (LPBYTE)nameFromReg, (LPDWORD)&nameFromRegSize);
|
result = ((MAL_PFN_RegQueryValueExA)pContext->win32.RegQueryValueExA)(hKey, "Name", 0, NULL, (LPBYTE)nameFromReg, (LPDWORD)&nameFromRegSize);
|
||||||
RegCloseKey(hKey);
|
((MAL_PFN_RegCloseKey)pContext->win32.RegCloseKey)(hKey);
|
||||||
|
|
||||||
if (result == ERROR_SUCCESS) {
|
if (result == ERROR_SUCCESS) {
|
||||||
// We have the value from the registry, so now we need to construct the name string.
|
// We have the value from the registry, so now we need to construct the name string.
|
||||||
@@ -14444,6 +14453,7 @@ mal_result mal_context_uninit_backend_apis__win32(mal_context* pContext)
|
|||||||
mal_CoUninitialize(pContext);
|
mal_CoUninitialize(pContext);
|
||||||
mal_dlclose(pContext->win32.hUser32DLL);
|
mal_dlclose(pContext->win32.hUser32DLL);
|
||||||
mal_dlclose(pContext->win32.hOle32DLL);
|
mal_dlclose(pContext->win32.hOle32DLL);
|
||||||
|
mal_dlclose(pContext->win32.hAdvapi32DLL);
|
||||||
|
|
||||||
return MAL_SUCCESS;
|
return MAL_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -14473,6 +14483,17 @@ mal_result mal_context_init_backend_apis__win32(mal_context* pContext)
|
|||||||
|
|
||||||
pContext->win32.GetForegroundWindow = (mal_proc)mal_dlsym(pContext->win32.hUser32DLL, "GetForegroundWindow");
|
pContext->win32.GetForegroundWindow = (mal_proc)mal_dlsym(pContext->win32.hUser32DLL, "GetForegroundWindow");
|
||||||
pContext->win32.GetDesktopWindow = (mal_proc)mal_dlsym(pContext->win32.hUser32DLL, "GetDesktopWindow");
|
pContext->win32.GetDesktopWindow = (mal_proc)mal_dlsym(pContext->win32.hUser32DLL, "GetDesktopWindow");
|
||||||
|
|
||||||
|
|
||||||
|
// Advapi32.dll
|
||||||
|
pContext->win32.hAdvapi32DLL = mal_dlopen("advapi32.dll");
|
||||||
|
if (pContext->win32.hAdvapi32DLL == NULL) {
|
||||||
|
return MAL_FAILED_TO_INIT_BACKEND;
|
||||||
|
}
|
||||||
|
|
||||||
|
pContext->win32.RegOpenKeyExA = (mal_proc)mal_dlsym(pContext->win32.hAdvapi32DLL, "RegOpenKeyExA");
|
||||||
|
pContext->win32.RegCloseKey = (mal_proc)mal_dlsym(pContext->win32.hAdvapi32DLL, "RegCloseKey");
|
||||||
|
pContext->win32.RegQueryValueExA = (mal_proc)mal_dlsym(pContext->win32.hAdvapi32DLL, "RegQueryValueExA");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mal_CoInitializeEx(pContext, NULL, 0); // 0 = COINIT_MULTITHREADED
|
mal_CoInitializeEx(pContext, NULL, 0); // 0 = COINIT_MULTITHREADED
|
||||||
|
|||||||
Reference in New Issue
Block a user