From d6a56e40f0ef1288a11782a5ca962dae202e8db4 Mon Sep 17 00:00:00 2001 From: David Reid Date: Mon, 25 Jan 2021 21:13:00 +1000 Subject: [PATCH] iOS: A small change to the experimental fix from the previous commit. --- miniaudio.h | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index f5cc87b0..9348b140 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -25995,19 +25995,8 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice) case AVAudioSessionRouteChangeReasonNewDeviceAvailable: { #if defined(MA_DEBUG_OUTPUT) - printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonNewDeviceAvailable. inputNumberChannels=%d; outputNumberOfChannels=%d.\n", pSession.inputNumberOfChannels, pSession.outputNumberOfChannels); + printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonNewDeviceAvailable\n"); #endif - - m_pDevice->sampleRate = (ma_uint32)pSession.sampleRate; - - if (m_pDevice->type == ma_device_type_capture || m_pDevice->type == ma_device_type_duplex) { - m_pDevice->capture.internalChannels = (ma_uint32)pSession.inputNumberOfChannels; - ma_device__post_init_setup(m_pDevice, ma_device_type_capture); - } - if (m_pDevice->type == ma_device_type_playback || m_pDevice->type == ma_device_type_duplex) { - m_pDevice->playback.internalChannels = (ma_uint32)pSession.outputNumberOfChannels; - ma_device__post_init_setup(m_pDevice, ma_device_type_playback); - } } break; case AVAudioSessionRouteChangeReasonNoSuitableRouteForCategory: @@ -26046,6 +26035,23 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice) #endif } break; } + + if (reason == AVAudioSessionRouteChangeReasonNewDeviceAvailable || reason == AVAudioSessionRouteChangeReasonCategoryChange || reason == AVAudioSessionRouteChangeReasonOverride) { + #if defined(MA_DEBUG_OUTPUT) + printf("[Core Audio] Changing Route. inputNumberChannels=%d; outputNumberOfChannels=%d\n", pSession.inputNumberOfChannels, pSession.outputNumberOfChannels); + #endif + + m_pDevice->sampleRate = (ma_uint32)pSession.sampleRate; + + if (m_pDevice->type == ma_device_type_capture || m_pDevice->type == ma_device_type_duplex) { + m_pDevice->capture.internalChannels = (ma_uint32)pSession.inputNumberOfChannels; + ma_device__post_init_setup(m_pDevice, ma_device_type_capture); + } + if (m_pDevice->type == ma_device_type_playback || m_pDevice->type == ma_device_type_duplex) { + m_pDevice->playback.internalChannels = (ma_uint32)pSession.outputNumberOfChannels; + ma_device__post_init_setup(m_pDevice, ma_device_type_playback); + } + } } @end #endif