also use refcounting for eTimers
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 29 Oct 2008 22:44:53 +0000 (22:44 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 29 Oct 2008 22:44:53 +0000 (22:44 +0000)
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<eTimer> to store the timer reference.. then its enough
to set the ePtr<eTimer> object to 0 when the timer is no more needed

28 files changed:
lib/base/ebase.cpp
lib/base/ebase.h
lib/components/file_eraser.cpp
lib/components/file_eraser.h
lib/dvb/decoder.cpp
lib/dvb/decoder.h
lib/dvb/dvb.cpp
lib/dvb/dvb.h
lib/dvb/dvbtime.cpp
lib/dvb/dvbtime.h
lib/dvb/epgcache.cpp
lib/dvb/epgcache.h
lib/dvb/esection.cpp
lib/dvb/esection.h
lib/dvb/frontend.cpp
lib/dvb/frontend.h
lib/dvb/pmt.cpp
lib/dvb/pmt.h
lib/dvb/radiotext.cpp
lib/dvb/radiotext.h
lib/gui/esubtitle.cpp
lib/gui/esubtitle.h
lib/gui/ewidgetdesktop.cpp
lib/gui/ewidgetdesktop.h
lib/service/servicedvb.cpp
lib/service/servicedvb.h
lib/service/servicemp3.cpp
lib/service/servicemp3.h

index a66d195..bd2ec58 100644 (file)
@@ -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;
 }
index 9c524ae..c86c177 100644 (file)
@@ -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<void> 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<iObject> m_clients;
 };
 #endif  // SWIG
 
index eb9c82f..031c30d 100644 (file)
 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);
index 6cb13dd..fd11eca 100644 (file)
@@ -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<eTimer> stop_thread_timer;
 #ifndef SWIG
 public:
 #endif
index c550163..0ce59d0 100644 (file)
@@ -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);
                }
index a652e09..05e07ef 100644 (file)
@@ -131,7 +131,7 @@ private:
        void video_event(struct videoEvent);
        Signal1<void, struct videoEvent> m_video_event;
        int m_video_clip_fd;
-       eTimer m_showSinglePicTimer;
+       ePtr<eTimer> m_showSinglePicTimer;
        void finishShowSinglePic(); // called by timer
 public:
        enum { pidNone = -1 };
index 4482d3e..68d9a0d 100644 (file)
@@ -61,7 +61,7 @@ ePtr<eDVBResourceManager> 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<iDVBChannel> &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<iDVBPVRChannel> &channel)
 {
        ePtr<eDVBAllocatedDemux> 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);
index bceb9ad..1a773ef 100644 (file)
@@ -22,7 +22,7 @@ class iDVBAdapter;
 class eDVBRegisteredFrontend: public iObject, public Object
 {
        DECLARE_REF(eDVBRegisteredFrontend);
-       eTimer *disable;
+       ePtr<eTimer> disable;
        void closeFrontend()
        {
                if (!m_inuse && m_frontend->closeFrontend()) // frontend busy
@@ -31,14 +31,10 @@ class eDVBRegisteredFrontend: public iObject, public Object
 public:
        Signal0<void> 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<iDVBChannel> m_cached_channel;
        Connection m_cached_channel_state_changed_conn;
-       eTimer m_releaseCachedChannelTimer;
+       ePtr<eTimer> m_releaseCachedChannelTimer;
        void DVBChannelStateChanged(iDVBChannel*);
        void feStateChanged();
 #ifndef SWIG
index 42b12e8..4c5911c 100644 (file)
@@ -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;
index ffcfaa4..efb8596 100644 (file)
@@ -31,7 +31,7 @@ class TDT: public eGTable
 {
        eDVBChannel *chan;
        ePtr<iDVBDemux> demux;
-       eTimer m_interval_timer;
+       ePtr<eTimer> m_interval_timer;
        int createTable(unsigned int nr, const __u8 *data, unsigned int max);
        void ready(int);
        int update_count;
index 1a07755..0bb6e25 100644 (file)
@@ -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<eDVBResourceManager> 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;
 }
 
index 5e5e7e8..fc42ded 100644 (file)
@@ -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<eTimer> abortTimer, zapTimer;
                int prevChannelState;
                __u8 state, isRunning, haveData;
                ePtr<eDVBChannel> channel;
@@ -163,7 +163,7 @@ class eEPGCache: public eMainloop, private eThread, public Object
                ePtr<iDVBSectionReader> m_NowNextReader, m_ScheduleReader, m_ScheduleOtherReader;
                tidMap seenSections[3], calcedSections[3];
 #ifdef ENABLE_PRIVATE_EPG
-               eTimer startPrivateTimer;
+               ePtr<eTimer> startPrivateTimer;
                int m_PrevVersion;
                int m_PrivatePid;
                uniqueEPGKey m_PrivateService;
@@ -181,7 +181,7 @@ class eEPGCache: public eMainloop, private eThread, public Object
                ePtr<eConnection> m_MHWConn, m_MHWConn2;
                ePtr<iDVBSectionReader> m_MHWReader, m_MHWReader2;
                eDVBSectionFilterMask m_MHWFilterMask, m_MHWFilterMask2;
-               eTimer m_MHWTimeoutTimer;
+               ePtr<eTimer> 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<eTimer> cleanTimer;
        std::map<iDVBChannel*, channel_data*> m_knownChannels;
        ePtr<eConnection> m_chanAddedConn;
 
index 8ec0790..28e37cb 100644 (file)
@@ -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)
index ae80665..5720d5d 100644 (file)
@@ -15,7 +15,7 @@ class eGTable: public iObject, public Object
        
        unsigned int m_tries;
        
-       eTimer *m_timeout;
+       ePtr<eTimer> m_timeout;
 
        void sectionRead(const __u8 *data);
        void timeout();
index 01eb27a..1bcacc0 100644 (file)
@@ -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<eDVBFrontend::NUM_DATA_ENTRIES; ++i)
@@ -617,8 +617,6 @@ eDVBFrontend::~eDVBFrontend()
 {
        m_data[LINKED_PREV_PTR] = m_data[LINKED_NEXT_PTR] = -1;
        closeFrontend();
-       delete m_timeout;
-       delete m_tuneTimer;
 }
 
 void eDVBFrontend::feEvent(int w)
