- fixed dvb scan
[enigma2.git] / lib / service / servicemp3.cpp
index 27ae1147882a02d6bb5eeeda8a5cc006b031fdbb..1f883f944bfcf3632c83cba7098e37cb6da76b5b 100644 (file)
@@ -9,13 +9,15 @@
 
 // eServiceFactoryMP3
 
-eServiceFactoryMP3::eServiceFactoryMP3(): ref(0)
+eServiceFactoryMP3::eServiceFactoryMP3()
 {
        ePtr<eServiceCenter> sc;
        
        eServiceCenter::getInstance(sc);
        if (sc)
                sc->addServiceFactory(eServiceFactoryMP3::id, this);
+
+       m_service_info = new eServiceMP3Info();
 }
 
 eServiceFactoryMP3::~eServiceFactoryMP3()
@@ -49,22 +51,51 @@ RESULT eServiceFactoryMP3::list(const eServiceReference &, ePtr<iListableService
        return -1;
 }
 
-// eServiceMP3
+RESULT eServiceFactoryMP3::info(const eServiceReference &ref, ePtr<iServiceInformation> &ptr)
+{
+       ptr = m_service_info;
+       return 0;
+}
+
+// eServiceMP3Info
 
 
+// eServiceMP3Info is seperated from eServiceMP3 to give information
+// about unopened files.
+
+// probably eServiceMP3 should use this class as well, and eServiceMP3Info
+// should have a database backend where ID3-files etc. are cached.
+// this would allow listing the mp3 database based on certain filters.
+
+DEFINE_REF(eServiceMP3Info)
+
+eServiceMP3Info::eServiceMP3Info()
+{
+}
+
+RESULT eServiceMP3Info::getName(const eServiceReference &ref, std::string &name)
+{
+       name = "MP3 file: " + ref.path;
+       return 0;
+}
+
+// eServiceMP3
+
 void eServiceMP3::test_end()
 {
        eDebug("end of mp3!");
        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 +104,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((iPlayableService*)this, m_event.connect(event));
        return 0;
 }
 
@@ -85,7 +116,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 +140,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(const eServiceReference &ref, std::string &name)
+{
+       name = "MP3 File: " + filename;
+       return 0;
+}
 
-eAutoInitP0<eServiceFactoryMP3> init_eServiceFactoryMP3(eAutoInitNumbers::service+1, "eServiceFactoryMP3");
+eAutoInitPtr<eServiceFactoryMP3> init_eServiceFactoryMP3(eAutoInitNumbers::service+1, "eServiceFactoryMP3");