From 560742c100d86fb654a6959823a57396ee665cb1 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Thu, 7 Jun 2007 18:04:10 +0000 Subject: [PATCH] Adds AmPlaylistSeparator, which can be used to get notified in the Session when the playlist reaches a certain entry. git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@351 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmPlaylist.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/core/AmPlaylist.h b/core/AmPlaylist.h index 9433d3db..8798ea52 100644 --- a/core/AmPlaylist.h +++ b/core/AmPlaylist.h @@ -88,6 +88,43 @@ class AmPlaylist: public AmAudio void close(); }; +/** + * \brief event fired by the AmPlaylistSeparator + */ +class AmPlaylistSeparatorEvent : + public AmEvent { +public: + AmPlaylistSeparatorEvent(int id) + : AmEvent(id) { } +}; + +/** + * null-playlist element which notifies session that this position in + * playlist is reached. It fies a AmPlaylistSeparatorEvent if it is + * read or written. + */ +class AmPlaylistSeparator + : public AmAudio { + bool notified; + AmEventQueue* ev_q; + int id; +public: + AmPlaylistSeparator(AmEventQueue* q, int id) + : ev_q(q), notified(false), id(id) { } + ~AmPlaylistSeparator() { } + + int read(unsigned int user_ts, unsigned int size){ + if (!notified) + ev_q->postEvent(new AmPlaylistSeparatorEvent(id)); + notified = true; + return 0; + } + int write(unsigned int user_ts, unsigned int size){ + return read(user_ts, size); + } +}; + + #endif