From: Andreas Monzner Date: Wed, 29 Oct 2008 22:44:53 +0000 (+0000) Subject: also use refcounting for eTimers X-Git-Tag: 2.6.0~673 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/0c59a4279f93f08fe95fca5f2e55f3e025f0cceb also use refcounting for eTimers its now no more possible directly to call new eTimer .. or to embedded eTimer. to create a eTimer now eTimer::create must be used... to delete you must call ->AddRef() after timer creation and ->Release when the timer is no more needed. Or use ePtr to store the timer reference.. then its enough to set the ePtr object to 0 when the timer is no more needed --- diff --git a/lib/base/ebase.cpp b/lib/base/ebase.cpp index a66d1958..bd2ec589 100644 --- a/lib/base/ebase.cpp +++ b/lib/base/ebase.cpp @@ -39,7 +39,8 @@ void eSocketNotifier::stop() } } - // timer +DEFINE_REF(eTimer); + void eTimer::start(long msek, bool singleShot) { if (bActive) @@ -160,7 +161,12 @@ int eMainloop::processOneEvent(unsigned int twisted_timeout, PyObject **res, ePy { /* process all timers which are ready. first remove them out of the list. */ while (!m_timer_list.empty() && (poll_timeout = timeout_usec( m_timer_list.begin()->getNextActivation() ) ) <= 0 ) - m_timer_list.begin()->activate(); + { + eTimer *tmr = m_timer_list.begin(); + tmr->AddRef(); + tmr->activate(); + tmr->Release(); + } if (poll_timeout < 0) poll_timeout = 0; else /* convert us to ms */ @@ -403,7 +409,7 @@ eTimerPy_dealloc(eTimerPy* self) if (self->in_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) self); eTimerPy_clear(self); - delete self->tm; + self->tm->Release(); self->ob_type->tp_free((PyObject*)self); } @@ -411,7 +417,8 @@ static PyObject * eTimerPy_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { eTimerPy *self = (eTimerPy *)type->tp_alloc(type, 0); - self->tm = new eTimer(eApp); + self->tm = eTimer::create(eApp); + self->tm->AddRef(); self->in_weakreflist = NULL; return (PyObject *)self; } diff --git a/lib/base/ebase.h b/lib/base/ebase.h index 9c524ae9..c86c177d 100644 --- a/lib/base/ebase.h +++ b/lib/base/ebase.h @@ -269,8 +269,9 @@ public: * * This class emits the signal \c eTimer::timeout after the specified timeout. */ -class eTimer +class eTimer: iObject { + DECLARE_REF(eTimer); friend class eMainloop; eMainloop &context; timespec nextActivation; @@ -278,6 +279,9 @@ class eTimer bool bSingleShot; bool bActive; void activate(); + + eTimer(eMainloop *context): context(*context), bActive(false) { } + void operator delete(void *pmem) { ::operator delete(pmem); } public: /** * \brief Constructs a timer. @@ -285,7 +289,7 @@ public: * The timer is not yet active, it has to be started with \c start. * \param context The thread from which the signal should be emitted. */ - eTimer(eMainloop *context=eApp): context(*context), bActive(false) { } + static eTimer *create(eMainloop *context=eApp) { return new eTimer(context); } ~eTimer() { if (bActive) stop(); } PSignal0 timeout; @@ -299,6 +303,7 @@ public: void changeInterval(long msek); void startLongTimer( int seconds ); bool operator<(const eTimer& t) const { return nextActivation < t.nextActivation; } + eSmartPtrList m_clients; }; #endif // SWIG diff --git a/lib/components/file_eraser.cpp b/lib/components/file_eraser.cpp index eb9c82f3..031c30dd 100644 --- a/lib/components/file_eraser.cpp +++ b/lib/components/file_eraser.cpp @@ -11,12 +11,12 @@ eBackgroundFileEraser *eBackgroundFileEraser::instance; eBackgroundFileEraser::eBackgroundFileEraser() - :messages(this,1), stop_thread_timer(this) + :messages(this,1), stop_thread_timer(eTimer::create(this)) { if (!instance) instance=this; CONNECT(messages.recv_msg, eBackgroundFileEraser::gotMessage); - CONNECT(stop_thread_timer.timeout, eBackgroundFileEraser::idle); + CONNECT(stop_thread_timer->timeout, eBackgroundFileEraser::idle); } void eBackgroundFileEraser::idle() @@ -44,7 +44,7 @@ void eBackgroundFileEraser::thread() runLoop(); - stop_thread_timer.stop(); + stop_thread_timer->stop(); } void eBackgroundFileEraser::erase(const char *filename) @@ -76,7 +76,7 @@ void eBackgroundFileEraser::gotMessage(const Message &msg ) eDebug("file %s erased", msg.filename); free((char*)msg.filename); } - stop_thread_timer.start(1000, true); // stop thread in one seconds + stop_thread_timer->start(1000, true); // stop thread in one seconds break; case Message::quit: quit(0); diff --git a/lib/components/file_eraser.h b/lib/components/file_eraser.h index 6cb13dda..fd11eca8 100644 --- a/lib/components/file_eraser.h +++ b/lib/components/file_eraser.h @@ -25,7 +25,7 @@ class eBackgroundFileEraser: public eMainloop, private eThread, public Object void gotMessage(const Message &message); void thread(); void idle(); - eTimer stop_thread_timer; + ePtr stop_thread_timer; #ifndef SWIG public: #endif diff --git a/lib/dvb/decoder.cpp b/lib/dvb/decoder.cpp index c550163e..0ce59d01 100644 --- a/lib/dvb/decoder.cpp +++ b/lib/dvb/decoder.cpp @@ -931,10 +931,10 @@ RESULT eTSMPEGDecoder::setAC3Delay(int delay) } eTSMPEGDecoder::eTSMPEGDecoder(eDVBDemux *demux, int decoder) - :m_demux(demux), m_changed(0), m_decoder(decoder), m_video_clip_fd(-1), m_showSinglePicTimer(eApp) + :m_demux(demux), m_changed(0), m_decoder(decoder), m_video_clip_fd(-1), m_showSinglePicTimer(eTimer::create(eApp)) { demux->connectEvent(slot(*this, &eTSMPEGDecoder::demux_event), m_demux_event_conn); - CONNECT(m_showSinglePicTimer.timeout, eTSMPEGDecoder::finishShowSinglePic); + CONNECT(m_showSinglePicTimer->timeout, eTSMPEGDecoder::finishShowSinglePic); m_is_ff = m_is_sm = m_is_trickmode = 0; } @@ -1191,7 +1191,7 @@ RESULT eTSMPEGDecoder::showSinglePic(const char *filename) if (!seq_end_avail) write(m_video_clip_fd, seq_end, sizeof(seq_end)); write(m_video_clip_fd, stuffing, 8192); - m_showSinglePicTimer.start(150, true); + m_showSinglePicTimer->start(150, true); } close(f); } diff --git a/lib/dvb/decoder.h b/lib/dvb/decoder.h index a652e094..05e07ef9 100644 --- a/lib/dvb/decoder.h +++ b/lib/dvb/decoder.h @@ -131,7 +131,7 @@ private: void video_event(struct videoEvent); Signal1 m_video_event; int m_video_clip_fd; - eTimer m_showSinglePicTimer; + ePtr m_showSinglePicTimer; void finishShowSinglePic(); // called by timer public: enum { pidNone = -1 }; diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index 4482d3e7..68d9a0dd 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -61,7 +61,7 @@ ePtr NewResourceManagerPtr(void) } eDVBResourceManager::eDVBResourceManager() - :m_releaseCachedChannelTimer(eApp) + :m_releaseCachedChannelTimer(eTimer::create(eApp)) { avail = 1; busy = 0; @@ -86,7 +86,7 @@ eDVBResourceManager::eDVBResourceManager() eDVBCAService::registerChannelCallback(this); - CONNECT(m_releaseCachedChannelTimer.timeout, eDVBResourceManager::releaseCachedChannel); + CONNECT(m_releaseCachedChannelTimer->timeout, eDVBResourceManager::releaseCachedChannel); } void eDVBResourceManager::feStateChanged() @@ -541,7 +541,7 @@ RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUse } m_cached_channel_state_changed_conn.disconnect(); m_cached_channel=0; - m_releaseCachedChannelTimer.stop(); + m_releaseCachedChannelTimer->stop(); } eDebugNoSimulate("allocate channel.. %04x:%04x", channelid.transport_stream_id.get(), channelid.original_network_id.get()); @@ -611,13 +611,13 @@ void eDVBResourceManager::DVBChannelStateChanged(iDVBChannel *chan) case iDVBChannel::state_ok: { eDebug("stop release channel timer"); - m_releaseCachedChannelTimer.stop(); + m_releaseCachedChannelTimer->stop(); break; } case iDVBChannel::state_last_instance: { eDebug("start release channel timer"); - m_releaseCachedChannelTimer.start(3000, true); + m_releaseCachedChannelTimer->start(3000, true); break; } default: // ignore all other events @@ -639,7 +639,7 @@ RESULT eDVBResourceManager::allocateRawChannel(eUsePtr &channel, in { m_cached_channel_state_changed_conn.disconnect(); m_cached_channel=0; - m_releaseCachedChannelTimer.stop(); + m_releaseCachedChannelTimer->stop(); } int err = allocateFrontendByIndex(fe, slot_index); @@ -655,11 +655,11 @@ RESULT eDVBResourceManager::allocatePVRChannel(eUsePtr &channel) { ePtr demux; - if (m_cached_channel && m_releaseCachedChannelTimer.isActive()) + if (m_cached_channel && m_releaseCachedChannelTimer->isActive()) { m_cached_channel_state_changed_conn.disconnect(); m_cached_channel=0; - m_releaseCachedChannelTimer.stop(); + m_releaseCachedChannelTimer->stop(); } channel = new eDVBChannel(this, 0); diff --git a/lib/dvb/dvb.h b/lib/dvb/dvb.h index bceb9ad0..1a773efa 100644 --- a/lib/dvb/dvb.h +++ b/lib/dvb/dvb.h @@ -22,7 +22,7 @@ class iDVBAdapter; class eDVBRegisteredFrontend: public iObject, public Object { DECLARE_REF(eDVBRegisteredFrontend); - eTimer *disable; + ePtr disable; void closeFrontend() { if (!m_inuse && m_frontend->closeFrontend()) // frontend busy @@ -31,14 +31,10 @@ class eDVBRegisteredFrontend: public iObject, public Object public: Signal0 stateChanged; eDVBRegisteredFrontend(eDVBFrontend *fe, iDVBAdapter *adap) - :disable(new eTimer(eApp)), m_adapter(adap), m_frontend(fe), m_inuse(0) + :disable(eTimer::create(eApp)), m_adapter(adap), m_frontend(fe), m_inuse(0) { CONNECT(disable->timeout, eDVBRegisteredFrontend::closeFrontend); } - ~eDVBRegisteredFrontend() - { - delete disable; - } void dec_use() { if (!--m_inuse) @@ -164,7 +160,7 @@ class eDVBResourceManager: public iObject, public Object eUsePtr m_cached_channel; Connection m_cached_channel_state_changed_conn; - eTimer m_releaseCachedChannelTimer; + ePtr m_releaseCachedChannelTimer; void DVBChannelStateChanged(iDVBChannel*); void feStateChanged(); #ifndef SWIG diff --git a/lib/dvb/dvbtime.cpp b/lib/dvb/dvbtime.cpp index 42b12e85..4c5911c9 100644 --- a/lib/dvb/dvbtime.cpp +++ b/lib/dvb/dvbtime.cpp @@ -86,10 +86,10 @@ time_t parseDVBtime(__u8 t1, __u8 t2, __u8 t3, __u8 t4, __u8 t5) } TDT::TDT(eDVBChannel *chan, int update_count) - :chan(chan), update_count(update_count) + :chan(chan), m_interval_timer(eTimer::create()), update_count(update_count) { CONNECT(tableReady, TDT::ready); - CONNECT(m_interval_timer.timeout, TDT::start); + CONNECT(m_interval_timer->timeout, TDT::start); if (chan) chan->getDemux(demux, 0); } @@ -136,7 +136,7 @@ void TDT::start() void TDT::startTimer( int interval ) { - m_interval_timer.start(interval, true); + m_interval_timer->start(interval, true); } eDVBLocalTimeHandler *eDVBLocalTimeHandler::instance; diff --git a/lib/dvb/dvbtime.h b/lib/dvb/dvbtime.h index ffcfaa41..efb85962 100644 --- a/lib/dvb/dvbtime.h +++ b/lib/dvb/dvbtime.h @@ -31,7 +31,7 @@ class TDT: public eGTable { eDVBChannel *chan; ePtr demux; - eTimer m_interval_timer; + ePtr m_interval_timer; int createTable(unsigned int nr, const __u8 *data, unsigned int max); void ready(int); int update_count; diff --git a/lib/dvb/epgcache.cpp b/lib/dvb/epgcache.cpp index 1a07755f..0bb6e25b 100644 --- a/lib/dvb/epgcache.cpp +++ b/lib/dvb/epgcache.cpp @@ -213,13 +213,13 @@ pthread_mutex_t eEPGCache::channel_map_lock= DEFINE_REF(eEPGCache) eEPGCache::eEPGCache() - :messages(this,1), cleanTimer(this)//, paused(0) + :messages(this,1), cleanTimer(eTimer::create(this))//, paused(0) { eDebug("[EPGC] Initialized EPGCache"); CONNECT(messages.recv_msg, eEPGCache::gotMessage); CONNECT(eDVBLocalTimeHandler::getInstance()->m_timeUpdated, eEPGCache::timeUpdated); - CONNECT(cleanTimer.timeout, eEPGCache::cleanLoop); + CONNECT(cleanTimer->timeout, eEPGCache::cleanLoop); ePtr res_mgr; eDVBResourceManager::getInstance(res_mgr); @@ -783,7 +783,7 @@ void eEPGCache::cleanLoop() eDebug("[EPGC] stop cleanloop"); eDebug("[EPGC] %i bytes for cache used", eventData::CacheSize); } - cleanTimer.start(CLEAN_INTERVAL,true); + cleanTimer->start(CLEAN_INTERVAL,true); } eEPGCache::~eEPGCache() @@ -847,7 +847,7 @@ void eEPGCache::gotMessage( const Message &msg ) int update = ( It != channelLastUpdated.end() ? ( UPDATE_INTERVAL - ( (::time(0)-It->second) * 1000 ) ) : ZAP_DELAY ); if (update < ZAP_DELAY) update = ZAP_DELAY; - data->startPrivateTimer.start(update, 1); + data->startPrivateTimer->start(update, 1); if (update >= 60000) eDebug("[EPGC] next private update in %i min", update/60000); else if (update >= 1000) @@ -1088,22 +1088,22 @@ void eEPGCache::save() eEPGCache::channel_data::channel_data(eEPGCache *ml) :cache(ml) - ,abortTimer(ml), zapTimer(ml), state(0) + ,abortTimer(eTimer::create(ml)), zapTimer(eTimer::create(ml)), state(0) ,isRunning(0), haveData(0) #ifdef ENABLE_PRIVATE_EPG - ,startPrivateTimer(ml) + ,startPrivateTimer(eTimer::create(ml)) #endif #ifdef ENABLE_MHW_EPG - ,m_MHWTimeoutTimer(ml) + ,m_MHWTimeoutTimer(eTimer::create(ml)) #endif { #ifdef ENABLE_MHW_EPG - CONNECT(m_MHWTimeoutTimer.timeout, eEPGCache::channel_data::MHWTimeout); + CONNECT(m_MHWTimeoutTimer->timeout, eEPGCache::channel_data::MHWTimeout); #endif - CONNECT(zapTimer.timeout, eEPGCache::channel_data::startEPG); - CONNECT(abortTimer.timeout, eEPGCache::channel_data::abortNonAvail); + CONNECT(zapTimer->timeout, eEPGCache::channel_data::startEPG); + CONNECT(abortTimer->timeout, eEPGCache::channel_data::abortNonAvail); #ifdef ENABLE_PRIVATE_EPG - CONNECT(startPrivateTimer.timeout, eEPGCache::channel_data::startPrivateReader); + CONNECT(startPrivateTimer->timeout, eEPGCache::channel_data::startPrivateReader); #endif pthread_mutex_init(&channel_active, 0); } @@ -1113,7 +1113,7 @@ bool eEPGCache::channel_data::finishEPG() if (!isRunning) // epg ready { eDebug("[EPGC] stop caching events(%ld)", ::time(0)); - zapTimer.start(UPDATE_INTERVAL, 1); + zapTimer->start(UPDATE_INTERVAL, 1); eDebug("[EPGC] next update in %i min", UPDATE_INTERVAL / 60000); for (int i=0; i < 3; ++i) { @@ -1186,7 +1186,7 @@ void eEPGCache::channel_data::startEPG() m_ScheduleOtherReader->start(mask); isRunning |= SCHEDULE_OTHER; - abortTimer.start(7000,true); + abortTimer->start(7000,true); } void eEPGCache::channel_data::abortNonAvail() @@ -1226,7 +1226,7 @@ void eEPGCache::channel_data::abortNonAvail() } #endif if ( isRunning ) - abortTimer.start(90000, true); + abortTimer->start(90000, true); else { ++state; @@ -1250,7 +1250,7 @@ void eEPGCache::channel_data::startChannel() if (update < ZAP_DELAY) update = ZAP_DELAY; - zapTimer.start(update, 1); + zapTimer->start(update, 1); if (update >= 60000) eDebug("[EPGC] next update in %i min", update/60000); else if (update >= 1000) @@ -1264,8 +1264,8 @@ void eEPGCache::channel_data::abortEPG() seenSections[i].clear(); calcedSections[i].clear(); } - abortTimer.stop(); - zapTimer.stop(); + abortTimer->stop(); + zapTimer->stop(); if (isRunning) { eDebug("[EPGC] abort caching events !!"); @@ -2919,7 +2919,7 @@ void eEPGCache::channel_data::storeTitle(std::map<__u32, mhw_title_t>::iterator void eEPGCache::channel_data::startTimeout(int msec) { - m_MHWTimeoutTimer.start(msec,true); + m_MHWTimeoutTimer->start(msec,true); m_MHWTimeoutet=false; } diff --git a/lib/dvb/epgcache.h b/lib/dvb/epgcache.h index 5e5e7e8e..fc42ded5 100644 --- a/lib/dvb/epgcache.h +++ b/lib/dvb/epgcache.h @@ -155,7 +155,7 @@ class eEPGCache: public eMainloop, private eThread, public Object pthread_mutex_t channel_active; channel_data(eEPGCache*); eEPGCache *cache; - eTimer abortTimer, zapTimer; + ePtr abortTimer, zapTimer; int prevChannelState; __u8 state, isRunning, haveData; ePtr channel; @@ -163,7 +163,7 @@ class eEPGCache: public eMainloop, private eThread, public Object ePtr m_NowNextReader, m_ScheduleReader, m_ScheduleOtherReader; tidMap seenSections[3], calcedSections[3]; #ifdef ENABLE_PRIVATE_EPG - eTimer startPrivateTimer; + ePtr startPrivateTimer; int m_PrevVersion; int m_PrivatePid; uniqueEPGKey m_PrivateService; @@ -181,7 +181,7 @@ class eEPGCache: public eMainloop, private eThread, public Object ePtr m_MHWConn, m_MHWConn2; ePtr m_MHWReader, m_MHWReader2; eDVBSectionFilterMask m_MHWFilterMask, m_MHWFilterMask2; - eTimer m_MHWTimeoutTimer; + ePtr m_MHWTimeoutTimer; bool m_MHWTimeoutet; void MHWTimeout() { m_MHWTimeoutet=true; } void readMHWData(const __u8 *data); @@ -249,7 +249,7 @@ private: friend class channel_data; static eEPGCache *instance; - eTimer cleanTimer; + ePtr cleanTimer; std::map m_knownChannels; ePtr m_chanAddedConn; diff --git a/lib/dvb/esection.cpp b/lib/dvb/esection.cpp index 8ec07901..28e37cbc 100644 --- a/lib/dvb/esection.cpp +++ b/lib/dvb/esection.cpp @@ -50,7 +50,7 @@ void eGTable::timeout() } eGTable::eGTable(bool debug): - m_timeout(0), m_debug(debug), error(0) + m_debug(debug), error(0) { } @@ -130,9 +130,7 @@ RESULT eGTable::start(iDVBSectionReader *reader, const eDVBTableSpec &table) if (m_table.flags & eDVBTableSpec::tfHaveTimeout) { - if (m_timeout) - delete m_timeout; - m_timeout = new eTimer(eApp); + m_timeout = eTimer::create(eApp); m_timeout->start(m_table.timeout, 1); // begin timeout CONNECT(m_timeout->timeout, eGTable::timeout); } @@ -152,8 +150,6 @@ RESULT eGTable::start(iDVBDemux *demux, const eDVBTableSpec &table) eGTable::~eGTable() { - if (m_timeout) - delete m_timeout; } void eAUGTable::slotTableReady(int error) diff --git a/lib/dvb/esection.h b/lib/dvb/esection.h index ae806652..5720d5de 100644 --- a/lib/dvb/esection.h +++ b/lib/dvb/esection.h @@ -15,7 +15,7 @@ class eGTable: public iObject, public Object unsigned int m_tries; - eTimer *m_timeout; + ePtr m_timeout; void sectionRead(const __u8 *data); void timeout(); diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp index 01eb27ae..1bcacc03 100644 --- a/lib/dvb/frontend.cpp +++ b/lib/dvb/frontend.cpp @@ -455,10 +455,10 @@ eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok, bool simulate) sprintf(m_filename, "/dev/dvb/adapter%d/frontend%d", adap, fe); #endif - m_timeout = new eTimer(eApp); + m_timeout = eTimer::create(eApp); CONNECT(m_timeout->timeout, eDVBFrontend::timeout); - m_tuneTimer = new eTimer(eApp); + m_tuneTimer = eTimer::create(eApp); CONNECT(m_tuneTimer->timeout, eDVBFrontend::tuneLoop); for (int i=0; i m_sec; ePtr m_sn; int m_tuning; - eTimer *m_timeout; - eTimer *m_tuneTimer; + ePtr m_timeout, m_tuneTimer; eSecCommandList m_sec_sequence; diff --git a/lib/dvb/pmt.cpp b/lib/dvb/pmt.cpp index 8364be53..80fbcab3 100644 --- a/lib/dvb/pmt.cpp +++ b/lib/dvb/pmt.cpp @@ -671,10 +671,10 @@ ChannelMap eDVBCAService::exist_channels; ePtr eDVBCAService::m_chanAddedConn; eDVBCAService::eDVBCAService() - : m_prev_build_hash(0), m_sendstate(0), m_retryTimer(eApp) + : m_prev_build_hash(0), m_sendstate(0), m_retryTimer(eTimer::create(eApp)) { memset(m_used_demux, 0xFF, sizeof(m_used_demux)); - CONNECT(m_retryTimer.timeout, eDVBCAService::sendCAPMT); + CONNECT(m_retryTimer->timeout, eDVBCAService::sendCAPMT); Connect(); } @@ -1040,11 +1040,11 @@ void eDVBCAService::sendCAPMT() { case 0xFFFFFFFF: ++m_sendstate; - m_retryTimer.start(0,true); + m_retryTimer->start(0,true); // eDebug("[eDVBCAService] send failed .. immediate retry"); break; default: - m_retryTimer.start(5000,true); + m_retryTimer->start(5000,true); // eDebug("[eDVBCAService] send failed .. retry in 5 sec"); break; } diff --git a/lib/dvb/pmt.h b/lib/dvb/pmt.h index bd6c4f16..d3a7faa7 100644 --- a/lib/dvb/pmt.h +++ b/lib/dvb/pmt.h @@ -44,7 +44,7 @@ class eDVBCAService: public Object struct sockaddr_un m_servaddr; unsigned int m_sendstate; unsigned char m_capmt[2048]; - eTimer m_retryTimer; + ePtr m_retryTimer; void sendCAPMT(); void Connect(); void socketCB(int what); diff --git a/lib/dvb/radiotext.cpp b/lib/dvb/radiotext.cpp index 1a8ffd51..9f8cf5f0 100644 --- a/lib/dvb/radiotext.cpp +++ b/lib/dvb/radiotext.cpp @@ -7,7 +7,7 @@ DEFINE_REF(eDVBRdsDecoder); eDVBRdsDecoder::eDVBRdsDecoder(iDVBDemux *demux) :msgPtr(0), bsflag(0), qdar_pos(0), t_ptr(0), qdarmvi_show(0), state(0) - ,m_abortTimer(eApp) + ,m_abortTimer(eTimer::create(eApp)) { setStreamID(0xC0, 0xC0); @@ -18,7 +18,7 @@ eDVBRdsDecoder::eDVBRdsDecoder(iDVBDemux *demux) eDebug("failed to create PES reader!"); else m_pes_reader->connectRead(slot(*this, &eDVBRdsDecoder::processData), m_read_connection); - CONNECT(m_abortTimer.timeout, eDVBRdsDecoder::abortNonAvail); + CONNECT(m_abortTimer->timeout, eDVBRdsDecoder::abortNonAvail); } eDVBRdsDecoder::~eDVBRdsDecoder() @@ -193,7 +193,7 @@ void eDVBRdsDecoder::processPESPacket(__u8 *data, int len) if (data[offs] == 0xFD) { - m_abortTimer.stop(); + m_abortTimer->stop(); int ancillary_len = 1 + data[offs - 1]; offs -= ancillary_len; gotAncillaryData(data+offs, ancillary_len); @@ -639,7 +639,7 @@ int eDVBRdsDecoder::start(int pid) { int ret = -1; if (m_pes_reader && !(ret = m_pes_reader->start(pid))) - m_abortTimer.startLongTimer(20); + m_abortTimer->startLongTimer(20); return ret; } diff --git a/lib/dvb/radiotext.h b/lib/dvb/radiotext.h index 634352f7..ace7b6ec 100644 --- a/lib/dvb/radiotext.h +++ b/lib/dvb/radiotext.h @@ -37,7 +37,7 @@ private: ePtr m_pes_reader; ePtr m_read_connection; Signal1 m_event; - eTimer m_abortTimer; + ePtr m_abortTimer; }; #endif diff --git a/lib/gui/esubtitle.cpp b/lib/gui/esubtitle.cpp index f859c170..c837afc6 100644 --- a/lib/gui/esubtitle.cpp +++ b/lib/gui/esubtitle.cpp @@ -11,12 +11,12 @@ */ eSubtitleWidget::eSubtitleWidget(eWidget *parent) - : eWidget(parent), m_hide_subtitles_timer(eApp) + : eWidget(parent), m_hide_subtitles_timer(eTimer::create(eApp)) { setBackgroundColor(gRGB(0,0,0,255)); m_page_ok = 0; m_dvb_page_ok = 0; - CONNECT(m_hide_subtitles_timer.timeout, eSubtitleWidget::clearPage); + CONNECT(m_hide_subtitles_timer->timeout, eSubtitleWidget::clearPage); } #define startX 50 @@ -46,7 +46,7 @@ void eSubtitleWidget::setPage(const eDVBTeletextSubtitlePage &p) m_visible_region.rects.push_back(area); } } - m_hide_subtitles_timer.start(7500, true); + m_hide_subtitles_timer->start(7500, true); invalidate(m_visible_region); // invalidate new regions } @@ -62,7 +62,7 @@ void eSubtitleWidget::setPage(const eDVBSubtitlePage &p) m_visible_region.rects.push_back(eRect(it->m_position, it->m_pixmap->size())); } m_dvb_page_ok = 1; - m_hide_subtitles_timer.start(7500, true); + m_hide_subtitles_timer->start(7500, true); invalidate(m_visible_region); // invalidate new regions } @@ -93,7 +93,7 @@ void eSubtitleWidget::setPage(const ePangoSubtitlePage &p) } } int timeout_ms = m_pango_page.m_timeout; - m_hide_subtitles_timer.start(timeout_ms, true); + m_hide_subtitles_timer->start(timeout_ms, true); invalidate(m_visible_region); // invalidate new regions } diff --git a/lib/gui/esubtitle.h b/lib/gui/esubtitle.h index 81f920ec..1635e6de 100644 --- a/lib/gui/esubtitle.h +++ b/lib/gui/esubtitle.h @@ -53,7 +53,7 @@ private: int m_pango_page_ok; ePangoSubtitlePage m_pango_page; - eTimer m_hide_subtitles_timer; + ePtr m_hide_subtitles_timer; gRegion m_visible_region; diff --git a/lib/gui/ewidgetdesktop.cpp b/lib/gui/ewidgetdesktop.cpp index 9f40a3db..63aeaace 100644 --- a/lib/gui/ewidgetdesktop.cpp +++ b/lib/gui/ewidgetdesktop.cpp @@ -343,12 +343,11 @@ void eWidgetDesktop::setRedrawTask(eMainloop &ml) { if (m_mainloop) { - delete m_timer; m_timer = 0; m_mainloop = 0; } m_mainloop = &ml; - m_timer = new eTimer(m_mainloop); + m_timer = eTimer::create(m_mainloop); CONNECT(m_timer->timeout, eWidgetDesktop::paint); if (m_require_redraw) @@ -399,7 +398,7 @@ void eWidgetDesktop::setCompositionMode(int mode) removeBufferForWidget(*i, l); } -eWidgetDesktop::eWidgetDesktop(eSize size): m_mainloop(0), m_timer(0) +eWidgetDesktop::eWidgetDesktop(eSize size): m_mainloop(0) { m_screen.m_dirty_region = gRegion(eRect(ePoint(0, 0), size)); m_screen.m_screen_size = size; diff --git a/lib/gui/ewidgetdesktop.h b/lib/gui/ewidgetdesktop.h index 91b7ea08..4ea5b57a 100644 --- a/lib/gui/ewidgetdesktop.h +++ b/lib/gui/ewidgetdesktop.h @@ -79,7 +79,7 @@ private: void paintBackground(eWidgetDesktopCompBuffer *comp); eMainloop *m_mainloop; - eTimer *m_timer; + ePtr m_timer; int m_comp_mode; int m_require_redraw; diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index e0e6dbca..954a3964 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -1065,7 +1065,9 @@ eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref, eDVBService *serv m_tune_state = -1; - CONNECT(m_subtitle_sync_timer.timeout, eDVBServicePlay::checkSubtitleTiming); + m_subtitle_sync_timer = eTimer::create(eApp); + + CONNECT(m_subtitle_sync_timer->timeout, eDVBServicePlay::checkSubtitleTiming); } eDVBServicePlay::~eDVBServicePlay() @@ -2926,7 +2928,7 @@ void eDVBServicePlay::checkSubtitleTiming() } else { eDebug("start subtitle delay %d", diff / 90); - m_subtitle_sync_timer.start(diff / 90, 1); + m_subtitle_sync_timer->start(diff / 90, 1); break; } } diff --git a/lib/service/servicedvb.h b/lib/service/servicedvb.h index bae0c6e5..85e97ea1 100644 --- a/lib/service/servicedvb.h +++ b/lib/service/servicedvb.h @@ -272,7 +272,7 @@ private: ePtr m_new_dvb_subtitle_page_connection; std::list m_dvb_subtitle_pages; - eTimer m_subtitle_sync_timer; + ePtr m_subtitle_sync_timer; void checkSubtitleTiming(); /* radiotext */ diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 1778e5bb..a453f54f 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -174,14 +174,13 @@ int eStaticServiceMP3Info::getLength(const eServiceReference &ref) eServiceMP3::eServiceMP3(const char *filename): m_filename(filename), m_pump(eApp, 1) { + m_seekTimeout = eTimer::create(eApp); m_stream_tags = 0; - m_audioStreams.clear(); - m_subtitleStreams.clear(); m_currentAudioStream = 0; m_currentSubtitleStream = 0; m_subtitle_widget = 0; m_currentTrickRatio = 0; - CONNECT(m_seekTimeout.timeout, eServiceMP3::seekTimeoutCB); + CONNECT(m_seekTimeout->timeout, eServiceMP3::seekTimeoutCB); CONNECT(m_pump.recv_msg, eServiceMP3::gstPoll); GstElement *source = 0; @@ -527,9 +526,9 @@ RESULT eServiceMP3::setFastForward(int ratio) { m_currentTrickRatio = ratio; if (ratio) - m_seekTimeout.start(1000, 0); + m_seekTimeout->start(1000, 0); else - m_seekTimeout.stop(); + m_seekTimeout->stop(); return 0; } @@ -543,13 +542,13 @@ void eServiceMP3::seekTimeoutCB() if (ppos < 0) { ppos = 0; - m_seekTimeout.stop(); + m_seekTimeout->stop(); } if (ppos > len) { ppos = 0; stop(); - m_seekTimeout.stop(); + m_seekTimeout->stop(); return; } seekTo(ppos); diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h index ae12c33a..a43c8ad9 100644 --- a/lib/service/servicemp3.h +++ b/lib/service/servicemp3.h @@ -153,7 +153,7 @@ private: std::vector m_subtitleStreams; eSubtitleWidget *m_subtitle_widget; int m_currentTrickRatio; - eTimer m_seekTimeout; + ePtr m_seekTimeout; void seekTimeoutCB(); friend class eServiceFactoryMP3; std::string m_filename;