Skip to content

Commit

Permalink
Only set Core Audio session category for iOS targets
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dskuza and dskuza committed Jul 17, 2024
1 parent 595ac88 commit 88375e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8e1be1223161ced9cfb80c0ec3671ffd25ee5cfb
6c5c79b751c50fa4393fb0e44624635861bc3f3b
12 changes: 8 additions & 4 deletions src/audio/audio_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ rcp<AudioEngine> 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
Expand All @@ -190,7 +191,8 @@ rcp<AudioEngine> 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;
Expand All @@ -205,7 +207,8 @@ rcp<AudioEngine> 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);
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 88375e7

Please sign in to comment.