Skip to content

Commit

Permalink
only start/stop the audio engine if its been initialized
Browse files Browse the repository at this point in the history
simple things first.

after some debugging on audio "ducking"

it looks like we only start to kill audio after we initialize the audio engine. this first "fix" simply prevents us from initializing the audio engine if its not already been initialized. when going into the background/foreground.

other than this, we initialize the audio engine when you first play an audio clip in `void AudioEvent::play()`

this still leaves an issue lying around where after we have initialized the audio engine we will now "forever" duck audio when we go into the background/foreground. but at least you should be able to avoid this entirely if you never load a file with audio.

Diffs=
d4b3118e1 only start/stop the audio engine if its been initialized (#7335)

Co-authored-by: Maxwell Talbot <[email protected]>
  • Loading branch information
mjtalbot and mjtalbot committed Jun 3, 2024
1 parent 296c14d commit fbe16bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dde676085908d492af545660cbbb19ee0d10d91d
d4b3118e1930e8e60565938a7c266d092a1ed940
12 changes: 10 additions & 2 deletions Source/Renderer/rive_renderer_view.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@ @implementation RiveRendererView

- (void)didEnterBackground:(NSNotification*)notification
{
rive::AudioEngine::RuntimeEngine()->stop();
auto engine = rive::AudioEngine::RuntimeEngine(false);
if (engine != nil)
{
engine->stop();
}
}

- (void)didEnterForeground:(NSNotification*)notification
{
rive::AudioEngine::RuntimeEngine()->start();
auto engine = rive::AudioEngine::RuntimeEngine(false);
if (engine != nil)
{
engine->start();
}
}

- (instancetype)initWithCoder:(NSCoder*)decoder
Expand Down

0 comments on commit fbe16bb

Please sign in to comment.