aboutsummaryrefslogtreecommitdiff
path: root/lib/nav
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2004-05-27 11:43:17 +0000
committerFelix Domke <tmbinc@elitedvb.net>2004-05-27 11:43:17 +0000
commit4c54cecb6020cde399b564f17dacb048b937018a (patch)
treecf81f3b93e5e749acdc23a9ba529632d180e4567 /lib/nav
parent6bfb37ae9c010c866900239281d345efcdd611bd (diff)
downloadenigma2-4c54cecb6020cde399b564f17dacb048b937018a.tar.gz
enigma2-4c54cecb6020cde399b564f17dacb048b937018a.zip
add playlists
Diffstat (limited to 'lib/nav')
-rw-r--r--lib/nav/Makefile.am4
-rw-r--r--lib/nav/core.cpp56
-rw-r--r--lib/nav/core.h11
-rw-r--r--lib/nav/playlist.cpp7
-rw-r--r--lib/nav/playlist.h16
5 files changed, 76 insertions, 18 deletions
diff --git a/lib/nav/Makefile.am b/lib/nav/Makefile.am
index a180e0bc..90603693 100644
--- a/lib/nav/Makefile.am
+++ b/lib/nav/Makefile.am
@@ -4,5 +4,5 @@ INCLUDES = \
noinst_LIBRARIES = libenigma_nav.a
libenigma_nav_a_SOURCES = \
- core.cpp
-
+ core.cpp playlist.cpp
+
diff --git a/lib/nav/core.cpp b/lib/nav/core.cpp
index 9314d2c1..c9dcb502 100644
--- a/lib/nav/core.cpp
+++ b/lib/nav/core.cpp
@@ -11,21 +11,31 @@ void eNavigation::serviceEvent(iPlayableService* service, int event)
switch (event)
{
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. remove it from playlist */
- if (!m_playlist.empty())
- m_playlist.erase(m_playlist.begin());
- if (!m_playlist.empty())
+ /* 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())
{
- RESULT res;
- res = playService(m_playlist.front());
- if (res)
- m_event(this, evPlayFailed);
- } else
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);
@@ -49,10 +59,20 @@ RESULT eNavigation::playService(const eServiceReference &service)
RESULT eNavigation::enqueueService(const eServiceReference &service)
{
- int doplay = m_playlist.empty();
- m_playlist.push_back(service);
+ 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)
- return playService(m_playlist.front());
+ {
+ m_playlist->m_current = m_playlist->end();
+ --m_playlist->m_current;
+ return playService(*m_playlist->m_current);
+ }
return 0;
}
@@ -68,6 +88,14 @@ RESULT eNavigation::getCurrentService(ePtr<iPlayableService> &service)
return 0;
}
+RESULT eNavigation::getPlaylist(ePtr<ePlaylist> &playlist)
+{
+ if (!m_playlist)
+ return -1;
+ playlist = m_playlist;
+ return 0;
+}
+
RESULT eNavigation::pause(int dop)
{
if (!m_runningService)
@@ -85,6 +113,10 @@ eNavigation::eNavigation(iServiceHandler *serviceHandler): ref(0)
{
assert(serviceHandler);
m_servicehandler = serviceHandler;
+ m_playlist = new ePlaylist;
+
+ /* start with no current selection */
+ m_playlist->m_current = m_playlist->end();
}
eNavigation::~eNavigation()
diff --git a/lib/nav/core.h b/lib/nav/core.h
index 99cf75ae..db438412 100644
--- a/lib/nav/core.h
+++ b/lib/nav/core.h
@@ -3,6 +3,7 @@
#include <lib/base/object.h>
#include <lib/service/iservice.h>
+#include <lib/nav/playlist.h>
#include <connection.h>
class eNavigation: public iObject, public Object
@@ -15,20 +16,22 @@ private:
ePtr<eConnection> m_service_event_conn;
void serviceEvent(iPlayableService* service, int event);
- std::list<eServiceReference> m_playlist;
+ ePtr<ePlaylist> m_playlist;
public:
enum
{
evStopService, /** the "current" service was just stopped and likes to be deallocated (clear refs!) */
- evNewService, /** a new "current" service was just started */
- evPlayFailed,
- evPlaylistDone
+ evNewService, /** a new "current" service was just started */
+ evPlayFailed, /** the next service (in playlist) or the one given in playService failed to play */
+ evPlaylistDone /** the last service in the playlist was just played */
};
+
RESULT playService(const eServiceReference &service);
RESULT enqueueService(const eServiceReference &service);
RESULT connectEvent(const Slot2<void,eNavigation*,int> &event, ePtr<eConnection> &connection);
/* int connectServiceEvent(const Slot1<void,iPlayableService*,int> &event, ePtr<eConnection> &connection); */
RESULT getCurrentService(ePtr<iPlayableService> &service);
+ RESULT getPlaylist(ePtr<ePlaylist> &playlist);
RESULT pause(int p);
eNavigation(iServiceHandler *serviceHandler);
diff --git a/lib/nav/playlist.cpp b/lib/nav/playlist.cpp
new file mode 100644
index 00000000..48919922
--- /dev/null
+++ b/lib/nav/playlist.cpp
@@ -0,0 +1,7 @@
+#include <lib/nav/playlist.h>
+
+DEFINE_REF(ePlaylist);
+
+ePlaylist::ePlaylist(): ref(0)
+{
+}
diff --git a/lib/nav/playlist.h b/lib/nav/playlist.h
new file mode 100644
index 00000000..f07ecb4b
--- /dev/null
+++ b/lib/nav/playlist.h
@@ -0,0 +1,16 @@
+#ifndef __lib_nav_playlist_h
+#define __lib_nav_playlist_h
+
+#include <list>
+#include <lib/base/object.h>
+#include <lib/service/iservice.h>
+
+class ePlaylist: public virtual iObject, public std::list<eServiceReference>
+{
+DECLARE_REF;
+public:
+ ePlaylist();
+ std::list<eServiceReference>::iterator m_current;
+};
+
+#endif