From 88375e79c43001eadfefc5a7f18729865ad78d94 Mon Sep 17 00:00:00 2001 From: dskuza Date: Wed, 17 Jul 2024 19:27:42 +0000 Subject: [PATCH] Only set Core Audio session category for iOS targets Fixes a crash in the latest UAT desktop editor(s) on macOS by targeting setting iOS session category to mixing only for iOS / iPadOS / Catalyst targets. The desktop editor is _not_ any of these targets, so the code changes are not compiled. See [here](https://github.com/rive-app/rive/pull/7555/files#r1680306818) for more discussion. Diffs= 6c5c79b75 Only set Core Audio session category for iOS targets (#7624) Co-authored-by: David Skuza --- .rive_head | 2 +- src/audio/audio_engine.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.rive_head b/.rive_head index b46f69f6..fb5018fa 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -8e1be1223161ced9cfb80c0ec3671ffd25ee5cfb +6c5c79b751c50fa4393fb0e44624635861bc3f3b diff --git a/src/audio/audio_engine.cpp b/src/audio/audio_engine.cpp index da487029..0bdd9f9d 100644 --- a/src/audio/audio_engine.cpp +++ b/src/audio/audio_engine.cpp @@ -166,7 +166,8 @@ rcp AudioEngine::Make(uint32_t numChannels, uint32_t sampleRate) // I _think_ MA_NO_DEVICE_IO is defined when building for Unity; otherwise, it seems to pass // "standard" building When defined, pContext is unavailable, which causes build errors when // building Unity for iOS. - David -#if defined(MA_HAS_COREAUDIO) && !defined(MA_NO_DEVICE_IO) +#if (TARGET_IPHONE_SIMULATOR || TARGET_OS_MACCATALYST || TARGET_OS_IPHONE) && \ + !defined(MA_NO_DEVICE_IO) // Used for configuration only, and isn't referenced past the usage of ma_context_init; thus, // can be locally scoped. Uses the "logical" defaults from miniaudio, and updates only what we // need. This should automatically set available backends in priority order based on the target @@ -190,7 +191,8 @@ rcp AudioEngine::Make(uint32_t numChannels, uint32_t sampleRate) engineConfig.channels = numChannels; engineConfig.sampleRate = sampleRate; -#if defined(MA_HAS_COREAUDIO) && !defined(MA_NO_DEVICE_IO) +#if (TARGET_IPHONE_SIMULATOR || TARGET_OS_MACCATALYST || TARGET_OS_IPHONE) && \ + !defined(MA_NO_DEVICE_IO) if (context != nullptr) { engineConfig.pContext = context; @@ -205,7 +207,8 @@ rcp AudioEngine::Make(uint32_t numChannels, uint32_t sampleRate) if (ma_engine_init(&engineConfig, engine) != MA_SUCCESS) { -#if defined(MA_HAS_COREAUDIO) && !defined(MA_NO_DEVICE_IO) +#if (TARGET_IPHONE_SIMULATOR || TARGET_OS_MACCATALYST || TARGET_OS_IPHONE) && \ + !defined(MA_NO_DEVICE_IO) if (context != nullptr) { ma_context_uninit(context); @@ -405,7 +408,8 @@ AudioEngine::~AudioEngine() } m_completedSounds.clear(); -#if defined(MA_HAS_COREAUDIO) && !defined(MA_NO_DEVICE_IO) +#if (TARGET_IPHONE_SIMULATOR || TARGET_OS_MACCATALYST || TARGET_OS_IPHONE) && \ + !defined(MA_NO_DEVICE_IO) // m_context is only set when Core Audio is available if (m_context != nullptr) {