From 60e2a5a1b6cb229460038cc9534b237e38e9b5ed Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 2 Mar 2013 15:47:00 +0000 Subject: [PATCH] Shutdown VDR patch from Yaris --- command.cc | 23 +++++++++++++++++++++++ vdr.cc | 22 +++++++++++++++++++++- vdr.h | 4 ++++ vdrcommand.h | 1 + vopts.cc | 26 +++++++++++++++++++++++--- 5 files changed, 72 insertions(+), 4 deletions(-) diff --git a/command.cc b/command.cc index 789fb7e..881b020 100644 --- a/command.cc +++ b/command.cc @@ -540,6 +540,7 @@ void Command::doStandby() } else { + VDR::getInstance()->shutdownVDR(); boxstack->removeAll(); Video::getInstance()->signalOff(); boxstack->update(wallpaper); @@ -870,6 +871,28 @@ void Command::doJustConnected(VConnect* vconnect) logger->log("Command", Log::INFO, "Config TV/S-Video not found"); } + // Set to shutdown VDR if config says + + config = vdr->configLoad("General", "VDR shutdown"); + if (config) + { + if (!STRCASECMP(config, "On")) + { + logger->log("Command", Log::INFO, "Shutdown VDR when shutting down vomp"); + vdr->setVDRShutdown(true); + } + else if (!STRCASECMP(config, "Off")) + { + logger->log("Command", Log::INFO, "Shutdown only vomp"); + vdr->setVDRShutdown(false); + } + } + else + { + logger->log("Command", Log::INFO, "Default shutdown only vomp"); + vdr->setVDRShutdown(false); // Default + } + // Set remote type config = vdr->configLoad("General", "Remote type"); diff --git a/vdr.cc b/vdr.cc index 6ebf766..bb2d4d3 100644 --- a/vdr.cc +++ b/vdr.cc @@ -38,7 +38,7 @@ #include "video.h" #include "osd.h" -#define VOMP_PROTOCOLL_VERSION 0x00000200 +#define VOMP_PROTOCOLL_VERSION 0x00000301 VDR* VDR::instance = NULL; //prepare a request @@ -117,6 +117,7 @@ VDR::VDR() connected = false; maxChannelNumber = 0; channelNumberWidth = 1; + doVDRShutdown = false; TEMP_SINGLE_VDR_PR = NULL; providerId=MPROVIDERID_VDR; subRange=MPROVIDERRANGE_VDR; @@ -1546,3 +1547,22 @@ int VDR::getLanguageContent(const std::string code, I18n::trans_table& texts) delete vresp; return 1; } + +void VDR::shutdownVDR() +{ + if(doVDRShutdown) + logger->log("VDR", Log::DEBUG, "Shutting down vdr"); + else + logger->log("VDR", Log::DEBUG, "Shutting down vomp only"); + + if(!doVDRShutdown || !connected) + return; + + VDR_RequestPacket vrp; + logger->log("VDR", Log::DEBUG, "Sending shutdown"); + if (!vrp.init(VDR_SHUTDOWN, false, 0)) return; + VDR_ResponsePacket* vresp = RequestResponse(&vrp); + delete vresp; + + logger->log("VDR", Log::DEBUG, "VDR shutdown"); +} diff --git a/vdr.h b/vdr.h index 19e4afa..c406115 100644 --- a/vdr.h +++ b/vdr.h @@ -137,6 +137,9 @@ class VDR : public Thread_TYPE, public EventDispatcher, public MediaProvider, pu bool isConnected() { return connected; } ULONG getChannelNumberWidth() { return channelNumberWidth; } + void setVDRShutdown(bool doShutdown) { doVDRShutdown = doShutdown; } + void shutdownVDR(); + // protocol functions // for the following, if result == false then the connection has died // doLogin @@ -226,6 +229,7 @@ class VDR : public Thread_TYPE, public EventDispatcher, public MediaProvider, pu USHORT serverPort; bool connected; ULONG maxChannelNumber; + bool doVDRShutdown; ULONG channelNumberWidth; VDR_PacketReceiver* TEMP_SINGLE_VDR_PR; diff --git a/vdrcommand.h b/vdrcommand.h index 7f8d450..33b9352 100644 --- a/vdrcommand.h +++ b/vdrcommand.h @@ -69,6 +69,7 @@ const static ULONG VDR_OPENMEDIA = 31; const static ULONG VDR_GETMEDIABLOCK = 32; const static ULONG VDR_GETMEDIAINFO = 35; const static ULONG VDR_CLOSECHANNEL = 36; +const static ULONG VDR_SHUTDOWN = 666; class VDR_Command : public SerializableList { public: diff --git a/vopts.cc b/vopts.cc index 0604e71..0893b7b 100644 --- a/vopts.cc +++ b/vopts.cc @@ -71,6 +71,7 @@ VOpts::VOpts() static const char* options13[] = {"Auto","1024", "2048", "4096", "8192", "16384", "32768", "65536"}; static const char* options14[] = {"No", "Yes"}; + static const char* options18[] = {"Off", "On"}; // Get list of languages from VDR and construct options table LangCode = VDR::getInstance()->getLanguageList(); options2 = new const char*[LangCode.size()]; @@ -188,6 +189,9 @@ VOpts::VOpts() option = new Option(15, "Recordings sort order", "General", "Recordings Sort Order", Option::TYPE_TEXT, 2, 0, 0, options15); options.push_back(option); wop->addOptionLine(option); + option = new Option(18, "Automatic VDR shutdown", "General", "VDR shutdown", Option::TYPE_TEXT, 2, 0, 0, options18); + options.push_back(option); + wop->addOptionLine(option); Remote::getInstance()->addOptionsToPanes(0,&options,wop); Video::getInstance()->addOptionsToPanes(0,&options,wop); @@ -441,9 +445,25 @@ void VOpts::doSave() VDR::getInstance()->setReceiveWindow(newTCPsize); break; } - case 17: { - Osd::getInstance()->setFont(options[i]->optionkeys[options[i]->userSetChoice]); - } break; + case 17: + { + Osd::getInstance()->setFont(options[i]->optionkeys[options[i]->userSetChoice]); + break; + } + case 18: + { + if (options[i]->userSetChoice == 1) + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting automatic vdr shutdown"); + VDR::getInstance()->setVDRShutdown(true); + } + else + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting local shutdown"); + VDR::getInstance()->setVDRShutdown(false); + } + break; + } } } else -- 2.39.5