X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/1cdf6cb021fcaa6548b90ba7b6765cf1e8b8b37b..15f19734b17b024a43fa5045ac319f2647cb3b98:/lib/nav/core.cpp diff --git a/lib/nav/core.cpp b/lib/nav/core.cpp index 99dcf2ec..062a7d00 100644 --- a/lib/nav/core.cpp +++ b/lib/nav/core.cpp @@ -1,51 +1,25 @@ #include #include +#include void eNavigation::serviceEvent(iPlayableService* service, int event) { - if (service != m_runningService) + if (m_runningService && service != m_runningService) { - eDebug("nav: event for other service"); + eDebug("nav: event %d for other service", event); return; } + m_event(event); +} - switch (event) +void eNavigation::recordEvent(iRecordableService* service, int event) +{ + if (m_recordings.find(service) == m_recordings.end()) { - case iPlayableService::evEnd: - assert(m_playlist); /* we need to have a playlist */ - - /* 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 */ - if (m_playlist->m_current != m_playlist->end()) - ++m_playlist->m_current; - - /* was the current service the last one? */ - if (m_playlist->m_current == m_playlist->end()) - { - m_event(this, evPlaylistDone); - break; - } - - /* there is another service in the playlist. play it. */ - RESULT res; - res = playService(*m_playlist->m_current); - if (res) - m_event(this, evPlayFailed); - break; - case iPlayableService::evStart: - m_event(this, evNewService); - break; - case iPlayableService::evUpdatedEventInfo: - m_event(this, evUpdatedEventInfo); - break; - default: - break; + eDebug("nav: event for non registered recording service"); + return; } + m_record_event(service, event); } RESULT eNavigation::playService(const eServiceReference &service) @@ -62,28 +36,15 @@ RESULT eNavigation::playService(const eServiceReference &service) return res; } -RESULT eNavigation::enqueueService(const eServiceReference &service) +RESULT eNavigation::connectEvent(const Slot1 &event, ePtr &connection) { - assert(m_playlist); - /* check if we need to play after the service was enqueued. */ - int doplay = m_playlist->m_current == m_playlist->end(); - - /* add the service to the playlist. the playlist's m_current */ - /* points either to a service before the last or 'doplay' is set. */ - m_playlist->push_back(service); - - if (doplay) - { - m_playlist->m_current = m_playlist->end(); - --m_playlist->m_current; - return playService(*m_playlist->m_current); - } + connection = new eConnection(this, m_event.connect(event)); return 0; } -RESULT eNavigation::connectEvent(const Slot2 &event, ePtr &connection) +RESULT eNavigation::connectRecordEvent(const Slot2,int> &event, ePtr &connection) { - connection = new eConnection(this, m_event.connect(event)); + connection = new eConnection(this, m_record_event.connect(event)); return 0; } @@ -93,28 +54,66 @@ RESULT eNavigation::getCurrentService(ePtr &service) return 0; } -RESULT eNavigation::getPlaylist(ePtr &playlist) -{ - if (!m_playlist) - return -1; - playlist = m_playlist; - 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); + + ePtr tmp = m_runningService; + m_runningService=0; + tmp->stop(); + + /* send stop event */ + m_event(iPlayableService::evEnd); /* kill service. */ - m_runningService = 0; m_service_event_conn = 0; return 0; } +RESULT eNavigation::recordService(const eServiceReference &ref, ePtr &service) +{ + assert(m_servicehandler); + RESULT res = m_servicehandler->record(ref, service); + eDebug("record: %d", res); + if (res) + service = 0; + else + { + ePtr conn; + service->connectEvent(slot(*this, &eNavigation::recordEvent), conn); + m_recordings[service]=conn; + } + return res; +} + +RESULT eNavigation::stopRecordService(ePtr &service) +{ + service->stop(); + std::map, ePtr >::iterator it = + m_recordings.find(service); + if (it != m_recordings.end()) + { + m_recordings.erase(it); + /* send stop event */ + m_record_event(service, iRecordableService::evEnd); + return 0; + } + + eDebug("try to stop non running recording!!"); // this should not happen + return -1; +} + +PyObject *eNavigation::getRecordings(void) +{ + ePyObject result = PyList_New(m_recordings.size()); + int pos=0; + for (std::map, ePtr >::iterator it(m_recordings.begin()); it != m_recordings.end(); ++it) + PyList_SET_ITEM(result, pos++, NEW_iRecordableServicePtr(it->first)); + return result; +} + RESULT eNavigation::pause(int dop) { if (!m_runningService) @@ -132,14 +131,11 @@ eNavigation::eNavigation(iServiceHandler *serviceHandler) { assert(serviceHandler); m_servicehandler = serviceHandler; - m_playlist = new ePlaylist; - - /* start with no current selection */ - m_playlist->m_current = m_playlist->end(); } eNavigation::~eNavigation() { + stopService(); } DEFINE_REF(eNavigation);