From 3e6d45b65a69e440c186f58a153039c52e12bb0a Mon Sep 17 00:00:00 2001 From: GetAway Date: Thu, 14 Sep 2023 18:53:26 +0200 Subject: [PATCH] Fix set lastmode; introduce sending an actionKey for LCD4linux We have a problem since the introduction of moviebrowser_mode. Lastmode is no longer reset correctly, because the new mode is overlaid by another mode and thus the original mode cannot be restored. Neutrino becomes unusable and has to be restarted. (Example below) Generally the opening of a window, like the MB or Channellist is also no Neutrino_mode in the sense as it was invented once. It is just a window and not a mode that Neutrino is in. Example: Neutrino is in TV_MODUS and you open the MB. You can see, Neutrino is still in TV_MODUS. I reverted the code and now an open window can say for example to the lcd4linux 'hello i'm open, here is mb'. When running a window we send some kind of AktionKey. After the actions in the window, the AktionKey is cleared. Now to the current bug: 1. boot on a TV channel. 2. switch to a WebTV channel. (in my case PlutoTV Star Trek) 3. play a TS over the Moviebrowser and stop it. (MODE_WEBTV is detected and the WebTV stream is restarted) 4. call the MB a second time and start and stop the TS. 5. the WebTV stream does not restart anymore. 6. exit the MB now. 7. neutrino becomes not operable. --- src/driver/lcd4l.cpp | 30 ++++++++++--------- src/driver/lcd4l.h | 16 ++++++---- src/gui/moviebrowser/mb.cpp | 46 +++++------------------------ src/gui/moviebrowser/mb.h | 2 -- src/neutrino.cpp | 4 --- src/neutrinoMessages.h | 1 - src/nhttpd/tuxboxapi/controlapi.cpp | 2 -- src/system/helpers.cpp | 2 -- 8 files changed, 34 insertions(+), 69 deletions(-) diff --git a/src/driver/lcd4l.cpp b/src/driver/lcd4l.cpp index b59f5d0f6..7616fe514 100644 --- a/src/driver/lcd4l.cpp +++ b/src/driver/lcd4l.cpp @@ -294,6 +294,7 @@ int CLCD4l::GetMaxBrightness() void CLCD4l::Init() { + m_ActionKey = ""; m_ParseID = 0; m_Brightness = -1; @@ -378,8 +379,9 @@ void *CLCD4l::LCD4lProc(void *arg) { usleep(5 * 100 * 1000); // 0.5 sec new_ParseID = PLCD4l->CompareParseID(p_ParseID); - if (new_ParseID || p_ParseID == NeutrinoModes::mode_audio || p_ParseID == NeutrinoModes::mode_moviebrowser) + if (new_ParseID || p_ParseID == NeutrinoModes::mode_audio || !PLCD4l->m_ActionKey.empty()) { break; + } } //printf("[CLCD4l] %s: m_ParseID: %llx (new_ParseID: %d)\n", __FUNCTION__, p_ParseID, new_ParseID ? 1 : 0); @@ -739,7 +741,7 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun) /* ----------------------------------------------------------------- */ - if (firstRun || newID || parseID == NeutrinoModes::mode_audio || parseID == NeutrinoModes::mode_ts) + if (firstRun || newID || parseID == NeutrinoModes::mode_audio || parseID == NeutrinoModes::mode_ts || !m_ActionKey.empty()) { std::string Service = ""; int ChannelNr = 0; @@ -749,7 +751,12 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun) int ModeStandby = 0; - if (m_ModeChannel) + if (m_ActionKey == "moviebrowser") + { + g_PicViewer->GetLogoName(0, "Moviebrowser", Logo, &dummy, &dummy, CPictureViewer::LCD4LINUX, true); + Service = g_Locale->getText(LOCALE_MOVIEBROWSER_HEAD); + } + else if (m_ModeChannel) { if (m_ModeChannel > 1) Service = g_RemoteControl->subChannels[g_RemoteControl->selected_subchannel].subservice_name; @@ -798,11 +805,6 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun) Logo = ICONSDIR "/" NEUTRINO_ICON_PLAY ICONSEXT; Service = g_Locale->getText(LOCALE_MAINMENU_AVINPUTMODE); } - else if (parseID == NeutrinoModes::mode_moviebrowser) - { - g_PicViewer->GetLogoName(0, "Moviebrowser", Logo, &dummy, &dummy, CPictureViewer::LCD4LINUX, true); - Service = g_Locale->getText(LOCALE_MOVIEBROWSER_HEAD); - } else if (parseID == NeutrinoModes::mode_ts) { if (ModeTshift) @@ -979,7 +981,12 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun) bool writeEvent = true; - if (m_ModeChannel) + if (!m_ActionKey.empty()) + { + // do nothing; Event is processed in moviebrowser or other windows + writeEvent = false; + } + else if (m_ModeChannel) { if (CNeutrinoApp::getInstance()->getMode() == NeutrinoModes::mode_webtv || CNeutrinoApp::getInstance()->getMode() == NeutrinoModes::mode_webradio) { @@ -1099,11 +1106,6 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun) // TODO: Event = Bildname } #endif - else if (parseID == NeutrinoModes::mode_moviebrowser) - { - // do nothing; Event is processed in moviebrowser - writeEvent = false; - } else if (parseID == NeutrinoModes::mode_ts) { if (CMoviePlayerGui::getInstance().p_movie_info) diff --git a/src/driver/lcd4l.h b/src/driver/lcd4l.h index 524138341..2cab49b3e 100644 --- a/src/driver/lcd4l.h +++ b/src/driver/lcd4l.h @@ -62,6 +62,8 @@ class CLCD4l void SwitchLCD4l(); void RestartLCD4lScript(); void ForceRun() { wait4daemon = false; } + void setActionKey(const std::string ActionKey) { m_ActionKey = ActionKey; } + void clearActionKey(void) { m_ActionKey.clear(); } int CreateFile(const char *file, std::string content = "", bool convert = false); int RemoveFile(const char *file); @@ -84,12 +86,13 @@ class CLCD4l // use signal/slot handlers // That is helping to keep the GUI code away from code inside ./src/driver. - sigc::signal OnBeforeStart, - OnAfterStart, - OnBeforeStop, - OnAfterStop, - OnBeforeRestart, - OnAfterRestart, + sigc::signal + OnBeforeStart, + OnAfterStart, + OnBeforeStop, + OnAfterStop, + OnBeforeRestart, + OnAfterRestart, OnError; private: @@ -116,6 +119,7 @@ class CLCD4l bool GetWaitStatus() { return wait4daemon; } // Variables + std::string m_ActionKey; uint64_t m_ParseID; int m_Mode; int m_ModeChannel; diff --git a/src/gui/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index 3a08e5729..0e97ca913 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -928,17 +928,9 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) framebuffer->paintBackground(); // clear screen - // restore last mode to allow tv/radio while copying - CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, m_LastMode); - - // TODO: signalize running action CMovieCut mc; bool res = mc.copyMovie(m_movieSelectionHandler, onefile); - // tell neutrino we're in moviebrowser mode again - m_LastMode = CNeutrinoApp::getInstance()->getMode(); - CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, NeutrinoModes::mode_moviebrowser | NeutrinoModes::norezap); - //g_RCInput->clearRCMsg(); if (res == 0) ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_COPY_FAILED, CMsgBox::mbrCancel, CMsgBox::mbCancel, NEUTRINO_ICON_ERROR); @@ -963,17 +955,9 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) framebuffer->paintBackground(); // clear screen - // restore last mode to allow tv/radio while cutting - CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, m_LastMode); - - // TODO: signalize running action CMovieCut mc; bool res = mc.cutMovie(m_movieSelectionHandler); - // tell neutrino we're in moviebrowser mode again - m_LastMode = CNeutrinoApp::getInstance()->getMode(); - CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, NeutrinoModes::mode_moviebrowser | NeutrinoModes::norezap); - //g_RCInput->clearRCMsg(); if (!res) ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_CUT_FAILED, CMsgBox::mbrCancel, CMsgBox::mbCancel, NEUTRINO_ICON_ERROR); @@ -1001,17 +985,9 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) framebuffer->paintBackground(); // clear screen - // restore last mode to allow tv/radio while truncating - CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, m_LastMode); - - // TODO: signalize running action CMovieCut mc; bool res = mc.truncateMovie(m_movieSelectionHandler); - // tell neutrino we're in moviebrowser mode again - m_LastMode = CNeutrinoApp::getInstance()->getMode(); - CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, NeutrinoModes::mode_moviebrowser | NeutrinoModes::norezap); - //g_RCInput->clearRCMsg(); if (!res) ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_TRUNCATE_FAILED, CMsgBox::mbrCancel, CMsgBox::mbCancel, NEUTRINO_ICON_ERROR); @@ -1049,10 +1025,6 @@ int CMovieBrowser::exec(const char* path) neutrino_msg_t msg; neutrino_msg_data_t data; - // tell neutrino we're in moviebrowser mode - m_LastMode = CNeutrinoApp::getInstance()->getMode(); - CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, NeutrinoModes::mode_moviebrowser | NeutrinoModes::norezap); - CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, g_Locale->getText(LOCALE_MOVIEBROWSER_HEAD)); loadSettings(&m_settings); @@ -1083,6 +1055,10 @@ int CMovieBrowser::exec(const char* path) if (paint() == false) return menu_ret;// paint failed due to less memory, exit +#ifdef ENABLE_LCD4LINUX + if (g_settings.lcd4l_support) + CLCD4l::getInstance()->setActionKey("moviebrowser"); +#endif bool loop = true; bool result; int timeout = g_settings.timing[SNeutrinoSettings::TIMING_FILEBROWSER]; @@ -1153,14 +1129,6 @@ int CMovieBrowser::exec(const char* path) loop = false; g_RCInput->postMsg(msg, data); } - else if (msg == NeutrinoMessages::CHANGEMODE) - { - if ((data & NeutrinoModes::mode_mask) != NeutrinoModes::mode_moviebrowser) - { - loop = false; - m_LastMode = data; - } - } else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all) { TRACE("[mb]->exec: getInstance\n"); @@ -1187,8 +1155,10 @@ int CMovieBrowser::exec(const char* path) TRACE("[mb] force reload next time\n"); fileInfoStale(); } - - CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, m_LastMode | NeutrinoModes::norezap); +#ifdef ENABLE_LCD4LINUX + if (g_settings.lcd4l_support) + CLCD4l::getInstance()->clearActionKey(); +#endif return (res); } diff --git a/src/gui/moviebrowser/mb.h b/src/gui/moviebrowser/mb.h index 9877c201b..6ea546a9e 100644 --- a/src/gui/moviebrowser/mb.h +++ b/src/gui/moviebrowser/mb.h @@ -195,8 +195,6 @@ class CMovieBrowser : public CMenuTarget, public CProgressSignals Font* m_pcFontTitle; std::string m_textTitle; - int m_LastMode; - MB_PARENTAL_LOCK m_parentalLock; MB_STORAGE_TYPE m_storageType; diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 7515ea17a..e93be239e 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -4607,10 +4607,6 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) lastMode=mode; mode=NeutrinoModes::mode_pic; } - if((data & NeutrinoModes::mode_mask)== NeutrinoModes::mode_moviebrowser) { - lastMode=mode; - mode=NeutrinoModes::mode_moviebrowser; - } if((data & NeutrinoModes::mode_mask)== NeutrinoModes::mode_ts) { if(mode == NeutrinoModes::mode_radio) frameBuffer->stopFrame(); diff --git a/src/neutrinoMessages.h b/src/neutrinoMessages.h index ac1701baf..00526d4ce 100644 --- a/src/neutrinoMessages.h +++ b/src/neutrinoMessages.h @@ -197,7 +197,6 @@ struct NeutrinoModes mode_webtv = 9, mode_upnp = 10, mode_webradio = 11, - mode_moviebrowser = 12, mode_mask = 0xFF, norezap = 0x100 }; diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index 58eba3c50..979d1a9f1 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -515,8 +515,6 @@ void CControlAPI::GetModeCGI(CyhookHandler *hh) result = "upnp"; else if (mode == NeutrinoModes::mode_webradio) result = "webradio"; - else if (mode == NeutrinoModes::mode_moviebrowser) - result = "moviebrowser"; else result = "unknown"; } diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index cd05bb502..17f7fcf93 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -105,8 +105,6 @@ const char* neutrinoMode_to_string(int mode) return "MODE_UPNP"; case NeutrinoModes::mode_webradio: return "MODE_WEBRADIO"; - case NeutrinoModes::mode_moviebrowser: - return "MODE_MOVIEBROWSER"; case (int)NeutrinoModes::mode_mask: return "MODE_MASK"; case (int)NeutrinoModes::norezap: