mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Fix an error when dynamically linking when forcing the UWP build.
This also fixes a possible crash during initialization due to leaving a thread running after early termination of the initialization routine.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
v0.11.20 - TBD
|
||||||
|
=====================
|
||||||
|
* Fix an error when dynamically linking libraries when forcing the UWP build on desktop.
|
||||||
|
|
||||||
|
|
||||||
v0.11.19 - 2023-11-04
|
v0.11.19 - 2023-11-04
|
||||||
=====================
|
=====================
|
||||||
* Fix a bug where `ma_decoder_init_file()` can incorrectly return successfully.
|
* Fix a bug where `ma_decoder_init_file()` can incorrectly return successfully.
|
||||||
|
|||||||
+36
-38
@@ -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.
|
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
|
||||||
miniaudio - v0.11.19 - 2023-11-04
|
miniaudio - v0.11.20 - TBD
|
||||||
|
|
||||||
David Reid - mackron@gmail.com
|
David Reid - mackron@gmail.com
|
||||||
|
|
||||||
@@ -3723,7 +3723,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define MA_VERSION_MAJOR 0
|
#define MA_VERSION_MAJOR 0
|
||||||
#define MA_VERSION_MINOR 11
|
#define MA_VERSION_MINOR 11
|
||||||
#define MA_VERSION_REVISION 19
|
#define MA_VERSION_REVISION 20
|
||||||
#define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION)
|
#define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION)
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(__clang__)
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
@@ -17820,7 +17820,7 @@ MA_API ma_handle ma_dlopen(ma_log* pLog, const char* filename)
|
|||||||
|
|
||||||
#ifdef MA_WIN32
|
#ifdef MA_WIN32
|
||||||
/* From MSDN: Desktop applications cannot use LoadPackagedLibrary; if a desktop application calls this function it fails with APPMODEL_ERROR_NO_PACKAGE.*/
|
/* From MSDN: Desktop applications cannot use LoadPackagedLibrary; if a desktop application calls this function it fails with APPMODEL_ERROR_NO_PACKAGE.*/
|
||||||
#if !defined(MA_WIN32_UWP)
|
#if !defined(MA_WIN32_UWP) || !(defined(WINAPI_FAMILY) && ((defined(WINAPI_FAMILY_PHONE_APP) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)))
|
||||||
handle = (ma_handle)LoadLibraryA(filename);
|
handle = (ma_handle)LoadLibraryA(filename);
|
||||||
#else
|
#else
|
||||||
/* *sigh* It appears there is no ANSI version of LoadPackagedLibrary()... */
|
/* *sigh* It appears there is no ANSI version of LoadPackagedLibrary()... */
|
||||||
@@ -23511,6 +23511,39 @@ static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_
|
|||||||
|
|
||||||
MA_ZERO_OBJECT(&pContext->wasapi);
|
MA_ZERO_OBJECT(&pContext->wasapi);
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(MA_WIN32_UWP)
|
||||||
|
{
|
||||||
|
/* Link to mmdevapi so we can get access to ActivateAudioInterfaceAsync(). */
|
||||||
|
pContext->wasapi.hMMDevapi = ma_dlopen(ma_context_get_log(pContext), "mmdevapi.dll");
|
||||||
|
if (pContext->wasapi.hMMDevapi) {
|
||||||
|
pContext->wasapi.ActivateAudioInterfaceAsync = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi, "ActivateAudioInterfaceAsync");
|
||||||
|
if (pContext->wasapi.ActivateAudioInterfaceAsync == NULL) {
|
||||||
|
ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi);
|
||||||
|
return MA_NO_BACKEND; /* ActivateAudioInterfaceAsync() could not be loaded. */
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return MA_NO_BACKEND; /* Failed to load mmdevapi.dll which is required for ActivateAudioInterfaceAsync() */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Optionally use the Avrt API to specify the audio thread's latency sensitivity requirements */
|
||||||
|
pContext->wasapi.hAvrt = ma_dlopen(ma_context_get_log(pContext), "avrt.dll");
|
||||||
|
if (pContext->wasapi.hAvrt) {
|
||||||
|
pContext->wasapi.AvSetMmThreadCharacteristicsA = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hAvrt, "AvSetMmThreadCharacteristicsA");
|
||||||
|
pContext->wasapi.AvRevertMmThreadcharacteristics = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hAvrt, "AvRevertMmThreadCharacteristics");
|
||||||
|
|
||||||
|
/* If either function could not be found, disable use of avrt entirely. */
|
||||||
|
if (!pContext->wasapi.AvSetMmThreadCharacteristicsA || !pContext->wasapi.AvRevertMmThreadcharacteristics) {
|
||||||
|
pContext->wasapi.AvSetMmThreadCharacteristicsA = NULL;
|
||||||
|
pContext->wasapi.AvRevertMmThreadcharacteristics = NULL;
|
||||||
|
ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hAvrt);
|
||||||
|
pContext->wasapi.hAvrt = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Annoyingly, WASAPI does not allow you to release an IAudioClient object from a different thread
|
Annoyingly, WASAPI does not allow you to release an IAudioClient object from a different thread
|
||||||
than the one that retrieved it with GetService(). This can result in a deadlock in two
|
than the one that retrieved it with GetService(). This can result in a deadlock in two
|
||||||
@@ -23554,41 +23587,6 @@ static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_
|
|||||||
ma_mutex_uninit(&pContext->wasapi.commandLock);
|
ma_mutex_uninit(&pContext->wasapi.commandLock);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MA_WIN32_UWP)
|
|
||||||
{
|
|
||||||
/* Link to mmdevapi so we can get access to ActivateAudioInterfaceAsync(). */
|
|
||||||
pContext->wasapi.hMMDevapi = ma_dlopen(ma_context_get_log(pContext), "mmdevapi.dll");
|
|
||||||
if (pContext->wasapi.hMMDevapi) {
|
|
||||||
pContext->wasapi.ActivateAudioInterfaceAsync = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi, "ActivateAudioInterfaceAsync");
|
|
||||||
if (pContext->wasapi.ActivateAudioInterfaceAsync == NULL) {
|
|
||||||
ma_semaphore_uninit(&pContext->wasapi.commandSem);
|
|
||||||
ma_mutex_uninit(&pContext->wasapi.commandLock);
|
|
||||||
ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi);
|
|
||||||
return MA_NO_BACKEND; /* ActivateAudioInterfaceAsync() could not be loaded. */
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ma_semaphore_uninit(&pContext->wasapi.commandSem);
|
|
||||||
ma_mutex_uninit(&pContext->wasapi.commandLock);
|
|
||||||
return MA_NO_BACKEND; /* Failed to load mmdevapi.dll which is required for ActivateAudioInterfaceAsync() */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Optionally use the Avrt API to specify the audio thread's latency sensitivity requirements */
|
|
||||||
pContext->wasapi.hAvrt = ma_dlopen(ma_context_get_log(pContext), "avrt.dll");
|
|
||||||
if (pContext->wasapi.hAvrt) {
|
|
||||||
pContext->wasapi.AvSetMmThreadCharacteristicsA = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hAvrt, "AvSetMmThreadCharacteristicsA");
|
|
||||||
pContext->wasapi.AvRevertMmThreadcharacteristics = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hAvrt, "AvRevertMmThreadCharacteristics");
|
|
||||||
|
|
||||||
/* If either function could not be found, disable use of avrt entirely. */
|
|
||||||
if (!pContext->wasapi.AvSetMmThreadCharacteristicsA || !pContext->wasapi.AvRevertMmThreadcharacteristics) {
|
|
||||||
pContext->wasapi.AvSetMmThreadCharacteristicsA = NULL;
|
|
||||||
pContext->wasapi.AvRevertMmThreadcharacteristics = NULL;
|
|
||||||
ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hAvrt);
|
|
||||||
pContext->wasapi.hAvrt = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ will receive the captured audio.
|
|||||||
If multiple backends are specified, the priority will be based on the order in which you specify them. If multiple waveform or noise types
|
If multiple backends are specified, the priority will be based on the order in which you specify them. If multiple waveform or noise types
|
||||||
are specified the last one on the command line will have priority.
|
are specified the last one on the command line will have priority.
|
||||||
*/
|
*/
|
||||||
|
#define MA_FORCE_UWP
|
||||||
#include "../test_common/ma_test_common.c"
|
#include "../test_common/ma_test_common.c"
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
|||||||
Reference in New Issue
Block a user