diff --git a/nx/include/switch/services/apm.h b/nx/include/switch/services/apm.h index 3f3fcbd3..b1d44e34 100644 --- a/nx/include/switch/services/apm.h +++ b/nx/include/switch/services/apm.h @@ -21,10 +21,10 @@ typedef enum { ApmCpuBoostMode_Type2 = 2, ///< Use performance configurations 0x9222000B and 0x9222000C. } ApmCpuBoostMode; -/// Initialize apm. Used automatically by \ref appletInitialize. +/// Initialize apm. Used automatically by \ref appletInitialize with AppletType_Application. Result apmInitialize(void); -/// Exit apm. Used automatically by \ref appletExit. +/// Exit apm. Used automatically by \ref appletExit with AppletType_Application. void apmExit(void); /// Gets the Service object for the actual apm service session. diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index 3b312bce..2a275b33 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -118,8 +118,10 @@ Result _appletInitialize(void) { if (__nx_applet_type == AppletType_None) return 0; - if (R_FAILED(apmInitialize())) - return MAKERESULT(Module_Libnx, LibnxError_ApmFailedToInitialize); + if (__nx_applet_type == AppletType_Default || __nx_applet_type == AppletType_Application) { + if (R_FAILED(apmInitialize())) + return MAKERESULT(Module_Libnx, LibnxError_ApmFailedToInitialize); + } Result rc = 0; @@ -422,8 +424,6 @@ void _appletCleanup(void) { serviceClose(&g_appletSrv); g_appletResourceUserId = 0; - apmExit(); - if (g_appletRecordingInitialized > 0) { tmemClose(&g_appletRecordingTmem); g_appletRecordingInitialized = 0; @@ -433,6 +433,8 @@ void _appletCleanup(void) { tmemClose(&g_appletCopyrightTmem); g_appletCopyrightInitialized = 0; } + + if (_appletIsRegularApplication()) apmExit(); } Service* appletGetServiceSession_Proxy(void) {