Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,28 +790,40 @@ void Player::setPause(unsigned int handle, bool pause)
// persistent scheduler thread handles all pause requests.
void Player::pauseEngine()
{
#ifdef __EMSCRIPTEN__
// Web: the wasm build is single-threaded (no pthreads), so the deferred
// scheduler thread cannot run. Pause the device immediately instead. The
// browser's AudioContext does not have the OS audio-session settling issue
// that motivates the delay on native platforms.
if (mInited && soloud.getActiveVoiceCount() == 0)
soloud.pause();
#else
{
std::lock_guard<std::mutex> lock(mPauseMutex);
if (!mPauseThreadRunning)
return;
mPauseRequested = true;
}
mPauseCv.notify_one();
#endif
}

void Player::startPauseEngineScheduler()
{
#ifndef __EMSCRIPTEN__
std::lock_guard<std::mutex> lock(mPauseMutex);
if (mPauseThreadRunning)
return;
mStopPauseThread = false;
mPauseRequested = false;
mPauseThread = std::thread(&Player::pauseEngineScheduler, this);
mPauseThreadRunning = true;
#endif
}

void Player::stopPauseEngineScheduler()
{
#ifndef __EMSCRIPTEN__
{
std::lock_guard<std::mutex> lock(mPauseMutex);
if (!mPauseThreadRunning)
Expand All @@ -826,6 +838,7 @@ void Player::stopPauseEngineScheduler()
std::lock_guard<std::mutex> lock(mPauseMutex);
mPauseThreadRunning = false;
}
#endif
}

void Player::pauseEngineScheduler()
Expand Down
2 changes: 1 addition & 1 deletion web/libflutter_soloud_plugin.js

Large diffs are not rendered by default.

Binary file modified web/libflutter_soloud_plugin.wasm
Binary file not shown.
Loading