index 61ea3bc..06ed12c 100644 (file)
@@ -87,8 +87,7 @@ private:
        ePtr<iDVBSatelliteEquipmentControl> m_sec;
        ePtr<eSocketNotifier> m_sn;
        int m_tuning;
-       eTimer *m_timeout;
-       eTimer *m_tuneTimer;
+       ePtr<eTimer> m_timeout, m_tuneTimer;
 
        eSecCommandList m_sec_sequence;
 
index 8364be5..80fbcab 100644 (file)
@@ -671,10 +671,10 @@ ChannelMap eDVBCAService::exist_channels;
 ePtr<eConnection> 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;
                }
index bd6c4f1..d3a7faa 100644 (file)
@@ -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<eTimer> m_retryTimer;
        void sendCAPMT();
        void Connect();
        void socketCB(int what);
index 1a8ffd5..9f8cf5f 100644 (file)
@@ -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;
 }
 
index 634352f..ace7b6e 100644 (file)
@@ -37,7 +37,7 @@ private:
        ePtr<iDVBPESReader> m_pes_reader;
        ePtr<eConnection> m_read_connection;
        Signal1<void, int> m_event;
-       eTimer m_abortTimer;
+       ePtr<eTimer> m_abortTimer;
 };
 
 #endif
index f859c17..c837afc 100644 (file)
        */      
 
 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
 }
 
index 81f920e..1635e6d 100644 (file)
@@ -53,7 +53,7 @@ private:
        int m_pango_page_ok;
        ePangoSubtitlePage m_pango_page;
 
-       eTimer m_hide_subtitles_timer;
+       ePtr<eTimer> m_hide_subtitles_timer;
 
        gRegion m_visible_region;
 
index 9f40a3d..63aeaac 100644 (file)
@@ -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;
index 91b7ea0..4ea5b57 100644 (file)
@@ -79,7 +79,7 @@ private:
        void paintBackground(eWidgetDesktopCompBuffer *comp);
        
        eMainloop *m_mainloop;
-       eTimer *m_timer;
+       ePtr<eTimer> m_timer;
        
        int m_comp_mode;
        int m_require_redraw;
index e0e6dbc..954a396 100644 (file)
@@ -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;
                }
        }
index bae0c6e..85e97ea 100644 (file)
@@ -272,7 +272,7 @@ private:
        ePtr<eConnection> m_new_dvb_subtitle_page_connection;
        std::list<eDVBSubtitlePage> m_dvb_subtitle_pages;
 
-       eTimer m_subtitle_sync_timer;
+       ePtr<eTimer> m_subtitle_sync_timer;
        void checkSubtitleTiming();
 
                /* radiotext */
index 1778e5b..a453f54 100644 (file)
@@ -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);
index ae12c33..a43c8ad 100644 (file)
@@ -153,7 +153,7 @@ private:
        std::vector<subtitleStream> m_subtitleStreams;
        eSubtitleWidget *m_subtitle_widget;
        int m_currentTrickRatio;
-       eTimer m_seekTimeout;
+       ePtr<eTimer> m_seekTimeout;
        void seekTimeoutCB();
        friend class eServiceFactoryMP3;
        std::string m_filename;