diff --git a/RetroFE/Source/Execute/Launcher.cpp b/RetroFE/Source/Execute/Launcher.cpp index aa17b73..0404bb8 100755 --- a/RetroFE/Source/Execute/Launcher.cpp +++ b/RetroFE/Source/Execute/Launcher.cpp @@ -47,6 +47,7 @@ bool Launcher::run(std::string collection, Item *collectionItem) std::string matchedExtension; std::string args; bool res = true; + FILE *fp; std::string launcherFile = Utils::combinePath( Configuration::absolutePath, "collections", collectionItem->collectionInfo->name, "launchers", collectionItem->name + ".conf" ); std::ifstream launcherStream( launcherFile.c_str( ) ); @@ -120,7 +121,10 @@ bool Launcher::run(std::string collection, Item *collectionItem) collection); /* Restart audio amp */ - popen(SHELL_CMD_TURN_AMPLI_ON, "r"); + fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r"); + if (fp != NULL) { + pclose(fp); + } /* Execute game */ if(!execute(executablePath, args, currentDirectory)) @@ -130,7 +134,10 @@ bool Launcher::run(std::string collection, Item *collectionItem) } /* Stop audio amp */ - popen(SHELL_CMD_TURN_AMPLI_OFF, "r"); + fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r"); + if (fp != NULL) { + pclose(fp); + } /* Restore stored PID */ char shellCmd[20]; diff --git a/RetroFE/Source/Menu/MenuMode.cpp b/RetroFE/Source/Menu/MenuMode.cpp index 2198f98..1ab3741 100755 --- a/RetroFE/Source/Menu/MenuMode.cpp +++ b/RetroFE/Source/Menu/MenuMode.cpp @@ -399,6 +399,7 @@ void MenuMode::init_menu_system_values(){ volume_percentage = 50; ///wrong value: setting default to 50 } else{ + pclose(fp); fgets(res, sizeof(res)-1, fp); /// Check if Volume is a number (at least the first char) @@ -419,6 +420,7 @@ void MenuMode::init_menu_system_values(){ brightness_percentage = 50; ///wrong value: setting default to 50 } else{ + pclose(fp); fgets(res, sizeof(res)-1, fp); /// Check if brightness is a number (at least the first char) @@ -846,6 +848,8 @@ int MenuMode::launch( ) fp = popen(shell_cmd, "r"); if (fp == NULL) { MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } /// ------ Refresh screen ------ @@ -862,6 +866,8 @@ int MenuMode::launch( ) fp = popen(shell_cmd, "r"); if (fp == NULL) { MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } /// ------ Refresh screen ------ screen_refresh = 1; @@ -907,6 +913,8 @@ int MenuMode::launch( ) fp = popen(shell_cmd, "r"); if (fp == NULL) { MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } /// ------ Refresh screen ------ screen_refresh = 1; @@ -922,6 +930,8 @@ int MenuMode::launch( ) fp = popen(shell_cmd, "r"); if (fp == NULL) { MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } /// ------ Refresh screen ------ screen_refresh = 1; @@ -1001,6 +1011,7 @@ int MenuMode::launch( ) } else{ usb_sharing = !usb_sharing; + pclose(fp); }*/ bool res = Utils::executeRawPath(usb_sharing?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT); @@ -1091,6 +1102,8 @@ int MenuMode::launch( ) fp = popen(shell_cmd, "r"); if (fp == NULL) { MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } return MENU_RETURN_EXIT; diff --git a/RetroFE/Source/Sound/Sound.cpp b/RetroFE/Source/Sound/Sound.cpp index a576a91..d6103c8 100755 --- a/RetroFE/Source/Sound/Sound.cpp +++ b/RetroFE/Source/Sound/Sound.cpp @@ -48,11 +48,16 @@ Sound::~Sound() void Sound::play() { + FILE *fp; + //printf("%s\n", __func__); SDL_RemoveTimer(idTimer); if(!ampliStarted){ - popen(SHELL_CMD_TURN_AMPLI_ON, "r"); - ampliStarted = 1; + fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r"); + if (fp != NULL) { + ampliStarted = 1; + pclose(fp); + } } if(chunk_) @@ -64,9 +69,14 @@ void Sound::play() uint32_t Sound::turnOffAmpli(uint32_t interval, void *param) { + FILE *fp; + //printf("%s\n", __func__); - popen(SHELL_CMD_TURN_AMPLI_OFF, "r"); - ampliStarted = 0; + fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r"); + if (fp != NULL) { + ampliStarted = 0; + pclose(fp); + } return 0; }