summaryrefslogtreecommitdiff
path: root/src/lib/playlist.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-07-19 13:39:14 +0100
committerCarl Hetherington <cth@carlh.net>2013-07-19 13:39:14 +0100
commit3d9fdcf7e6a5d775a2688a071b69264b1a6971c7 (patch)
tree78d875336b2320d01d136c446343b9e90a68bf2e /src/lib/playlist.cc
parent86461ade4087f8473c1e8b063907d92884813843 (diff)
Allow repeat of multiple stuff.
Diffstat (limited to 'src/lib/playlist.cc')
-rw-r--r--src/lib/playlist.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index 31b16b646..e4494acb0 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -42,6 +42,7 @@ using std::min;
using std::max;
using std::string;
using std::stringstream;
+using std::pair;
using boost::optional;
using boost::shared_ptr;
using boost::weak_ptr;
@@ -291,14 +292,24 @@ Playlist::content () const
}
void
-Playlist::repeat (shared_ptr<Content> c, int n)
+Playlist::repeat (list<shared_ptr<Content> > c, int n)
{
- Time pos = c->end ();
+ pair<Time, Time> range (TIME_MAX, 0);
+ for (list<shared_ptr<Content> >::iterator i = c.begin(); i != c.end(); ++i) {
+ range.first = min (range.first, (*i)->start ());
+ range.second = max (range.second, (*i)->start ());
+ range.first = min (range.first, (*i)->end ());
+ range.second = max (range.second, (*i)->end ());
+ }
+
+ Time pos = range.second;
for (int i = 0; i < n; ++i) {
- shared_ptr<Content> copy = c->clone ();
- copy->set_start (pos);
- _content.push_back (copy);
- pos = copy->end ();
+ for (list<shared_ptr<Content> >::iterator i = c.begin(); i != c.end(); ++i) {
+ shared_ptr<Content> copy = (*i)->clone ();
+ copy->set_start (pos + copy->start() - range.first);
+ _content.push_back (copy);
+ }
+ pos += range.second - range.first;
}
reconnect ();