Only init/exit apm from applet with AppletType_Application. Closes #360.

This commit is contained in:
yellows8 2019-12-23 10:45:39 -05:00
parent f043307e7f
commit 1bb1aef2f7
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
2 changed files with 8 additions and 6 deletions

View File

@ -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.

View File

@ -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) {