diff --git a/src/zapit/include/zapit/zapit.h b/src/zapit/include/zapit/zapit.h index 4473e003a..9be18fe7f 100644 --- a/src/zapit/include/zapit/zapit.h +++ b/src/zapit/include/zapit/zapit.h @@ -134,6 +134,7 @@ class CZapit : public OpenThreads::Thread CZapitChannel * current_channel; t_channel_id live_channel_id; t_channel_id pip_channel_id; + t_channel_id lock_channel_id; /* scan params */ TP_params TP; fast_scan_type_t scant; diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index fd07d0745..a3a489fab 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -130,6 +130,7 @@ CZapit::CZapit() current_volume = 100; volume_percent = 0; pip_channel_id = 0; + lock_channel_id = 0; pip_fe = NULL; } @@ -350,7 +351,7 @@ void CZapit::ConfigFrontend() void CZapit::SendPMT(bool forupdate) { - if(!current_channel) + if(!current_channel || (!forupdate && playbackStopForced)) return; CCamManager::getInstance()->Start(current_channel->getChannelID(), CCamManager::PLAY, forupdate); @@ -525,6 +526,7 @@ bool CZapit::ZapIt(const t_channel_id channel_id, bool forupdate, bool startplay current_channel = newchannel; live_channel_id = current_channel->getChannelID(); + lock_channel_id = live_channel_id; SaveSettings(false); if(!TuneChannel(live_fe, newchannel, transponder_change)) { @@ -534,7 +536,7 @@ bool CZapit::ZapIt(const t_channel_id channel_id, bool forupdate, bool startplay } SendEvent(CZapitClient::EVT_TUNE_COMPLETE, &live_channel_id, sizeof(t_channel_id)); -#if 0 // def ENABLE_PIP +#ifdef ENABLE_PIP if (transponder_change && (live_fe == pip_fe)) StopPip(); #endif @@ -598,7 +600,9 @@ bool CZapit::StartPip(const t_channel_id channel_id) { CZapitChannel* newchannel; bool transponder_change; - + /* do lock if live is running, or in record mode - + this is for the case temporary timeshift is running, it do not lock its frontend */ + bool need_lock = !playbackStopForced || (currentMode & RECORD_MODE); if((newchannel = CServiceManager::getInstance()->FindChannel(channel_id)) == NULL) { INFO("channel_id " PRINTF_CHANNEL_ID_TYPE " not found", channel_id); @@ -606,14 +610,22 @@ bool CZapit::StartPip(const t_channel_id channel_id) } INFO("[pip] zap to %s (%llx tp %llx)", newchannel->getName().c_str(), newchannel->getChannelID(), newchannel->getTransponderId()); - CFEManager::getInstance()->lockFrontend(live_fe); + if (need_lock) + CFEManager::getInstance()->lockFrontend(live_fe); + CFrontend * frontend = CFEManager::getInstance()->allocateFE(newchannel); - CFEManager::getInstance()->unlockFrontend(live_fe); + + if (need_lock) + CFEManager::getInstance()->unlockFrontend(live_fe); + if(frontend == NULL) { ERROR("Cannot get frontend\n"); return false; } StopPip(); + if (!need_lock && !SAME_TRANSPONDER(newchannel->getChannelID(), live_channel_id)) + live_channel_id = newchannel->getChannelID(); + if(!TuneChannel(frontend, newchannel, transponder_change)) return false; @@ -1605,12 +1617,20 @@ bool CZapit::ParseCommand(CBasicMessage::Header &rmsg, int connfd) StopPlayBack(true); standby = false; playbackStopForced = true; + lock_channel_id = live_channel_id; SendCmdReady(connfd); break; case CZapitMessages::CMD_SB_UNLOCK_PLAYBACK: playbackStopForced = false; - StartPlayBack(current_channel); - SendPMT(); + if (lock_channel_id == live_channel_id) { + StartPlayBack(current_channel); + SendPMT(); + } else { + live_fe->setTsidOnid(0); + ZapIt(lock_channel_id); + lock_channel_id = 0; + } + SendCmdReady(connfd); break; #if 0