diff --git a/sphaira/CMakeLists.txt b/sphaira/CMakeLists.txt index 266c59c..dc7dc4a 100644 --- a/sphaira/CMakeLists.txt +++ b/sphaira/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.13) -set(sphaira_VERSION 0.6.1) +set(sphaira_VERSION 0.6.2) project(sphaira VERSION ${sphaira_VERSION} diff --git a/sphaira/include/app.hpp b/sphaira/include/app.hpp index 8a9ce3e..18b70e7 100644 --- a/sphaira/include/app.hpp +++ b/sphaira/include/app.hpp @@ -119,6 +119,21 @@ public: return type == AppletType_Application || type == AppletType_SystemApplication; } + static auto IsApplet() -> bool { + return !IsApplication(); + } + + // returns true if launched in applet mode with a title suspended in the background. + static auto IsAppletWithSuspendedApp() -> bool { + R_UNLESS(IsApplet(), false); + R_TRY_RESULT(pmdmntInitialize(), false); + ON_SCOPE_EXIT(pmdmntExit()); + + u64 pid; + return R_SUCCEEDED(pmdmntGetApplicationProcessId(&pid)); + } + + // private: static constexpr inline auto CONFIG_PATH = "/config/sphaira/config.ini"; static constexpr inline auto PLAYLOG_PATH = "/config/sphaira/playlog.ini"; diff --git a/sphaira/source/app.cpp b/sphaira/source/app.cpp index d63845b..33e5732 100644 --- a/sphaira/source/app.cpp +++ b/sphaira/source/app.cpp @@ -1282,9 +1282,11 @@ App::App(const char* argv0) { } } - // only enable audio in non-applet mode due to audren fatal. + // disable audio in applet mode with a suspended application due to audren fatal. // see: https://github.com/ITotalJustice/sphaira/issues/92 - if (IsApplication()) { + if (IsAppletWithSuspendedApp()) { + App::Notify("Audio disabled due to suspended game"_i18n); + } else { plsrPlayerInit(); }