Skip to content

Commit

Permalink
Start & stop audio with renderer thread
Browse files Browse the repository at this point in the history
Following up on https://github.com/rive-app/rive/pull/7055 to make sure Android behaves the same way when apps go in the background

Diffs=
ca916e974 Start & stop audio with renderer thread (#7064)

Co-authored-by: Umberto Sonnino <[email protected]>
  • Loading branch information
umberto-sonnino and umberto-sonnino committed Apr 17, 2024
1 parent 6de7a7f commit 1c71069
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4a9947630d3848ff70813cf5e2d8718adb9a1b90
ca916e974e58c76923bc569ef76d409d82453f68
2 changes: 2 additions & 0 deletions kotlin/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ message("BUILD TYPE: ${CMAKE_BUILD_TYPE}")

add_definitions(-DSK_GL)
add_definitions(-DRIVE_GLES)
# Provide this manually so Android Studio plays nicely with C++.
add_definitions(-DWITH_RIVE_AUDIO)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(SKIA_DIR_NAME "skia_debug")
Expand Down
3 changes: 3 additions & 0 deletions kotlin/src/main/cpp/src/models/worker_impl.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "models/worker_impl.hpp"

#include "rive/pls/gl/pls_render_target_gl.hpp"
#include "rive/audio/audio_engine.hpp"

namespace rive_android
{
Expand Down Expand Up @@ -52,10 +53,12 @@ void WorkerImpl::start(jobject ktRenderer, std::chrono::high_resolution_clock::t
m_ktAdvanceCallback = env->GetMethodID(m_ktRendererClass, "advance", "(F)V");
m_lastFrameTime = frameTime;
m_isStarted = true;
rive::AudioEngine::RuntimeEngine()->start();
}

void WorkerImpl::stop()
{
rive::AudioEngine::RuntimeEngine()->stop();
auto env = GetJNIEnv();
if (m_ktRendererClass != nullptr)
{
Expand Down

0 comments on commit 1c71069

Please sign in to comment.