Advertisement
svenhoefer

Untitled

Nov 20th, 2017
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.13 KB | None | 0 0
  1. diff --git a/src/neutrino.cpp b/src/neutrino.cpp
  2. index e1a7a26..455159c 100644
  3. --- a/src/neutrino.cpp
  4. +++ b/src/neutrino.cpp
  5. @@ -139,6 +139,11 @@
  6.  #include <linux/reboot.h>
  7.  #include <sys/reboot.h>
  8.  
  9. +#ifdef __sh__
  10. +/* the sh4 gcc seems to dislike someting about openthreads... */
  11. +#define exit _exit
  12. +#endif
  13. +
  14.  #include <compatibility.h>
  15.  
  16.  #include <lib/libdvbsub/dvbsub.h>
  17. @@ -2071,7 +2076,7 @@ void CNeutrinoApp::CmdParser(int argc, char **argv)
  18.         else {
  19.             dprintf(DEBUG_NORMAL, "Usage: neutrino [-u | --enable-update] "
  20.                           "[-v | --verbose 0..3]\n");
  21. -           exit(1);
  22. +           exit(CNeutrinoApp::EXIT_ERROR);
  23.         }
  24.     }
  25.  }
  26. @@ -2089,7 +2094,7 @@ void CNeutrinoApp::SetupFrameBuffer()
  27.     frameBuffer->setOsdResolutions();
  28.     if (frameBuffer->osd_resolutions.empty()) {
  29.         dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n");
  30. -       exit(-1);
  31. +       exit(CNeutrinoApp::EXIT_ERROR);
  32.     }
  33.  
  34.     uint32_t ort;
  35. @@ -2119,7 +2124,7 @@ void CNeutrinoApp::SetupFrameBuffer()
  36.  
  37.     if (setFbMode == -1) {
  38.         dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n");
  39. -       exit(-1);
  40. +       exit(CNeutrinoApp::EXIT_ERROR);
  41.     }
  42.     frameBuffer->Clear();
  43.     frameBufferInitialized = true;
  44. @@ -2664,8 +2669,8 @@ TIMER_STOP("################################## after all #######################
  45.  #endif
  46.         CFlashUpdateCheck::getInstance()->startThread();
  47.     }
  48. -   RealRun();
  49.  
  50. +   RealRun();
  51.     ExitRun(g_info.hw_caps->can_shutdown);
  52.  
  53.     return 0;
  54. @@ -3857,9 +3862,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
  55.         return messages_return::handled;
  56.     }
  57.     else if( msg == NeutrinoMessages::REBOOT ) {
  58. -       FILE *f = fopen("/tmp/.reboot", "w");
  59. -       fclose(f);
  60. -       ExitRun();
  61. +       ExitRun(CNeutrinoApp::EXIT_REBOOT);
  62.     }
  63.     else if (msg == NeutrinoMessages::EVT_POPUP || msg == NeutrinoMessages::EVT_EXTMSG) {
  64.         if (mode != NeutrinoModes::mode_scart && mode != NeutrinoModes::mode_standby) {
  65. @@ -4025,22 +4028,30 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
  66.  extern time_t timer_minutes;//timermanager.cpp
  67.  extern bool timer_is_rec;//timermanager.cpp
  68.  
  69. -void CNeutrinoApp::ExitRun(int can_shutdown)
  70. +void CNeutrinoApp::ExitRun(int exit_code)
  71.  {
  72. -   /* can_shutdown is actually our exit code */
  73. -   printf("[neutrino] %s can_shutdown: %d\n", __func__, can_shutdown);
  74. +   printf("[neutrino] %s(int %d)\n", __func__, exit_code);
  75. +   printf("[neutrino] hw_caps->can_shutdown: %d\n", __func__, g_info.hw_caps->can_shutdown);
  76.  
  77. -   bool do_shutdown = true;
  78. +   bool do_exiting = true;
  79.     CRecordManager::getInstance()->StopAutoRecord();
  80.     if(CRecordManager::getInstance()->RecordingStatus() || cYTCache::getInstance()->isActive())
  81.     {
  82. -       do_shutdown =
  83. -           (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECORDING_QUERY, CMsgBox::mbrNo,
  84. +       do_exiting = (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECORDING_QUERY, CMsgBox::mbrNo,
  85.                     CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, DEFAULT_TIMEOUT, true) == CMsgBox::mbrYes);
  86.     }
  87. -   if (!do_shutdown)
  88. +   if (!do_exiting)
  89.         return;
  90.  
  91. +   // for compatibility; /tmp/.reboot is not really needed anymore
  92. +   if (exit_code == CNeutrinoApp::EXIT_REBOOT)
  93. +   {
  94. +       FILE *f = fopen("/tmp/.reboot", "w");
  95. +       fclose(f);
  96. +   }
  97. +   else
  98. +       unlink("/tmp/.reboot");
  99. +
  100.     stop_lcd4l_support(); //NI lcd4l-support
  101.  
  102.     //NI InfoIcons
  103. @@ -4068,7 +4079,7 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
  104.     }
  105.  
  106.     /* on shutdown force load new fst */
  107. -   if (can_shutdown)
  108. +   if (exit_code == CNeutrinoApp::EXIT_SHUTDOWN)
  109.         CheckFastScan(true, false);
  110.  
  111.     CVFD::getInstance()->setMode(CVFD::MODE_SHUTDOWN);
  112. @@ -4088,9 +4099,11 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
  113.     int leds = 0;
  114.     int bright = 0;
  115.  #if HAVE_COOL_HARDWARE
  116. -   if (can_shutdown) {
  117. +   if (exit_code == CNeutrinoApp::EXIT_SHUTDOWN)
  118. +   {
  119.         leds = 0x40;
  120. -       switch (g_settings.led_deep_mode){
  121. +       switch (g_settings.led_deep_mode)
  122. +       {
  123.             case 0:
  124.                 leds = 0x0; // leds off
  125.                 break;
  126. @@ -4158,14 +4171,10 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
  127.     delete SHTDCNT::getInstance();
  128.     stop_video();
  129.  
  130. -   printf("[neutrino] This is the end. exiting with code %d\n", can_shutdown);
  131.     Cleanup();
  132. -#ifdef __sh__
  133. -   /* the sh4 gcc seems to dislike someting about openthreads... */
  134. -   _exit(can_shutdown);
  135. -#else
  136. -   exit(can_shutdown);
  137. -#endif
  138. +
  139. +   printf("[neutrino] This is the end. Exiting with code %d\n", exit_code);
  140. +   exit(exit_code);
  141.  }
  142.  
  143.  void CNeutrinoApp::saveEpg(int _mode)
  144. @@ -4585,8 +4594,9 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
  145.     if(actionKey == "help_recording") {
  146.         ShowMsg(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMsgBox::mbrBack, CMsgBox::mbBack);
  147.     }
  148. -   else if(actionKey=="shutdown") {
  149. -       ExitRun(1);
  150. +   else if(actionKey=="shutdown")
  151. +   {
  152. +       ExitRun(g_info.hw_caps->can_shutdown);
  153.     }
  154.     else if(actionKey=="need_reboot")
  155.     {
  156. @@ -4596,10 +4606,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
  157.     }
  158.     else if(actionKey=="reboot")
  159.     {
  160. -       FILE *f = fopen("/tmp/.reboot", "w");
  161. -       fclose(f);
  162. -       ExitRun();
  163. -       unlink("/tmp/.reboot");
  164. +       ExitRun(CNeutrinoApp::EXIT_REBOOT);
  165.         returnval = menu_return::RETURN_NONE;
  166.     }
  167.     else if (actionKey=="clock_switch")
  168. @@ -4775,7 +4782,8 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
  169.             for(int i = 3; i < 256; i++)
  170.                 close(i);
  171.             execvp(global_argv[0], global_argv); // no return if successful
  172. -           exit(1);
  173. +
  174. +           exit(CNeutrinoApp::EXIT_REBOOT); // should never be reached
  175.         }
  176.     }
  177.     else if(actionKey == "moviedir") {
  178. @@ -4950,11 +4958,7 @@ void sighandler (int signum)
  179.         delete CVFD::getInstance();
  180.         delete SHTDCNT::getInstance();
  181.         stop_video();
  182. -#ifdef __sh__
  183. -       _exit(0);
  184. -#else
  185. -       exit(0);
  186. -#endif
  187. +       exit(CNeutrinoApp::EXIT_NORMAL);
  188.     default:
  189.         break;
  190.     }
  191. diff --git a/src/neutrino.h b/src/neutrino.h
  192. index 45399ab..7aa1a6d 100644
  193. --- a/src/neutrino.h
  194. +++ b/src/neutrino.h
  195. @@ -68,7 +68,13 @@ public:
  196.         RECORDING_FILE   = 3
  197.     };
  198.    
  199. -  
  200. +   enum // exit codes
  201. +   {
  202. +       EXIT_ERROR = -1,
  203. +       EXIT_NORMAL = 0,
  204. +       EXIT_SHUTDOWN = 1,
  205. +       EXIT_REBOOT = 2
  206. +   };
  207.  
  208.  private:
  209.     CFrameBuffer * frameBuffer;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement