From d8b5a787717e73d0844031368c159e87ed8933bb Mon Sep 17 00:00:00 2001 From: GetAway Date: Mon, 1 Jan 2024 20:14:35 +0100 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. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9721c93f576342ef14043b75ecae770abd0f99ee Author: GetAway Date: 2024-01-01 (Mon, 01 Jan 2024) ------------------ This commit was generated by Migit --- src/driver/lcd4l.cpp | 32 +++++++++++--------- src/driver/lcd4l.h | 6 +++- 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, 31 insertions(+), 64 deletions(-) diff --git a/src/driver/lcd4l.cpp b/src/driver/lcd4l.cpp index 9ce86f1f2..d8709327a 100644 --- a/src/driver/lcd4l.cpp +++ b/src/driver/lcd4l.cpp @@ -291,6 +291,7 @@ int CLCD4l::GetMaxBrightness() void CLCD4l::Init() { + m_ActionKey = ""; m_ParseID = 0; m_Brightness = -1; @@ -375,8 +376,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); @@ -737,7 +739,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; @@ -745,7 +747,14 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun) int dummy; int ModeLogo = 0; - if (m_ModeChannel) + int ModeStandby = 0; + + 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; @@ -794,11 +803,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) @@ -971,7 +975,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) { @@ -1091,11 +1100,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 3d5b69c71..d76633512 100644 --- a/src/driver/lcd4l.h +++ b/src/driver/lcd4l.h @@ -58,6 +58,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); @@ -72,7 +74,8 @@ class CLCD4l // use signal/slot handlers // That is helping to keep the GUI code away from code inside ./src/driver. - sigc::signal OnBeforeStart, + sigc::signal + OnBeforeStart, OnAfterStart, OnBeforeStop, OnAfterStop, @@ -104,6 +107,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 9bda8d084..a6df12416 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -934,17 +934,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); @@ -969,17 +961,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); @@ -1007,17 +991,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); @@ -1055,10 +1031,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); @@ -1089,6 +1061,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]; @@ -1159,14 +1135,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"); @@ -1193,8 +1161,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 449ba1914..ab88d12c4 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 f38d7c621..a7cf5c338 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -4612,10 +4612,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 dae5e1213..e67719844 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -524,8 +524,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 2e834637a..22145dbb7 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: