Skip to content

Commit e84a420

Browse files
committed
Update miniaudio to v0.11.21
1 parent efc0fed commit e84a420

1 file changed

Lines changed: 31 additions & 8 deletions

File tree

src/external/miniaudio.h

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
3-
miniaudio - v0.11.20 - 2023-11-10
3+
miniaudio - v0.11.21 - 2023-11-15
44

55
David Reid - mackron@gmail.com
66

@@ -3723,7 +3723,7 @@ extern "C" {
37233723

37243724
#define MA_VERSION_MAJOR 0
37253725
#define MA_VERSION_MINOR 11
3726-
#define MA_VERSION_REVISION 20
3726+
#define MA_VERSION_REVISION 21
37273727
#define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION)
37283728

37293729
#if defined(_MSC_VER) && !defined(__clang__)
@@ -6716,7 +6716,8 @@ typedef enum
67166716
ma_device_notification_type_stopped,
67176717
ma_device_notification_type_rerouted,
67186718
ma_device_notification_type_interruption_began,
6719-
ma_device_notification_type_interruption_ended
6719+
ma_device_notification_type_interruption_ended,
6720+
ma_device_notification_type_unlocked
67206721
} ma_device_notification_type;
67216722

67226723
typedef struct
@@ -18668,6 +18669,14 @@ static void ma_device__on_notification_rerouted(ma_device* pDevice)
1866818669
}
1866918670
#endif
1867018671

18672+
#if defined(MA_EMSCRIPTEN)
18673+
EMSCRIPTEN_KEEPALIVE
18674+
void ma_device__on_notification_unlocked(ma_device* pDevice)
18675+
{
18676+
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_unlocked));
18677+
}
18678+
#endif
18679+
1867118680

1867218681
static void ma_device__on_data_inner(ma_device* pDevice, void* pFramesOut, const void* pFramesIn, ma_uint32 frameCount)
1867318682
{
@@ -32797,9 +32806,9 @@ static ma_result ma_find_best_format__coreaudio(ma_context* pContext, AudioObjec
3279732806

3279832807
hasSupportedFormat = MA_FALSE;
3279932808
for (iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) {
32800-
ma_format format;
32801-
ma_result formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &format);
32802-
if (formatResult == MA_SUCCESS && format != ma_format_unknown) {
32809+
ma_format formatFromDescription;
32810+
ma_result formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &formatFromDescription);
32811+
if (formatResult == MA_SUCCESS && formatFromDescription != ma_format_unknown) {
3280332812
hasSupportedFormat = MA_TRUE;
3280432813
bestDeviceFormatSoFar = pDeviceFormatDescriptions[iFormat].mFormat;
3280532814
break;
@@ -39800,6 +39809,7 @@ static ma_result ma_device_uninit__webaudio(ma_device* pDevice)
3980039809
*/
3980139810
device.webaudio.close();
3980239811
device.webaudio = undefined;
39812+
device.pDevice = undefined;
3980339813
}, pDevice->webaudio.deviceIndex);
3980439814
}
3980539815
#endif
@@ -39823,6 +39833,10 @@ static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__webaudio(co
3982339833
*/
3982439834
ma_uint32 periodSizeInFrames;
3982539835

39836+
if (nativeSampleRate == 0) {
39837+
nativeSampleRate = MA_DEFAULT_SAMPLE_RATE;
39838+
}
39839+
3982639840
if (pDescriptor->periodSizeInFrames == 0) {
3982739841
if (pDescriptor->periodSizeInMilliseconds == 0) {
3982839842
if (performanceProfile == ma_performance_profile_low_latency) {
@@ -40295,6 +40309,8 @@ static ma_result ma_device_init__webaudio(ma_device* pDevice, const ma_device_co
4029540309
device.scriptNode.connect(device.webaudio.destination);
4029640310
}
4029740311

40312+
device.pDevice = pDevice;
40313+
4029840314
return miniaudio.track_device(device);
4029940315
}, pConfig->deviceType, channels, sampleRate, periodSizeInFrames, pDevice->webaudio.pIntermediaryBuffer, pDevice);
4030040316

@@ -40467,8 +40483,15 @@ static ma_result ma_context_init__webaudio(ma_context* pContext, const ma_contex
4046740483
miniaudio.unlock = function() {
4046840484
for(var i = 0; i < miniaudio.devices.length; ++i) {
4046940485
var device = miniaudio.devices[i];
40470-
if (device != null && device.webaudio != null && device.state === 2 /* ma_device_state_started */) {
40471-
device.webaudio.resume();
40486+
if (device != null &&
40487+
device.webaudio != null &&
40488+
device.state === window.miniaudio.device_state.started) {
40489+
40490+
device.webaudio.resume().then(() => {
40491+
Module._ma_device__on_notification_unlocked(device.pDevice);
40492+
},
40493+
(error) => {console.error("Failed to resume audiocontext", error);
40494+
});
4047240495
}
4047340496
}
4047440497
miniaudio.unlock_event_types.map(function(event_type) {

0 commit comments

Comments
 (0)