From d1eb44d62b858189d8d9138e6c3a192f1ec77db7 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 16 Sep 2021 19:54:13 +0100 Subject: [PATCH] Move subtitles default to Config --- config.cc | 3 +++ control.h | 3 --- playervideolive.cc | 5 ++++- playervideorec.cc | 5 ++++- vconnect.cc | 2 +- vdr.cc | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/config.cc b/config.cc index f187910..fe8a32f 100644 --- a/config.cc +++ b/config.cc @@ -50,6 +50,9 @@ void Config::applyDefaults() insertBool("input", "mod_lirc_enabled", false); insertInt("server-discovery", "prefer-ipv", 6); + + // Not in config.json.sample - VDR login always sets this + insertInt("subtitles", "default", 0); } bool Config::loadFile() diff --git a/control.h b/control.h index 694d8cd..6bb6cae 100644 --- a/control.h +++ b/control.h @@ -69,8 +69,6 @@ class Control : public MessageQueue void setAdvMenus(bool adv) { advMenus = adv; }; bool isAdvMenus() { return advMenus; }; int getLangPref(bool subtitle,const char* langcode); - void setSubDefault(int subon) { subdefault = subon; }; // NCONFIG - int getSubDefault() { return subdefault; }; ASLPrefList &getASLList() { return langcodes; }; private: @@ -114,7 +112,6 @@ class Control : public MessageQueue bool advMenus{}; ASLPrefList langcodes; - int subdefault; // NCONFIG void processMessage(Message* m); }; diff --git a/playervideolive.cc b/playervideolive.cc index 0ca0025..0667fee 100644 --- a/playervideolive.cc +++ b/playervideolive.cc @@ -25,6 +25,7 @@ #include "defines.h" #include "log.h" +#include "config.h" #include "audio.h" #include "video.h" #include "demuxerts.h" @@ -818,7 +819,9 @@ void PlayerVideoLive::threadMethod() { firstStart = false; - if (control->getSubDefault()) + int subDefault; + Config::getInstance()->getInt("subtitles", "default", subDefault); + if (subDefault) turnSubtitlesOn(true); else turnSubtitlesOn(false); diff --git a/playervideorec.cc b/playervideorec.cc index 046346b..12ace22 100644 --- a/playervideorec.cc +++ b/playervideorec.cc @@ -18,6 +18,7 @@ */ #include "log.h" +#include "config.h" #include "audio.h" #include "video.h" #include "demuxervdr.h" @@ -94,7 +95,9 @@ int PlayerVideoRec::init(bool p_isPesRecording, double framespersecond) video->blank(); audio->stop(); - if (Control::getInstance()->getSubDefault()) + int subDefault; + Config::getInstance()->getInt("subtitles", "default", subDefault); + if (subDefault) turnSubtitlesOn(true); else turnSubtitlesOn(false); diff --git a/vconnect.cc b/vconnect.cc index 593a0c1..d416358 100644 --- a/vconnect.cc +++ b/vconnect.cc @@ -286,7 +286,7 @@ bool VConnect::attemptConnect(const VDRServer* vdrServer) logger->debug(TAG, "VDR login ok"); - Control::getInstance()->setSubDefault(subtitles); + Config::getInstance()->set("subtitles", "default", subtitles); Wol::getInstance()->setWakeUpIP(vdrServer->ip.c_str()); logger->info(TAG, "Send VDR connected message"); diff --git a/vdr.cc b/vdr.cc index d8af43b..2a077a1 100644 --- a/vdr.cc +++ b/vdr.cc @@ -664,7 +664,7 @@ bool VDR::doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsign newpref.audiopref = vresp->extractLONG(); newpref.subtitlepref = vresp->extractLONG(); newpref.langcode = vresp->extractStdString(); - //logger->debug(TAG, "Langpref {} {} {}", newpref.langcode.c_str(), newpref.audiopref, newpref.subtitlepref); + //logger->debug(TAG, "Langpref {} {} {} {}", subtitles, newpref.langcode, newpref.audiopref, newpref.subtitlepref); list.push_back(newpref); } } -- 2.39.5