mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Merge branch 'master' into dev-0.11
This commit is contained in:
@@ -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.10.38 - 2021-07-14
|
miniaudio - v0.10.39 - 2021-07-20
|
||||||
|
|
||||||
David Reid - mackron@gmail.com
|
David Reid - mackron@gmail.com
|
||||||
|
|
||||||
@@ -16367,18 +16367,25 @@ static ma_result ma_context_get_device_info__pulse(ma_context* pContext, ma_devi
|
|||||||
ma_result result = MA_SUCCESS;
|
ma_result result = MA_SUCCESS;
|
||||||
ma_context_get_device_info_callback_data__pulse callbackData;
|
ma_context_get_device_info_callback_data__pulse callbackData;
|
||||||
ma_pa_operation* pOP = NULL;
|
ma_pa_operation* pOP = NULL;
|
||||||
|
const char* pDeviceName = NULL;
|
||||||
|
|
||||||
MA_ASSERT(pContext != NULL);
|
MA_ASSERT(pContext != NULL);
|
||||||
|
|
||||||
callbackData.pDeviceInfo = pDeviceInfo;
|
callbackData.pDeviceInfo = pDeviceInfo;
|
||||||
callbackData.foundDevice = MA_FALSE;
|
callbackData.foundDevice = MA_FALSE;
|
||||||
|
|
||||||
|
if (pDeviceID != NULL) {
|
||||||
|
pDeviceName = pDeviceID->pulse;
|
||||||
|
} else {
|
||||||
|
pDeviceName = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
result = ma_context_get_default_device_index__pulse(pContext, deviceType, &callbackData.defaultDeviceIndex);
|
result = ma_context_get_default_device_index__pulse(pContext, deviceType, &callbackData.defaultDeviceIndex);
|
||||||
|
|
||||||
if (deviceType == ma_device_type_playback) {
|
if (deviceType == ma_device_type_playback) {
|
||||||
pOP = ((ma_pa_context_get_sink_info_by_name_proc)pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceID->pulse, ma_context_get_device_info_sink_callback__pulse, &callbackData);
|
pOP = ((ma_pa_context_get_sink_info_by_name_proc)pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceName, ma_context_get_device_info_sink_callback__pulse, &callbackData);
|
||||||
} else {
|
} else {
|
||||||
pOP = ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceID->pulse, ma_context_get_device_info_source_callback__pulse, &callbackData);
|
pOP = ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceName, ma_context_get_device_info_source_callback__pulse, &callbackData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pOP != NULL) {
|
if (pOP != NULL) {
|
||||||
@@ -16630,14 +16637,9 @@ static void ma_device_on_suspended__pulse(ma_pa_stream* pStream, void* pUserData
|
|||||||
if (suspended == 1) {
|
if (suspended == 1) {
|
||||||
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[Pulse] Device suspended state changed. Suspended.\n");
|
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[Pulse] Device suspended state changed. Suspended.\n");
|
||||||
|
|
||||||
/* Locking this behind MA_DEBUG_OUTPUT for the moment while this is still in an experimental state. */
|
if (pDevice->onStop) {
|
||||||
#if defined(MA_DEBUG_OUTPUT)
|
pDevice->onStop(pDevice);
|
||||||
{
|
|
||||||
if (pDevice->onStop) {
|
|
||||||
pDevice->onStop(pDevice);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[Pulse] Device suspended state changed. Resumed.\n");
|
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[Pulse] Device suspended state changed. Resumed.\n");
|
||||||
}
|
}
|
||||||
@@ -19818,6 +19820,12 @@ static void on_start_stop__coreaudio(void* pUserData, AudioUnit audioUnit, Audio
|
|||||||
ma_device* pDevice = (ma_device*)pUserData;
|
ma_device* pDevice = (ma_device*)pUserData;
|
||||||
MA_ASSERT(pDevice != NULL);
|
MA_ASSERT(pDevice != NULL);
|
||||||
|
|
||||||
|
/* Don't do anything if it looks like we're just reinitializing due to a device switch. */
|
||||||
|
if (((audioUnit == pDevice->coreaudio.audioUnitPlayback) && pDevice->coreaudio.isSwitchingPlaybackDevice) ||
|
||||||
|
((audioUnit == pDevice->coreaudio.audioUnitCapture) && pDevice->coreaudio.isSwitchingCaptureDevice)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
There's been a report of a deadlock here when triggered by ma_device_uninit(). It looks like
|
There's been a report of a deadlock here when triggered by ma_device_uninit(). It looks like
|
||||||
AudioUnitGetProprty (called below) and AudioComponentInstanceDispose (called in ma_device_uninit)
|
AudioUnitGetProprty (called below) and AudioComponentInstanceDispose (called in ma_device_uninit)
|
||||||
@@ -20146,23 +20154,23 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice)
|
|||||||
|
|
||||||
case AVAudioSessionRouteChangeReasonWakeFromSleep:
|
case AVAudioSessionRouteChangeReasonWakeFromSleep:
|
||||||
{
|
{
|
||||||
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonWakeFromSleep\n");
|
ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_DEBUG, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonWakeFromSleep\n");
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case AVAudioSessionRouteChangeReasonOverride:
|
case AVAudioSessionRouteChangeReasonOverride:
|
||||||
{
|
{
|
||||||
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonOverride\n");
|
ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_DEBUG, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonOverride\n");
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case AVAudioSessionRouteChangeReasonCategoryChange:
|
case AVAudioSessionRouteChangeReasonCategoryChange:
|
||||||
{
|
{
|
||||||
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonCategoryChange\n");
|
ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_DEBUG, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonCategoryChange\n");
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case AVAudioSessionRouteChangeReasonUnknown:
|
case AVAudioSessionRouteChangeReasonUnknown:
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonUnknown\n");
|
ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_DEBUG, "[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonUnknown\n");
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26275,7 +26283,8 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
|
|||||||
ma_event_signal(&pDevice->stopEvent);
|
ma_event_signal(&pDevice->stopEvent);
|
||||||
|
|
||||||
for (;;) { /* <-- This loop just keeps the thread alive. The main audio loop is inside. */
|
for (;;) { /* <-- This loop just keeps the thread alive. The main audio loop is inside. */
|
||||||
ma_stop_proc onStop;
|
ma_result startResult;
|
||||||
|
ma_result stopResult; /* <-- This will store the result from onDeviceStop(). If it returns an error, we don't fire the onStop callback. */
|
||||||
|
|
||||||
/* We wait on an event to know when something has requested that the device be started and the main loop entered. */
|
/* We wait on an event to know when something has requested that the device be started and the main loop entered. */
|
||||||
ma_event_wait(&pDevice->wakeupEvent);
|
ma_event_wait(&pDevice->wakeupEvent);
|
||||||
@@ -26297,10 +26306,14 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
|
|||||||
|
|
||||||
/* If the device has a start callback, start it now. */
|
/* If the device has a start callback, start it now. */
|
||||||
if (pDevice->pContext->callbacks.onDeviceStart != NULL) {
|
if (pDevice->pContext->callbacks.onDeviceStart != NULL) {
|
||||||
ma_result result = pDevice->pContext->callbacks.onDeviceStart(pDevice);
|
startResult = pDevice->pContext->callbacks.onDeviceStart(pDevice);
|
||||||
if (result != MA_SUCCESS) {
|
} else {
|
||||||
pDevice->workResult = result; /* Failed to start the device. */
|
startResult = MA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (startResult != MA_SUCCESS) {
|
||||||
|
pDevice->workResult = startResult;
|
||||||
|
continue; /* Failed to start. Loop back to the start and wait for something to happen (pDevice->wakeupEvent). */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure the state is set appropriately. */
|
/* Make sure the state is set appropriately. */
|
||||||
@@ -26314,37 +26327,27 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
|
|||||||
ma_device_audio_thread__default_read_write(pDevice);
|
ma_device_audio_thread__default_read_write(pDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Getting here means we have broken from the main loop which happens the application has requested that device be stopped. */
|
||||||
Getting here means we have broken from the main loop which happens the application has requested that device be stopped. Note that this
|
if (pDevice->pContext->callbacks.onDeviceStop != NULL) {
|
||||||
may have actually already happened above if the device was lost and miniaudio has attempted to re-initialize the device. In this case we
|
stopResult = pDevice->pContext->callbacks.onDeviceStop(pDevice);
|
||||||
don't want to be doing this a second time.
|
} else {
|
||||||
*/
|
stopResult = MA_SUCCESS; /* No stop callback with the backend. Just assume successful. */
|
||||||
if (ma_device_get_state(pDevice) != MA_STATE_UNINITIALIZED) {
|
|
||||||
if (pDevice->pContext->callbacks.onDeviceStop != NULL) {
|
|
||||||
pDevice->pContext->callbacks.onDeviceStop(pDevice);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* After the device has stopped, make sure an event is posted. */
|
|
||||||
onStop = pDevice->onStop;
|
|
||||||
if (onStop) {
|
|
||||||
onStop(pDevice);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
A function somewhere is waiting for the device to have stopped for real so we need to signal an event to allow it to continue. Note that
|
After the device has stopped, make sure an event is posted. Don't post an onStop event if
|
||||||
it's possible that the device has been uninitialized which means we need to _not_ change the status to stopped. We cannot go from an
|
stopping failed. This can happen on some backends when the underlying stream has been
|
||||||
uninitialized state to stopped state.
|
stopped due to the device being physically unplugged or disabled via an OS setting.
|
||||||
*/
|
*/
|
||||||
if (ma_device_get_state(pDevice) != MA_STATE_UNINITIALIZED) {
|
if (pDevice->onStop && stopResult != MA_SUCCESS) {
|
||||||
ma_device__set_state(pDevice, MA_STATE_STOPPED);
|
pDevice->onStop(pDevice);
|
||||||
ma_event_signal(&pDevice->stopEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* A function somewhere is waiting for the device to have stopped for real so we need to signal an event to allow it to continue. */
|
||||||
|
ma_device__set_state(pDevice, MA_STATE_STOPPED);
|
||||||
|
ma_event_signal(&pDevice->stopEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure we aren't continuously waiting on a stop event. */
|
|
||||||
ma_event_signal(&pDevice->stopEvent); /* <-- Is this still needed? */
|
|
||||||
|
|
||||||
#ifdef MA_WIN32
|
#ifdef MA_WIN32
|
||||||
ma_CoUninitialize(pDevice->pContext);
|
ma_CoUninitialize(pDevice->pContext);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -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.10.38 - 2021-07-14
|
miniaudio - v0.10.39 - 2021-07-20
|
||||||
|
|
||||||
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 10
|
#define MA_VERSION_MINOR 10
|
||||||
#define MA_VERSION_REVISION 38
|
#define MA_VERSION_REVISION 39
|
||||||
#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__)
|
||||||
@@ -4797,7 +4797,7 @@ struct ma_decoder
|
|||||||
};
|
};
|
||||||
|
|
||||||
MA_API ma_decoder_config ma_decoder_config_init(ma_format outputFormat, ma_uint32 outputChannels, ma_uint32 outputSampleRate);
|
MA_API ma_decoder_config ma_decoder_config_init(ma_format outputFormat, ma_uint32 outputChannels, ma_uint32 outputSampleRate);
|
||||||
MA_API ma_decoder_config ma_decoder_config_init_default();
|
MA_API ma_decoder_config ma_decoder_config_init_default(void);
|
||||||
|
|
||||||
MA_API ma_result ma_decoder_init(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
|
MA_API ma_result ma_decoder_init(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
|
||||||
MA_API ma_result ma_decoder_init_memory(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
|
MA_API ma_result ma_decoder_init_memory(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
|
||||||
|
|||||||
+13
-4
@@ -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.10.39 - TBD
|
miniaudio - v0.10.39 - 2021-07-20
|
||||||
|
|
||||||
David Reid - mackron@gmail.com
|
David Reid - mackron@gmail.com
|
||||||
|
|
||||||
@@ -25737,18 +25737,25 @@ static ma_result ma_context_get_device_info__pulse(ma_context* pContext, ma_devi
|
|||||||
ma_result result = MA_SUCCESS;
|
ma_result result = MA_SUCCESS;
|
||||||
ma_context_get_device_info_callback_data__pulse callbackData;
|
ma_context_get_device_info_callback_data__pulse callbackData;
|
||||||
ma_pa_operation* pOP = NULL;
|
ma_pa_operation* pOP = NULL;
|
||||||
|
const char* pDeviceName = NULL;
|
||||||
|
|
||||||
MA_ASSERT(pContext != NULL);
|
MA_ASSERT(pContext != NULL);
|
||||||
|
|
||||||
callbackData.pDeviceInfo = pDeviceInfo;
|
callbackData.pDeviceInfo = pDeviceInfo;
|
||||||
callbackData.foundDevice = MA_FALSE;
|
callbackData.foundDevice = MA_FALSE;
|
||||||
|
|
||||||
|
if (pDeviceID != NULL) {
|
||||||
|
pDeviceName = pDeviceID->pulse;
|
||||||
|
} else {
|
||||||
|
pDeviceName = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
result = ma_context_get_default_device_index__pulse(pContext, deviceType, &callbackData.defaultDeviceIndex);
|
result = ma_context_get_default_device_index__pulse(pContext, deviceType, &callbackData.defaultDeviceIndex);
|
||||||
|
|
||||||
if (deviceType == ma_device_type_playback) {
|
if (deviceType == ma_device_type_playback) {
|
||||||
pOP = ((ma_pa_context_get_sink_info_by_name_proc)pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceID->pulse, ma_context_get_device_info_sink_callback__pulse, &callbackData);
|
pOP = ((ma_pa_context_get_sink_info_by_name_proc)pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceName, ma_context_get_device_info_sink_callback__pulse, &callbackData);
|
||||||
} else {
|
} else {
|
||||||
pOP = ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceID->pulse, ma_context_get_device_info_source_callback__pulse, &callbackData);
|
pOP = ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceName, ma_context_get_device_info_source_callback__pulse, &callbackData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pOP != NULL) {
|
if (pOP != NULL) {
|
||||||
@@ -84402,9 +84409,11 @@ The following miscellaneous changes have also been made.
|
|||||||
/*
|
/*
|
||||||
REVISION HISTORY
|
REVISION HISTORY
|
||||||
================
|
================
|
||||||
v0.10.39 - TBD
|
v0.10.39 - 2021-07-20
|
||||||
|
- Core Audio: Fix a deadlock when the default device is changed.
|
||||||
- Core Audio: Fix compilation errors on macOS and iOS.
|
- Core Audio: Fix compilation errors on macOS and iOS.
|
||||||
- PulseAudio: Fix a bug where the stop callback is not fired when a device is unplugged.
|
- PulseAudio: Fix a bug where the stop callback is not fired when a device is unplugged.
|
||||||
|
- PulseAudio: Fix a null pointer dereference.
|
||||||
|
|
||||||
v0.10.38 - 2021-07-14
|
v0.10.38 - 2021-07-14
|
||||||
- Fix a linking error when MA_DEBUG_OUTPUT is not enabled.
|
- Fix a linking error when MA_DEBUG_OUTPUT is not enabled.
|
||||||
|
|||||||
Reference in New Issue
Block a user