diff --git a/lib/sectionsdclient/sectionsdMsg.h b/lib/sectionsdclient/sectionsdMsg.h index c9d7c88f0..9358e8340 100644 --- a/lib/sectionsdclient/sectionsdMsg.h +++ b/lib/sectionsdclient/sectionsdMsg.h @@ -58,6 +58,7 @@ struct sectionsd getIsScanningActive, // commandGetIsScanningActive getIsTimeSet, // commandGetIsTimeSet serviceChanged, // commandserviceChanged + serviceStopped, // commandserviceChanged CMD_registerEvents, // commandRegisterEventClient CMD_unregisterEvents, // commandUnRegisterEventClient freeMemory, // commandFreeMemory diff --git a/lib/sectionsdclient/sectionsdclient.cpp b/lib/sectionsdclient/sectionsdclient.cpp index 2173ea9b5..c50066926 100644 --- a/lib/sectionsdclient/sectionsdclient.cpp +++ b/lib/sectionsdclient/sectionsdclient.cpp @@ -161,6 +161,14 @@ void CSectionsdClient::setServiceChanged(const t_channel_id channel_id, const bo close_connection(); } +void CSectionsdClient::setServiceStopped() +{ + send(sectionsd::serviceStopped); + + readResponse(); + close_connection(); +} + void CSectionsdClient::freeMemory() { send(sectionsd::freeMemory); diff --git a/lib/sectionsdclient/sectionsdclient.h b/lib/sectionsdclient/sectionsdclient.h index f782b9e16..f202ed94d 100644 --- a/lib/sectionsdclient/sectionsdclient.h +++ b/lib/sectionsdclient/sectionsdclient.h @@ -182,6 +182,7 @@ class CSectionsdClient : private CBasicClient bool getIsTimeSet(); void setPauseScanning(const bool doPause); void setServiceChanged(const t_channel_id channel_id, const bool requestEvent, int dnum = 0); + void setServiceStopped(); bool getIsScanningActive(); diff --git a/src/daemonc/remotecontrol.cpp b/src/daemonc/remotecontrol.cpp index c2ecea76b..35149ab9e 100644 --- a/src/daemonc/remotecontrol.cpp +++ b/src/daemonc/remotecontrol.cpp @@ -119,6 +119,8 @@ int CRemoteControl::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data //printf("[neutrino] timeout EVT_ZAP current %llx data %llx\n", current_channel_id, *(t_channel_id *)data); if ((*(t_channel_id *)data) != current_channel_id) { g_InfoViewer->chanready = 0; + if (!IS_WEBTV(current_channel_id)) + g_Sectionsd->setServiceStopped(); CMoviePlayerGui::getInstance().stopPlayBack(); g_Zapit->zapTo_serviceID_NOWAIT(current_channel_id ); //g_Sectionsd->setServiceChanged(current_channel_id, false); @@ -702,6 +704,8 @@ void CRemoteControl::zapTo_ChannelID(const t_channel_id channel_id, const std::s g_RCInput->killTimer(scrambled_timer); //dvbsub_pause(true); CZapit::getInstance()->Abort(); + if (!IS_WEBTV(channel_id)) + g_Sectionsd->setServiceStopped(); CMoviePlayerGui::getInstance().stopPlayBack(); g_Zapit->zapTo_serviceID_NOWAIT(channel_id); diff --git a/src/eitd/dmx.cpp b/src/eitd/dmx.cpp index 3850c3983..007676db1 100644 --- a/src/eitd/dmx.cpp +++ b/src/eitd/dmx.cpp @@ -73,7 +73,6 @@ DMX::DMX() void DMX::init() { - fd = -1; lastChanged = time_monotonic(); filter_index = 0; real_pauseCounter = 0; @@ -124,7 +123,6 @@ void DMX::closefd(void) //dmx->Stop(); delete dmx; dmx = NULL; - fd = -1; } } @@ -283,6 +281,10 @@ int DMX::getSection(uint8_t *buf, const unsigned timeoutInMSeconds, int &timeout } lock(); + if (!isOpen()) { + unlock(); + return -1; + } int rc = dmx->Read(buf, MAX_SECTION_LENGTH, timeoutInMSeconds); @@ -492,7 +494,6 @@ int DMX::immediate_start(void) dmx = new cDemux(dmx_num); dmx->Open(DMX_PSI_CHANNEL, NULL, dmxBufferSizeInKB*1024UL); } - fd = 1; /* setfilter() only if this is no dummy filter... */ if (filters[filter_index].filter && filters[filter_index].mask) diff --git a/src/eitd/dmx.h b/src/eitd/dmx.h index 38d30a31a..abecc1d7b 100644 --- a/src/eitd/dmx.h +++ b/src/eitd/dmx.h @@ -53,7 +53,6 @@ class DMX { protected: - int fd; cDemux * dmx; int dmx_num; unsigned short pID; @@ -69,7 +68,7 @@ protected: bool seen_section; inline bool isOpen(void) { - return (fd != -1); + return (dmx != NULL); } int immediate_start(void); /* mutex must be locked before and unlocked after this method */ diff --git a/src/eitd/eitd.h b/src/eitd/eitd.h index c650001ad..81f4b5473 100644 --- a/src/eitd/eitd.h +++ b/src/eitd/eitd.h @@ -260,6 +260,7 @@ class CCNThread : public CEventsThread void sendCNEvent(); public: CCNThread(); + void stopUpdate(); bool checkUpdate(); }; diff --git a/src/eitd/sectionsd.cpp b/src/eitd/sectionsd.cpp index 2fc063272..c229e77e5 100644 --- a/src/eitd/sectionsd.cpp +++ b/src/eitd/sectionsd.cpp @@ -968,6 +968,20 @@ static void commandserviceChanged(int connfd, char *data, const unsigned dataLen dprintf("[sectionsd] commandserviceChanged: Service changed to " PRINTF_CHANNEL_ID_TYPE "\n", uniqueServiceKey); } +static void commandserviceStopped(int connfd, char * /* data */, const unsigned /* dataLength */) +{ + xprintf("[sectionsd] commandserviceStopped\n"); + sendEmptyResponse(connfd, NULL, 0); + threadCN.lock(); + threadEIT.lock(); + threadCN.closefd(); + threadEIT.closefd(); + threadCN.unlock(); + threadEIT.unlock(); + threadCN.stopUpdate(); + xprintf("[sectionsd] commandserviceStopped done\n"); +} + static void commandGetIsScanningActive(int connfd, char* /*data*/, const unsigned /*dataLength*/) { struct sectionsd::msgResponseHeader responseHeader; @@ -1233,6 +1247,7 @@ static s_cmd_table connectionCommands[sectionsd::numberOfCommands] = { { commandGetIsScanningActive, "commandGetIsScanningActive" }, { commandGetIsTimeSet, "commandGetIsTimeSet" }, { commandserviceChanged, "commandserviceChanged" }, + { commandserviceStopped, "commandserviceStopped" }, { commandRegisterEventClient, "commandRegisterEventClient" }, { commandUnRegisterEventClient, "commandUnRegisterEventClient" }, { commandFreeMemory, "commandFreeMemory" }, @@ -1786,7 +1801,7 @@ void CCNThread::beforeWait() update_mutex.unlock(); } -void CCNThread::afterWait() +void CCNThread::stopUpdate() { xprintf("%s: stop eit update filter (%s)\n", name.c_str(), updating ? "active" : "not active"); update_mutex.lock(); @@ -1797,6 +1812,11 @@ void CCNThread::afterWait() update_mutex.unlock(); } +void CCNThread::afterWait() +{ + stopUpdate(); +} + void CCNThread::beforeSleep() { if (sendToSleepNow && messaging_have_CN == 0x00) {