X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/d63d2c3c6cbbd574dda4f8b00ebe6c661735edd5..cd621fe499141885e5a0d8b4e42a0f8a7f41a9ac:/lib/service/servicemp3.cpp diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index fb5993e4..d1c9001d 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -8,7 +9,7 @@ // eServiceFactoryMP3 -eServiceFactoryMP3::eServiceFactoryMP3(): ref(0) +eServiceFactoryMP3::eServiceFactoryMP3() { ePtr sc; @@ -31,15 +32,8 @@ DEFINE_REF(eServiceFactoryMP3) // iServiceHandler RESULT eServiceFactoryMP3::play(const eServiceReference &ref, ePtr &ptr) { - RESULT res; // check resources... ptr = new eServiceMP3(ref.path.c_str()); - res = ptr->start(); - if (res) - { - ptr = 0; - return res; - } return 0; } @@ -57,33 +51,72 @@ RESULT eServiceFactoryMP3::list(const eServiceReference &, ePtr &event, ePtr &connection) { - ++ref; + connection = new eConnection((iPlayableService*)this, m_event.connect(event)); + return 0; } -void eServiceMP3::Release() +RESULT eServiceMP3::start() { - if (!--ref) - delete this; + assert(m_state == stIdle); + + m_state = stRunning; + + printf("mp3 starts\n"); + printf("MP3: %s start\n", filename.c_str()); + test.start(1000, 1); + CONNECT(test.timeout, eServiceMP3::test_end); + m_event(this, evStart); + return 0; +} + +RESULT eServiceMP3::stop() +{ + assert(m_state != stIdle); + if (m_state == stStopped) + return -1; + test.stop(); + printf("MP3: %s stop\n", filename.c_str()); + m_state = stStopped; + m_event(this, evEnd); + return 0; } -RESULT eServiceMP3::start() { printf("mp3 starts\n"); return 0; } RESULT eServiceMP3::getIPausableService(ePtr &ptr) { ptr=this; return 0; } // iPausableService RESULT eServiceMP3::pause() { printf("mp3 pauses!\n"); return 0; } RESULT eServiceMP3::unpause() { printf("mp3 unpauses!\n"); return 0; } +RESULT eServiceMP3::getIServiceInformation(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");