X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/20f69c200ec5703e958a6b95abfcfd5a108e5939..acab01604673e3fb0d13e47f9ffb5c32e8d9dd07:/lib/dvb/dvbtime.cpp diff --git a/lib/dvb/dvbtime.cpp b/lib/dvb/dvbtime.cpp index 5167a01e..dc98a6d3 100644 --- a/lib/dvb/dvbtime.cpp +++ b/lib/dvb/dvbtime.cpp @@ -68,7 +68,7 @@ TDT::TDT(eDVBChannel *chan) CONNECT(tableReady, TDT::ready); CONNECT(m_interval_timer.timeout, TDT::start); if (chan) - chan->getDemux(demux); + chan->getDemux(demux, 0); } void TDT::ready(int error) @@ -81,7 +81,7 @@ int TDT::createTable(int nr, const __u8 *data, unsigned int max) if ( data && data[0] == 0x70 || data[0] == 0x73 ) { int length = ((data[1] & 0x0F) << 8) | data[2]; - if ( length >= 8 ) + if ( length >= 5 ) { time_t tptime = parseDVBtime(data[3], data[4], data[5], data[6], data[7]); eDVBLocalTimeHandler::getInstance()->updateTime(tptime, chan); @@ -97,14 +97,13 @@ void TDT::start() if ( chan ) { eDVBTableSpec spec; - spec.pid = TimeAndDateTable::PID; - spec.tid = TimeAndDateTable::TID; + spec.pid = TimeAndDateSection::PID; + spec.tid = TimeAndDateSection::TID; spec.tid_mask = 0xFC; - spec.timeout = TimeAndDateTable::TIMEOUT; + spec.timeout = TimeAndDateSection::TIMEOUT; spec.flags= eDVBTableSpec::tfAnyVersion | eDVBTableSpec::tfHaveTID | eDVBTableSpec::tfHaveTIDMask | - eDVBTableSpec::tfCheckCRC | eDVBTableSpec::tfHaveTimeout; if ( demux ) eGTable::start( demux, spec ); @@ -129,18 +128,14 @@ eDVBLocalTimeHandler::eDVBLocalTimeHandler() if (!res_mgr) eDebug("[eDVBLocalTimerHandler] no resource manager !!!!!!!"); else - { res_mgr->connectChannelAdded(slot(*this,&eDVBLocalTimeHandler::DVBChannelAdded), m_chanAddedConn); - res_mgr->connectChannelRemoved(slot(*this,&eDVBLocalTimeHandler::DVBChannelRemoved), m_chanRemovedConn); - res_mgr->connectChannelRunning(slot(*this,&eDVBLocalTimeHandler::DVBChannelRunning), m_chanRunningConn); - } } eDVBLocalTimeHandler::~eDVBLocalTimeHandler() { instance=0; - for (std::map::iterator it=m_active_tables.begin(); it != m_active_tables.end(); ++it) - delete it->second; + for (std::map::iterator it=m_knownChannels.begin(); it != m_knownChannels.end(); ++it) + delete it->second.tdt; } void eDVBLocalTimeHandler::readTimeOffsetData( const char* filename ) @@ -217,7 +212,7 @@ void eDVBLocalTimeHandler::updateTime( time_t tp_time, eDVBChannel *chan ) settimeofday(&tnow,0); for (ePtrList::iterator it(eMainloop::existing_loops) ;it != eMainloop::existing_loops.end(); ++it) - it->setTimerOffset(m_time_difference); + it->addTimeOffset(m_time_difference); m_time_difference=0; } else if ( !m_time_difference ) @@ -338,7 +333,7 @@ void eDVBLocalTimeHandler::updateTime( time_t tp_time, eDVBChannel *chan ) settimeofday(&tnow,0); for (ePtrList::iterator it(eMainloop::existing_loops) ;it != eMainloop::existing_loops.end(); ++it) - it->setTimerOffset(m_time_difference); + it->addTimeOffset(m_time_difference); m_time_difference=0; } @@ -347,52 +342,49 @@ void eDVBLocalTimeHandler::updateTime( time_t tp_time, eDVBChannel *chan ) if ( restart_tdt ) { - std::map::iterator it = - m_active_tables.find(chan); - if ( it != m_active_tables.end() ) + std::map::iterator it = + m_knownChannels.find(chan); + if ( it != m_knownChannels.end() ) { - delete it->second; - it->second = new TDT(chan); - it->second->startTimer(60*60*1000); // restart TDT for this transponder in 60min + delete it->second.tdt; + it->second.tdt = new TDT(chan); + it->second.tdt->startTimer(60*60*1000); // restart TDT for this transponder in 60min } } - } void eDVBLocalTimeHandler::DVBChannelAdded(eDVBChannel *chan) { - eDebug("[eDVBLocalTimerHandler] add channel %p", chan); if ( chan ) { - std::map::iterator it = - m_active_tables.find(chan); - if ( it != m_active_tables.end() ) - { - delete it->second; - it->second = new TDT(chan); - } - else - m_active_tables[chan] = new TDT(chan); +// eDebug("[eDVBLocalTimerHandler] add channel %p", chan); + std::pair::iterator, bool> tmp = + m_knownChannels.insert( std::pair(chan, channel_data()) ); + tmp.first->second.tdt = new TDT(chan); + tmp.first->second.channel = chan; + chan->connectStateChange(slot(*this, &eDVBLocalTimeHandler::DVBChannelStateChanged), tmp.first->second.m_stateChangedConn); } } -void eDVBLocalTimeHandler::DVBChannelRemoved(eDVBChannel *chan) +void eDVBLocalTimeHandler::DVBChannelStateChanged(iDVBChannel *chan) { - eDebug("[eDVBLocalTimerHandler] remove channel %p", chan); - std::map::iterator it = - m_active_tables.find(chan); - if ( it != m_active_tables.end() ) + std::map::iterator it = + m_knownChannels.find(chan); + if ( it != m_knownChannels.end() ) { - delete it->second; - m_active_tables.erase(it); + int state=0; + chan->getState(state); + switch (state) + { + case iDVBChannel::state_ok: + eDebug("[eDVBLocalTimerHandler] channel %p running", chan); + it->second.tdt->start(); + break; + case iDVBChannel::state_release: + eDebug("[eDVBLocalTimerHandler] remove channel %p", chan); + delete it->second.tdt; + m_knownChannels.erase(it); + break; + } } } - -void eDVBLocalTimeHandler::DVBChannelRunning(iDVBChannel *chan) -{ - eDebug("[eDVBLocalTimerHandler] start channel %p", chan); - std::map::iterator it = - m_active_tables.find(chan); - if ( it != m_active_tables.end() ) - it->second->start(); -}