mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 08:44:04 +02:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a5b74bef0 | |||
| c77d40ba00 | |||
| 8fcf6889aa | |||
| f9ce46330c | |||
| 3b50a854ec | |||
| da0572e6b8 | |||
| eb0ce6f1a5 |
+13
@@ -1,3 +1,16 @@
|
|||||||
|
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.
|
||||||
|
* Web: Fix an error where the buffer size is incorrectly calculated.
|
||||||
|
* Core Audio: Fix a -Wshadow warning.
|
||||||
|
|
||||||
|
|
||||||
|
v0.11.20 - 2023-11-10
|
||||||
|
=====================
|
||||||
|
* Fix a compilation error with iOS.
|
||||||
|
* 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.
|
||||||
|
|||||||
@@ -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.21 - 2023-11-15
|
||||||
|
|
||||||
David Reid - mackron@gmail.com
|
David Reid - mackron@gmail.com
|
||||||
|
|
||||||
@@ -6397,7 +6397,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()... */
|
||||||
@@ -7245,16 +7245,11 @@ static void ma_device__on_notification_rerouted(ma_device* pDevice)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Interruptions are only used on some platforms. */
|
#if defined(MA_EMSCRIPTEN)
|
||||||
#if defined(MA_APPLE_MOBILE)
|
EMSCRIPTEN_KEEPALIVE
|
||||||
static void ma_device__on_notification_interruption_began(ma_device* pDevice)
|
void ma_device__on_notification_unlocked(ma_device* pDevice)
|
||||||
{
|
{
|
||||||
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_began));
|
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_unlocked));
|
||||||
}
|
|
||||||
|
|
||||||
static void ma_device__on_notification_interruption_ended(ma_device* pDevice)
|
|
||||||
{
|
|
||||||
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_ended));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -12088,6 +12083,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
|
||||||
@@ -12131,41 +12159,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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -20461,6 +20454,18 @@ size, allocate a block of memory of that size and then call AudioObjectGetProper
|
|||||||
AudioDeviceID's so just do "dataSize/sizeof(AudioDeviceID)" to know the device count.
|
AudioDeviceID's so just do "dataSize/sizeof(AudioDeviceID)" to know the device count.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined(MA_APPLE_MOBILE)
|
||||||
|
static void ma_device__on_notification_interruption_began(ma_device* pDevice)
|
||||||
|
{
|
||||||
|
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_began));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ma_device__on_notification_interruption_ended(ma_device* pDevice)
|
||||||
|
{
|
||||||
|
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_ended));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static ma_result ma_result_from_OSStatus(OSStatus status)
|
static ma_result ma_result_from_OSStatus(OSStatus status)
|
||||||
{
|
{
|
||||||
switch (status)
|
switch (status)
|
||||||
@@ -21377,9 +21382,9 @@ static ma_result ma_find_best_format__coreaudio(ma_context* pContext, AudioObjec
|
|||||||
|
|
||||||
hasSupportedFormat = MA_FALSE;
|
hasSupportedFormat = MA_FALSE;
|
||||||
for (iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) {
|
for (iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) {
|
||||||
ma_format format;
|
ma_format formatFromDescription;
|
||||||
ma_result formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &format);
|
ma_result formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &formatFromDescription);
|
||||||
if (formatResult == MA_SUCCESS && format != ma_format_unknown) {
|
if (formatResult == MA_SUCCESS && formatFromDescription != ma_format_unknown) {
|
||||||
hasSupportedFormat = MA_TRUE;
|
hasSupportedFormat = MA_TRUE;
|
||||||
bestDeviceFormatSoFar = pDeviceFormatDescriptions[iFormat].mFormat;
|
bestDeviceFormatSoFar = pDeviceFormatDescriptions[iFormat].mFormat;
|
||||||
break;
|
break;
|
||||||
@@ -28380,6 +28385,7 @@ static ma_result ma_device_uninit__webaudio(ma_device* pDevice)
|
|||||||
*/
|
*/
|
||||||
device.webaudio.close();
|
device.webaudio.close();
|
||||||
device.webaudio = undefined;
|
device.webaudio = undefined;
|
||||||
|
device.pDevice = undefined;
|
||||||
}, pDevice->webaudio.deviceIndex);
|
}, pDevice->webaudio.deviceIndex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -28403,6 +28409,10 @@ static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__webaudio(co
|
|||||||
*/
|
*/
|
||||||
ma_uint32 periodSizeInFrames;
|
ma_uint32 periodSizeInFrames;
|
||||||
|
|
||||||
|
if (nativeSampleRate == 0) {
|
||||||
|
nativeSampleRate = MA_DEFAULT_SAMPLE_RATE;
|
||||||
|
}
|
||||||
|
|
||||||
if (pDescriptor->periodSizeInFrames == 0) {
|
if (pDescriptor->periodSizeInFrames == 0) {
|
||||||
if (pDescriptor->periodSizeInMilliseconds == 0) {
|
if (pDescriptor->periodSizeInMilliseconds == 0) {
|
||||||
if (performanceProfile == ma_performance_profile_low_latency) {
|
if (performanceProfile == ma_performance_profile_low_latency) {
|
||||||
@@ -28875,6 +28885,8 @@ static ma_result ma_device_init__webaudio(ma_device* pDevice, const ma_device_co
|
|||||||
device.scriptNode.connect(device.webaudio.destination);
|
device.scriptNode.connect(device.webaudio.destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device.pDevice = pDevice;
|
||||||
|
|
||||||
return miniaudio.track_device(device);
|
return miniaudio.track_device(device);
|
||||||
}, pConfig->deviceType, channels, sampleRate, periodSizeInFrames, pDevice->webaudio.pIntermediaryBuffer, pDevice);
|
}, pConfig->deviceType, channels, sampleRate, periodSizeInFrames, pDevice->webaudio.pIntermediaryBuffer, pDevice);
|
||||||
|
|
||||||
@@ -29047,8 +29059,15 @@ static ma_result ma_context_init__webaudio(ma_context* pContext, const ma_contex
|
|||||||
miniaudio.unlock = function() {
|
miniaudio.unlock = function() {
|
||||||
for(var i = 0; i < miniaudio.devices.length; ++i) {
|
for(var i = 0; i < miniaudio.devices.length; ++i) {
|
||||||
var device = miniaudio.devices[i];
|
var device = miniaudio.devices[i];
|
||||||
if (device != null && device.webaudio != null && device.state === 2 /* ma_device_state_started */) {
|
if (device != null &&
|
||||||
device.webaudio.resume();
|
device.webaudio != null &&
|
||||||
|
device.state === window.miniaudio.device_state.started) {
|
||||||
|
|
||||||
|
device.webaudio.resume().then(() => {
|
||||||
|
Module._ma_device__on_notification_unlocked(device.pDevice);
|
||||||
|
},
|
||||||
|
(error) => {console.error("Failed to resume audiocontext", error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
miniaudio.unlock_event_types.map(function(event_type) {
|
miniaudio.unlock_event_types.map(function(event_type) {
|
||||||
|
|||||||
@@ -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.21 - 2023-11-15
|
||||||
|
|
||||||
David Reid - mackron@gmail.com
|
David Reid - mackron@gmail.com
|
||||||
|
|
||||||
@@ -20,7 +20,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 21
|
||||||
#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__)
|
||||||
@@ -3013,7 +3013,8 @@ typedef enum
|
|||||||
ma_device_notification_type_stopped,
|
ma_device_notification_type_stopped,
|
||||||
ma_device_notification_type_rerouted,
|
ma_device_notification_type_rerouted,
|
||||||
ma_device_notification_type_interruption_began,
|
ma_device_notification_type_interruption_began,
|
||||||
ma_device_notification_type_interruption_ended
|
ma_device_notification_type_interruption_ended,
|
||||||
|
ma_device_notification_type_unlocked
|
||||||
} ma_device_notification_type;
|
} ma_device_notification_type;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|||||||
+73
-53
@@ -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.21 - 2023-11-15
|
||||||
|
|
||||||
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 21
|
||||||
#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__)
|
||||||
@@ -6716,7 +6716,8 @@ typedef enum
|
|||||||
ma_device_notification_type_stopped,
|
ma_device_notification_type_stopped,
|
||||||
ma_device_notification_type_rerouted,
|
ma_device_notification_type_rerouted,
|
||||||
ma_device_notification_type_interruption_began,
|
ma_device_notification_type_interruption_began,
|
||||||
ma_device_notification_type_interruption_ended
|
ma_device_notification_type_interruption_ended,
|
||||||
|
ma_device_notification_type_unlocked
|
||||||
} ma_device_notification_type;
|
} ma_device_notification_type;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -17820,7 +17821,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()... */
|
||||||
@@ -18668,16 +18669,11 @@ static void ma_device__on_notification_rerouted(ma_device* pDevice)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Interruptions are only used on some platforms. */
|
#if defined(MA_EMSCRIPTEN)
|
||||||
#if defined(MA_APPLE_MOBILE)
|
EMSCRIPTEN_KEEPALIVE
|
||||||
static void ma_device__on_notification_interruption_began(ma_device* pDevice)
|
void ma_device__on_notification_unlocked(ma_device* pDevice)
|
||||||
{
|
{
|
||||||
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_began));
|
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_unlocked));
|
||||||
}
|
|
||||||
|
|
||||||
static void ma_device__on_notification_interruption_ended(ma_device* pDevice)
|
|
||||||
{
|
|
||||||
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_ended));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -23511,6 +23507,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 +23583,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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -31884,6 +31878,18 @@ size, allocate a block of memory of that size and then call AudioObjectGetProper
|
|||||||
AudioDeviceID's so just do "dataSize/sizeof(AudioDeviceID)" to know the device count.
|
AudioDeviceID's so just do "dataSize/sizeof(AudioDeviceID)" to know the device count.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined(MA_APPLE_MOBILE)
|
||||||
|
static void ma_device__on_notification_interruption_began(ma_device* pDevice)
|
||||||
|
{
|
||||||
|
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_began));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ma_device__on_notification_interruption_ended(ma_device* pDevice)
|
||||||
|
{
|
||||||
|
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_ended));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static ma_result ma_result_from_OSStatus(OSStatus status)
|
static ma_result ma_result_from_OSStatus(OSStatus status)
|
||||||
{
|
{
|
||||||
switch (status)
|
switch (status)
|
||||||
@@ -32800,9 +32806,9 @@ static ma_result ma_find_best_format__coreaudio(ma_context* pContext, AudioObjec
|
|||||||
|
|
||||||
hasSupportedFormat = MA_FALSE;
|
hasSupportedFormat = MA_FALSE;
|
||||||
for (iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) {
|
for (iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) {
|
||||||
ma_format format;
|
ma_format formatFromDescription;
|
||||||
ma_result formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &format);
|
ma_result formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &formatFromDescription);
|
||||||
if (formatResult == MA_SUCCESS && format != ma_format_unknown) {
|
if (formatResult == MA_SUCCESS && formatFromDescription != ma_format_unknown) {
|
||||||
hasSupportedFormat = MA_TRUE;
|
hasSupportedFormat = MA_TRUE;
|
||||||
bestDeviceFormatSoFar = pDeviceFormatDescriptions[iFormat].mFormat;
|
bestDeviceFormatSoFar = pDeviceFormatDescriptions[iFormat].mFormat;
|
||||||
break;
|
break;
|
||||||
@@ -39803,6 +39809,7 @@ static ma_result ma_device_uninit__webaudio(ma_device* pDevice)
|
|||||||
*/
|
*/
|
||||||
device.webaudio.close();
|
device.webaudio.close();
|
||||||
device.webaudio = undefined;
|
device.webaudio = undefined;
|
||||||
|
device.pDevice = undefined;
|
||||||
}, pDevice->webaudio.deviceIndex);
|
}, pDevice->webaudio.deviceIndex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -39826,6 +39833,10 @@ static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__webaudio(co
|
|||||||
*/
|
*/
|
||||||
ma_uint32 periodSizeInFrames;
|
ma_uint32 periodSizeInFrames;
|
||||||
|
|
||||||
|
if (nativeSampleRate == 0) {
|
||||||
|
nativeSampleRate = MA_DEFAULT_SAMPLE_RATE;
|
||||||
|
}
|
||||||
|
|
||||||
if (pDescriptor->periodSizeInFrames == 0) {
|
if (pDescriptor->periodSizeInFrames == 0) {
|
||||||
if (pDescriptor->periodSizeInMilliseconds == 0) {
|
if (pDescriptor->periodSizeInMilliseconds == 0) {
|
||||||
if (performanceProfile == ma_performance_profile_low_latency) {
|
if (performanceProfile == ma_performance_profile_low_latency) {
|
||||||
@@ -40298,6 +40309,8 @@ static ma_result ma_device_init__webaudio(ma_device* pDevice, const ma_device_co
|
|||||||
device.scriptNode.connect(device.webaudio.destination);
|
device.scriptNode.connect(device.webaudio.destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device.pDevice = pDevice;
|
||||||
|
|
||||||
return miniaudio.track_device(device);
|
return miniaudio.track_device(device);
|
||||||
}, pConfig->deviceType, channels, sampleRate, periodSizeInFrames, pDevice->webaudio.pIntermediaryBuffer, pDevice);
|
}, pConfig->deviceType, channels, sampleRate, periodSizeInFrames, pDevice->webaudio.pIntermediaryBuffer, pDevice);
|
||||||
|
|
||||||
@@ -40470,8 +40483,15 @@ static ma_result ma_context_init__webaudio(ma_context* pContext, const ma_contex
|
|||||||
miniaudio.unlock = function() {
|
miniaudio.unlock = function() {
|
||||||
for(var i = 0; i < miniaudio.devices.length; ++i) {
|
for(var i = 0; i < miniaudio.devices.length; ++i) {
|
||||||
var device = miniaudio.devices[i];
|
var device = miniaudio.devices[i];
|
||||||
if (device != null && device.webaudio != null && device.state === 2 /* ma_device_state_started */) {
|
if (device != null &&
|
||||||
device.webaudio.resume();
|
device.webaudio != null &&
|
||||||
|
device.state === window.miniaudio.device_state.started) {
|
||||||
|
|
||||||
|
device.webaudio.resume().then(() => {
|
||||||
|
Module._ma_device__on_notification_unlocked(device.pDevice);
|
||||||
|
},
|
||||||
|
(error) => {console.error("Failed to resume audiocontext", error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
miniaudio.unlock_event_types.map(function(event_type) {
|
miniaudio.unlock_event_types.map(function(event_type) {
|
||||||
|
|||||||
@@ -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