fix memleak
[enigma2.git] / lib / nav / core.cpp
index c9dcb5022ec6eaa611fb6f1fee961d6f9f5ca17e..45771f1544a5583339a78f96f427f79b3b70940c 100644 (file)
@@ -1,4 +1,5 @@
 #include <lib/nav/core.h>
 #include <lib/nav/core.h>
+#include <lib/base/eerror.h>
 
 void eNavigation::serviceEvent(iPlayableService* service, int event)
 {
 
 void eNavigation::serviceEvent(iPlayableService* service, int event)
 {
@@ -13,11 +14,10 @@ void eNavigation::serviceEvent(iPlayableService* service, int event)
        case iPlayableService::evEnd:
                assert(m_playlist); /* we need to have a playlist */
                
        case iPlayableService::evEnd:
                assert(m_playlist); /* we need to have a playlist */
                
-                       /* at first, kill the running service */
-               m_event(this, evStopService);
-               m_runningService = 0;
-               m_service_event_conn = 0;
-                       /* our running main service stopped. identify what to do next. */
+               /* at first, kill the running service */
+               stopService();
+               
+               /* our running main service stopped. identify what to do next. */
                        
                        /* unless the playlist current position is invalid (because there was */
                        /* playlist, for example when the service was engaged with playService */
                        
                        /* unless the playlist current position is invalid (because there was */
                        /* playlist, for example when the service was engaged with playService */
@@ -40,6 +40,9 @@ void eNavigation::serviceEvent(iPlayableService* service, int event)
        case iPlayableService::evStart:
                m_event(this, evNewService);
                break;
        case iPlayableService::evStart:
                m_event(this, evNewService);
                break;
+       case iPlayableService::evUpdatedEventInfo:
+               m_event(this, evUpdatedEventInfo);
+               break;
        default:
                break;
        }
        default:
                break;
        }
@@ -47,6 +50,8 @@ void eNavigation::serviceEvent(iPlayableService* service, int event)
 
 RESULT eNavigation::playService(const eServiceReference &service)
 {
 
 RESULT eNavigation::playService(const eServiceReference &service)
 {
+       stopService();
+       
        assert(m_servicehandler);
        RESULT res = m_servicehandler->play(service, m_runningService);
        if (m_runningService)
        assert(m_servicehandler);
        RESULT res = m_servicehandler->play(service, m_runningService);
        if (m_runningService)
@@ -96,12 +101,36 @@ RESULT eNavigation::getPlaylist(ePtr<ePlaylist> &playlist)
        return 0;
 }
 
        return 0;
 }
 
+RESULT eNavigation::stopService(void)
+{
+               /* check if there is a running service... */
+       if (!m_runningService)
+               return 1;
+                       /* send stop event */
+       m_event(this, evStopService);
+
+               /* kill service. */
+       m_runningService = 0;
+       m_service_event_conn = 0;
+       return 0;
+}
+
+RESULT eNavigation::recordService(const eServiceReference &ref, ePtr<iRecordableService> &service)
+{
+       assert(m_servicehandler);
+       RESULT res = m_servicehandler->record(ref, service);
+       eDebug("record: %d", res);
+       if (res)
+               service = 0;
+       return res;
+}
+
 RESULT eNavigation::pause(int dop)
 {
        if (!m_runningService)
                return -1;
        ePtr<iPauseableService> p;
 RESULT eNavigation::pause(int dop)
 {
        if (!m_runningService)
                return -1;
        ePtr<iPauseableService> p;
-       if (m_runningService->getIPausableService(p))
+       if (m_runningService->pause(p))
                return -2;
        if (dop)
                return p->pause();
                return -2;
        if (dop)
                return p->pause();
@@ -109,7 +138,7 @@ RESULT eNavigation::pause(int dop)
                return p->unpause();
 }
 
                return p->unpause();
 }
 
-eNavigation::eNavigation(iServiceHandler *serviceHandler): ref(0)
+eNavigation::eNavigation(iServiceHandler *serviceHandler)
 {
        assert(serviceHandler);
        m_servicehandler = serviceHandler;
 {
        assert(serviceHandler);
        m_servicehandler = serviceHandler;