Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/neutrino.cpp b/src/neutrino.cpp
- index e1a7a26..455159c 100644
- --- a/src/neutrino.cpp
- +++ b/src/neutrino.cpp
- @@ -139,6 +139,11 @@
- #include <linux/reboot.h>
- #include <sys/reboot.h>
- +#ifdef __sh__
- +/* the sh4 gcc seems to dislike someting about openthreads... */
- +#define exit _exit
- +#endif
- +
- #include <compatibility.h>
- #include <lib/libdvbsub/dvbsub.h>
- @@ -2071,7 +2076,7 @@ void CNeutrinoApp::CmdParser(int argc, char **argv)
- else {
- dprintf(DEBUG_NORMAL, "Usage: neutrino [-u | --enable-update] "
- "[-v | --verbose 0..3]\n");
- - exit(1);
- + exit(CNeutrinoApp::EXIT_ERROR);
- }
- }
- }
- @@ -2089,7 +2094,7 @@ void CNeutrinoApp::SetupFrameBuffer()
- frameBuffer->setOsdResolutions();
- if (frameBuffer->osd_resolutions.empty()) {
- dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n");
- - exit(-1);
- + exit(CNeutrinoApp::EXIT_ERROR);
- }
- uint32_t ort;
- @@ -2119,7 +2124,7 @@ void CNeutrinoApp::SetupFrameBuffer()
- if (setFbMode == -1) {
- dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n");
- - exit(-1);
- + exit(CNeutrinoApp::EXIT_ERROR);
- }
- frameBuffer->Clear();
- frameBufferInitialized = true;
- @@ -2664,8 +2669,8 @@ TIMER_STOP("################################## after all #######################
- #endif
- CFlashUpdateCheck::getInstance()->startThread();
- }
- - RealRun();
- + RealRun();
- ExitRun(g_info.hw_caps->can_shutdown);
- return 0;
- @@ -3857,9 +3862,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
- return messages_return::handled;
- }
- else if( msg == NeutrinoMessages::REBOOT ) {
- - FILE *f = fopen("/tmp/.reboot", "w");
- - fclose(f);
- - ExitRun();
- + ExitRun(CNeutrinoApp::EXIT_REBOOT);
- }
- else if (msg == NeutrinoMessages::EVT_POPUP || msg == NeutrinoMessages::EVT_EXTMSG) {
- if (mode != NeutrinoModes::mode_scart && mode != NeutrinoModes::mode_standby) {
- @@ -4025,22 +4028,30 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
- extern time_t timer_minutes;//timermanager.cpp
- extern bool timer_is_rec;//timermanager.cpp
- -void CNeutrinoApp::ExitRun(int can_shutdown)
- +void CNeutrinoApp::ExitRun(int exit_code)
- {
- - /* can_shutdown is actually our exit code */
- - printf("[neutrino] %s can_shutdown: %d\n", __func__, can_shutdown);
- + printf("[neutrino] %s(int %d)\n", __func__, exit_code);
- + printf("[neutrino] hw_caps->can_shutdown: %d\n", __func__, g_info.hw_caps->can_shutdown);
- - bool do_shutdown = true;
- + bool do_exiting = true;
- CRecordManager::getInstance()->StopAutoRecord();
- if(CRecordManager::getInstance()->RecordingStatus() || cYTCache::getInstance()->isActive())
- {
- - do_shutdown =
- - (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECORDING_QUERY, CMsgBox::mbrNo,
- + do_exiting = (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECORDING_QUERY, CMsgBox::mbrNo,
- CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, DEFAULT_TIMEOUT, true) == CMsgBox::mbrYes);
- }
- - if (!do_shutdown)
- + if (!do_exiting)
- return;
- + // for compatibility; /tmp/.reboot is not really needed anymore
- + if (exit_code == CNeutrinoApp::EXIT_REBOOT)
- + {
- + FILE *f = fopen("/tmp/.reboot", "w");
- + fclose(f);
- + }
- + else
- + unlink("/tmp/.reboot");
- +
- stop_lcd4l_support(); //NI lcd4l-support
- //NI InfoIcons
- @@ -4068,7 +4079,7 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
- }
- /* on shutdown force load new fst */
- - if (can_shutdown)
- + if (exit_code == CNeutrinoApp::EXIT_SHUTDOWN)
- CheckFastScan(true, false);
- CVFD::getInstance()->setMode(CVFD::MODE_SHUTDOWN);
- @@ -4088,9 +4099,11 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
- int leds = 0;
- int bright = 0;
- #if HAVE_COOL_HARDWARE
- - if (can_shutdown) {
- + if (exit_code == CNeutrinoApp::EXIT_SHUTDOWN)
- + {
- leds = 0x40;
- - switch (g_settings.led_deep_mode){
- + switch (g_settings.led_deep_mode)
- + {
- case 0:
- leds = 0x0; // leds off
- break;
- @@ -4158,14 +4171,10 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
- delete SHTDCNT::getInstance();
- stop_video();
- - printf("[neutrino] This is the end. exiting with code %d\n", can_shutdown);
- Cleanup();
- -#ifdef __sh__
- - /* the sh4 gcc seems to dislike someting about openthreads... */
- - _exit(can_shutdown);
- -#else
- - exit(can_shutdown);
- -#endif
- +
- + printf("[neutrino] This is the end. Exiting with code %d\n", exit_code);
- + exit(exit_code);
- }
- void CNeutrinoApp::saveEpg(int _mode)
- @@ -4585,8 +4594,9 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
- if(actionKey == "help_recording") {
- ShowMsg(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMsgBox::mbrBack, CMsgBox::mbBack);
- }
- - else if(actionKey=="shutdown") {
- - ExitRun(1);
- + else if(actionKey=="shutdown")
- + {
- + ExitRun(g_info.hw_caps->can_shutdown);
- }
- else if(actionKey=="need_reboot")
- {
- @@ -4596,10 +4606,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
- }
- else if(actionKey=="reboot")
- {
- - FILE *f = fopen("/tmp/.reboot", "w");
- - fclose(f);
- - ExitRun();
- - unlink("/tmp/.reboot");
- + ExitRun(CNeutrinoApp::EXIT_REBOOT);
- returnval = menu_return::RETURN_NONE;
- }
- else if (actionKey=="clock_switch")
- @@ -4775,7 +4782,8 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
- for(int i = 3; i < 256; i++)
- close(i);
- execvp(global_argv[0], global_argv); // no return if successful
- - exit(1);
- +
- + exit(CNeutrinoApp::EXIT_REBOOT); // should never be reached
- }
- }
- else if(actionKey == "moviedir") {
- @@ -4950,11 +4958,7 @@ void sighandler (int signum)
- delete CVFD::getInstance();
- delete SHTDCNT::getInstance();
- stop_video();
- -#ifdef __sh__
- - _exit(0);
- -#else
- - exit(0);
- -#endif
- + exit(CNeutrinoApp::EXIT_NORMAL);
- default:
- break;
- }
- diff --git a/src/neutrino.h b/src/neutrino.h
- index 45399ab..7aa1a6d 100644
- --- a/src/neutrino.h
- +++ b/src/neutrino.h
- @@ -68,7 +68,13 @@ public:
- RECORDING_FILE = 3
- };
- -
- + enum // exit codes
- + {
- + EXIT_ERROR = -1,
- + EXIT_NORMAL = 0,
- + EXIT_SHUTDOWN = 1,
- + EXIT_REBOOT = 2
- + };
- private:
- CFrameBuffer * frameBuffer;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement