diff options
| -rw-r--r-- | lib/base/init.h | 32 | ||||
| -rw-r--r-- | lib/dvb/dvb.cpp | 2 | ||||
| -rw-r--r-- | lib/dvb/frontend.cpp | 2 | ||||
| -rw-r--r-- | lib/dvb/scan.cpp | 2 | ||||
| -rw-r--r-- | lib/dvb/scan.h | 2 | ||||
| -rw-r--r-- | lib/dvb/sec.cpp | 4 | ||||
| -rw-r--r-- | lib/dvb/sec.h | 1 | ||||
| -rw-r--r-- | lib/nav/core.cpp | 12 | ||||
| -rw-r--r-- | lib/nav/core.h | 3 | ||||
| -rw-r--r-- | lib/service/service.cpp | 10 | ||||
| -rw-r--r-- | lib/service/servicedvb.cpp | 2 | ||||
| -rw-r--r-- | lib/service/servicefs.cpp | 2 | ||||
| -rw-r--r-- | lib/service/servicemp3.cpp | 15 | ||||
| -rw-r--r-- | lib/service/servicemp3.h | 5 | ||||
| -rw-r--r-- | main/enigma.cpp | 21 |
15 files changed, 91 insertions, 24 deletions
diff --git a/lib/base/init.h b/lib/base/init.h index 465bac40..6ffd04c7 100644 --- a/lib/base/init.h +++ b/lib/base/init.h @@ -3,6 +3,7 @@ #include <list> #include <utility> +#include <lib/base/object.h> class eAutoInit; @@ -94,4 +95,35 @@ public: } }; +template<class T1> class +eAutoInitPtr: protected eAutoInit +{ + ePtr<T1> t; + void initNow() + { + t = new T1(); + } + void closeNow() + { + t = 0; + } +public: + operator T1*() + { + return t; + } + T1 *operator->() + { + return t; + } + eAutoInitPtr(int runl, char *description): eAutoInit(runl, description) + { + eInit::add(rl, this); + } + ~eAutoInitPtr() + { + eInit::remove(rl, this); + } +}; + #endif diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index 895ff084..cfdb05af 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -180,7 +180,7 @@ RESULT eDVBChannel::setChannel(const eDVBChannelID &channelid) RESULT eDVBChannel::connectStateChange(const Slot1<void,iDVBChannel*> &stateChange, ePtr<eConnection> &connection) { - connection = new eConnection(m_stateChanged.connect(stateChange)); + connection = new eConnection(this, m_stateChanged.connect(stateChange)); return 0; } diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp index c51eeea7..8948f194 100644 --- a/lib/dvb/frontend.cpp +++ b/lib/dvb/frontend.cpp @@ -391,7 +391,7 @@ RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where) RESULT eDVBFrontend::connectStateChange(const Slot1<void,iDVBFrontend*> &stateChange, ePtr<eConnection> &connection) { - connection = new eConnection(m_stateChanged.connect(stateChange)); + connection = new eConnection(this, m_stateChanged.connect(stateChange)); return 0; } diff --git a/lib/dvb/scan.cpp b/lib/dvb/scan.cpp index 68121c44..5571a810 100644 --- a/lib/dvb/scan.cpp +++ b/lib/dvb/scan.cpp @@ -369,6 +369,6 @@ RESULT eDVBScan::processSDT(eDVBNamespace dvbnamespace, const ServiceDescription RESULT eDVBScan::connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &connection) { - connection = new eConnection(m_event.connect(event)); + connection = new eConnection(this, m_event.connect(event)); return 0; } diff --git a/lib/dvb/scan.h b/lib/dvb/scan.h index 196e52fc..cc727644 100644 --- a/lib/dvb/scan.h +++ b/lib/dvb/scan.h @@ -6,7 +6,7 @@ #include <lib/dvb_si/bat.h> #include <lib/dvb/db.h> -class eDVBScan: public Object +class eDVBScan: public Object, public virtual iObject { /* chid helper functions: */ diff --git a/lib/dvb/sec.cpp b/lib/dvb/sec.cpp index 99e39ea6..b3c4b2cc 100644 --- a/lib/dvb/sec.cpp +++ b/lib/dvb/sec.cpp @@ -4,6 +4,10 @@ DEFINE_REF(eDVBSatelliteEquipmentControl); +eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(): ref(0) +{ +} + RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, struct dvb_frontend_parameters &parm, eDVBFrontendParametersSatellite &sat) { int hi; diff --git a/lib/dvb/sec.h b/lib/dvb/sec.h index e4b2d1d2..13aa9aa8 100644 --- a/lib/dvb/sec.h +++ b/lib/dvb/sec.h @@ -7,6 +7,7 @@ class eDVBSatelliteEquipmentControl: public iDVBSatelliteEquipmentControl { public: DECLARE_REF; + eDVBSatelliteEquipmentControl(); RESULT prepare(iDVBFrontend &frontend, struct dvb_frontend_parameters &parm, eDVBFrontendParametersSatellite &sat); }; diff --git a/lib/nav/core.cpp b/lib/nav/core.cpp index b5c229c7..9314d2c1 100644 --- a/lib/nav/core.cpp +++ b/lib/nav/core.cpp @@ -11,7 +11,11 @@ void eNavigation::serviceEvent(iPlayableService* service, int event) switch (event) { case iPlayableService::evEnd: - /* our running main service stopped. */ + /* at first, kill the running service */ + m_event(this, evStopService); + m_runningService = 0; + m_service_event_conn = 0; + /* our running main service stopped. remove it from playlist */ if (!m_playlist.empty()) m_playlist.erase(m_playlist.begin()); if (!m_playlist.empty()) @@ -33,6 +37,7 @@ void eNavigation::serviceEvent(iPlayableService* service, int event) RESULT eNavigation::playService(const eServiceReference &service) { + assert(m_servicehandler); RESULT res = m_servicehandler->play(service, m_runningService); if (m_runningService) { @@ -53,7 +58,7 @@ RESULT eNavigation::enqueueService(const eServiceReference &service) RESULT eNavigation::connectEvent(const Slot2<void,eNavigation*,int> &event, ePtr<eConnection> &connection) { - connection = new eConnection(m_event.connect(event)); + connection = new eConnection(this, m_event.connect(event)); return 0; } @@ -76,8 +81,9 @@ RESULT eNavigation::pause(int dop) return p->unpause(); } -eNavigation::eNavigation(iServiceHandler *serviceHandler) +eNavigation::eNavigation(iServiceHandler *serviceHandler): ref(0) { + assert(serviceHandler); m_servicehandler = serviceHandler; } diff --git a/lib/nav/core.h b/lib/nav/core.h index 056c150b..99cf75ae 100644 --- a/lib/nav/core.h +++ b/lib/nav/core.h @@ -19,7 +19,8 @@ private: public: enum { - evNewService, + evStopService, /** the "current" service was just stopped and likes to be deallocated (clear refs!) */ + evNewService, /** a new "current" service was just started */ evPlayFailed, evPlaylistDone }; diff --git a/lib/service/service.cpp b/lib/service/service.cpp index 99199aa9..6141516f 100644 --- a/lib/service/service.cpp +++ b/lib/service/service.cpp @@ -32,16 +32,22 @@ eString eServiceReference::toString() const eServiceCenter *eServiceCenter::instance; -eServiceCenter::eServiceCenter() +eServiceCenter::eServiceCenter(): ref(0) { if (!instance) + { + eDebug("settings instance."); instance = this; + } } eServiceCenter::~eServiceCenter() { if (instance == this) + { + eDebug("clear instance"); instance = 0; + } } DEFINE_REF(eServiceCenter); @@ -91,4 +97,4 @@ RESULT eServiceCenter::removeServiceFactory(int id) return 0; } -eAutoInitP0<eServiceCenter> init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter"); +eAutoInitPtr<eServiceCenter> init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter"); diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 62dbee54..199b58aa 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -166,4 +166,4 @@ RESULT eDVBServicePlay::getName(eString &name) DEFINE_REF(eDVBServicePlay) -eAutoInitP0<eServiceFactoryDVB> init_eServiceFactoryDVB(eAutoInitNumbers::service+1, "eServiceFactoryDVB"); +eAutoInitPtr<eServiceFactoryDVB> init_eServiceFactoryDVB(eAutoInitNumbers::service+1, "eServiceFactoryDVB"); diff --git a/lib/service/servicefs.cpp b/lib/service/servicefs.cpp index ad40f0af..91ae44e3 100644 --- a/lib/service/servicefs.cpp +++ b/lib/service/servicefs.cpp @@ -109,4 +109,4 @@ RESULT eServiceFS::getContent(std::list<eServiceReference> &list) return 0; } -eAutoInitP0<eServiceFactoryFS> init_eServiceFactoryFS(eAutoInitNumbers::service+1, "eServiceFactoryFS"); +eAutoInitPtr<eServiceFactoryFS> init_eServiceFactoryFS(eAutoInitNumbers::service+1, "eServiceFactoryFS"); diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 27ae1147..a6d19287 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -61,10 +61,12 @@ void eServiceMP3::test_end() eServiceMP3::eServiceMP3(const char *filename): ref(0), filename(filename), test(eApp) { m_state = stIdle; + eDebug("SERVICEMP3 construct!"); } eServiceMP3::~eServiceMP3() { + eDebug("SERVICEMP3 destruct!"); if (m_state == stRunning) stop(); } @@ -73,7 +75,7 @@ DEFINE_REF(eServiceMP3); RESULT eServiceMP3::connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection) { - connection = new eConnection(m_event.connect(event)); + connection = new eConnection(this, m_event.connect(event)); return 0; } @@ -85,7 +87,7 @@ RESULT eServiceMP3::start() printf("mp3 starts\n"); printf("MP3: %s start\n", filename.c_str()); - test.start(10000, 1); + test.start(1000, 1); CONNECT(test.timeout, eServiceMP3::test_end); m_event(this, evStart); return 0; @@ -109,7 +111,12 @@ RESULT eServiceMP3::getIPausableService(ePtr<iPauseableService> &ptr) { ptr=this RESULT eServiceMP3::pause() { printf("mp3 pauses!\n"); return 0; } RESULT eServiceMP3::unpause() { printf("mp3 unpauses!\n"); return 0; } -RESULT eServiceMP3::getIServiceInformation(ePtr<iServiceInformation>&) { return -1; } +RESULT eServiceMP3::getIServiceInformation(ePtr<iServiceInformation>&i) { i = this; return 0; } +RESULT eServiceMP3::getName(eString &name) +{ + name = "MP3 File: " + filename; + return 0; +} -eAutoInitP0<eServiceFactoryMP3> init_eServiceFactoryMP3(eAutoInitNumbers::service+1, "eServiceFactoryMP3"); +eAutoInitPtr<eServiceFactoryMP3> init_eServiceFactoryMP3(eAutoInitNumbers::service+1, "eServiceFactoryMP3"); diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h index b443d6eb..d51207ff 100644 --- a/lib/service/servicemp3.h +++ b/lib/service/servicemp3.h @@ -17,7 +17,7 @@ public: RESULT list(const eServiceReference &, ePtr<iListableService> &ptr); }; -class eServiceMP3: public virtual iPlayableService, public virtual iPauseableService, public virtual iObject, public Object +class eServiceMP3: public virtual iPlayableService, public virtual iPauseableService, public virtual iServiceInformation, public virtual iObject, public Object { DECLARE_REF; private: @@ -46,6 +46,9 @@ public: RESULT unpause(); RESULT getIServiceInformation(ePtr<iServiceInformation>&); + + // iServiceInformation + RESULT getName(eString &name); }; #endif diff --git a/main/enigma.cpp b/main/enigma.cpp index 4cc8eaf9..668c7c5a 100644 --- a/main/enigma.cpp +++ b/main/enigma.cpp @@ -27,6 +27,7 @@ class eMain: public eApplication, public Object ePtr<iPlayableService> m_playservice; ePtr<eNavigation> m_nav; ePtr<eConnection> m_conn_event; + ePtr<iServiceInformation> m_serviceInformation; public: eMain() { @@ -38,8 +39,9 @@ public: ePtr<eServiceCenter> service_center; eServiceCenter::getInstance(service_center); + assert(service_center); m_nav = new eNavigation(service_center); -#if 1 +#if 0 if (service_center) { eServiceReference ref("2:0:1:0:0:0:0:0:0:0:/"); @@ -79,6 +81,11 @@ public: { switch (ev) { + case eNavigation::evStopService: + /* very important: the old service should be deallocated, so clear *all* references to it */ + m_serviceInformation = 0; + eDebug("STOP service!"); + break; case eNavigation::evNewService: { ePtr<iPlayableService> service; @@ -88,14 +95,13 @@ public: eDebug("no running service!"); break; } - ePtr<iServiceInformation> s; - if (service->getIServiceInformation(s)) + if (service->getIServiceInformation(m_serviceInformation)) { eDebug("failed to get iserviceinformation"); break; } eString name; - s->getName(name); + m_serviceInformation->getName(name); eDebug("NEW running service: %s", name.c_str()); break; } @@ -104,6 +110,7 @@ public: break; case eNavigation::evPlaylistDone: eDebug("playlist done"); + quit(); break; default: eDebug("Navigation event %d", ev); @@ -113,7 +120,6 @@ public: ~eMain() { - } }; @@ -127,10 +133,11 @@ void object_dump() #endif int main() -{ +{ #ifdef OBJECT_DEBUG atexit(object_dump); #endif eMain app; - return app.exec(); + int res = app.exec(); + eDebug("after exec"); } |
