X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/c0f5089ea04bd04fe25148e712fa62cd49dc17da..d86dfb91c834be43d9bcddd69ddbc7e463825fbd:/lib/service/servicemp3.cpp diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 27ae1147..dc038a85 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -9,20 +9,22 @@ // eServiceFactoryMP3 -eServiceFactoryMP3::eServiceFactoryMP3(): ref(0) +eServiceFactoryMP3::eServiceFactoryMP3() { ePtr sc; - eServiceCenter::getInstance(sc); + eServiceCenter::getPrivInstance(sc); if (sc) sc->addServiceFactory(eServiceFactoryMP3::id, this); + + m_service_info = new eStaticServiceMP3Info(); } eServiceFactoryMP3::~eServiceFactoryMP3() { ePtr sc; - eServiceCenter::getInstance(sc); + eServiceCenter::getPrivInstance(sc); if (sc) sc->removeServiceFactory(eServiceFactoryMP3::id); } @@ -49,8 +51,47 @@ RESULT eServiceFactoryMP3::list(const eServiceReference &, ePtr &ptr) +{ + ptr = m_service_info; + return 0; +} + +RESULT eServiceFactoryMP3::offlineOperations(const eServiceReference &, ePtr &ptr) +{ + ptr = 0; + return -1; +} + + +// eStaticServiceMP3Info + +// eStaticServiceMP3Info is seperated from eServiceMP3 to give information +// about unopened files. + +// probably eServiceMP3 should use this class as well, and eStaticServiceMP3Info +// should have a database backend where ID3-files etc. are cached. +// this would allow listing the mp3 database based on certain filters. + +DEFINE_REF(eStaticServiceMP3Info) + +eStaticServiceMP3Info::eStaticServiceMP3Info() +{ +} + +RESULT eStaticServiceMP3Info::getName(const eServiceReference &ref, std::string &name) +{ + name = "MP3 file: " + ref.path; + return 0; +} + +int eStaticServiceMP3Info::getLength(const eServiceReference &ref) +{ + return -1; +} + +// eServiceMP3 void eServiceMP3::test_end() { @@ -58,13 +99,15 @@ void eServiceMP3::test_end() stop(); } -eServiceMP3::eServiceMP3(const char *filename): ref(0), filename(filename), test(eApp) +eServiceMP3::eServiceMP3(const char *filename): filename(filename), test(eApp) { m_state = stIdle; + eDebug("SERVICEMP3 construct!"); } eServiceMP3::~eServiceMP3() { + eDebug("SERVICEMP3 destruct!"); if (m_state == stRunning) stop(); } @@ -73,7 +116,7 @@ DEFINE_REF(eServiceMP3); RESULT eServiceMP3::connectEvent(const Slot2 &event, ePtr &connection) { - connection = new eConnection(m_event.connect(event)); + connection = new eConnection((iPlayableService*)this, m_event.connect(event)); return 0; } @@ -85,7 +128,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; @@ -103,13 +146,21 @@ RESULT eServiceMP3::stop() return 0; } -RESULT eServiceMP3::getIPausableService(ePtr &ptr) { ptr=this; return 0; } +RESULT eServiceMP3::pause(ePtr &ptr) { ptr=this; return 0; } +RESULT eServiceMP3::seek(ePtr &ptr) { ptr = 0; return -1; } + +RESULT eServiceMP3::audioTracks(ePtr &ptr) { ptr = 0; return -1; }; // iPausableService RESULT eServiceMP3::pause() { printf("mp3 pauses!\n"); return 0; } RESULT eServiceMP3::unpause() { printf("mp3 unpauses!\n"); return 0; } -RESULT eServiceMP3::getIServiceInformation(ePtr&) { return -1; } +RESULT eServiceMP3::info(ePtr&i) { i = this; return 0; } +RESULT eServiceMP3::getName(std::string &name) +{ + name = "MP3 File: " + filename; + return 0; +} -eAutoInitP0 init_eServiceFactoryMP3(eAutoInitNumbers::service+1, "eServiceFactoryMP3"); +eAutoInitPtr init_eServiceFactoryMP3(eAutoInitNumbers::service+1, "eServiceFactoryMP3");