2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2017-01-03 20:48:59 +01:00
|
|
|
* Copyright 2003-2017 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2004-02-24 00:41:20 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2004-02-24 00:41:20 +01:00
|
|
|
*/
|
|
|
|
|
2009-11-12 09:12:38 +01:00
|
|
|
#include "config.h"
|
2013-01-07 10:55:05 +01:00
|
|
|
#include "Playlist.hxx"
|
2016-03-10 20:10:14 +01:00
|
|
|
#include "Listener.hxx"
|
2013-09-27 22:31:24 +02:00
|
|
|
#include "PlaylistError.hxx"
|
2015-08-15 15:55:46 +02:00
|
|
|
#include "player/Control.hxx"
|
2014-01-07 21:39:47 +01:00
|
|
|
#include "DetachedSong.hxx"
|
2013-09-27 22:31:24 +02:00
|
|
|
#include "Log.hxx"
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-12-29 17:28:32 +01:00
|
|
|
#include <assert.h>
|
2004-06-05 03:14:37 +02:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
void
|
2014-01-07 21:39:47 +01:00
|
|
|
playlist::TagModified(DetachedSong &&song)
|
2009-01-20 22:49:19 +01:00
|
|
|
{
|
2014-01-07 21:39:47 +01:00
|
|
|
if (!playing)
|
2009-01-20 22:49:19 +01:00
|
|
|
return;
|
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
assert(current >= 0);
|
2009-01-23 00:09:26 +01:00
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
DetachedSong ¤t_song = queue.GetOrder(current);
|
|
|
|
if (song.IsSame(current_song))
|
2016-02-23 21:01:55 +01:00
|
|
|
current_song.MoveTagItemsFrom(std::move(song));
|
2013-10-21 23:22:16 +02:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.ModifyAtOrder(current);
|
2016-03-10 20:03:01 +01:00
|
|
|
OnModified();
|
2009-01-20 22:49:19 +01:00
|
|
|
}
|
|
|
|
|
2014-11-26 08:34:51 +01:00
|
|
|
inline void
|
|
|
|
playlist::QueueSongOrder(PlayerControl &pc, unsigned order)
|
|
|
|
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2014-11-26 08:34:51 +01:00
|
|
|
assert(queue.IsValidOrder(order));
|
2009-01-04 19:09:34 +01:00
|
|
|
|
2014-11-26 08:34:51 +01:00
|
|
|
queued = order;
|
2009-01-04 19:09:34 +01:00
|
|
|
|
2014-11-26 08:34:51 +01:00
|
|
|
const DetachedSong &song = queue.GetOrder(order);
|
2012-08-09 22:19:39 +02:00
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
FormatDebug(playlist_domain, "queue song %i:\"%s\"",
|
2014-11-26 08:34:51 +01:00
|
|
|
queued, song.GetURI());
|
2009-01-23 00:06:54 +01:00
|
|
|
|
2015-11-11 16:50:57 +01:00
|
|
|
pc.LockEnqueueSong(new DetachedSong(song));
|
2009-01-23 00:06:54 +01:00
|
|
|
}
|
2009-01-04 19:09:34 +01:00
|
|
|
|
2014-11-26 08:49:19 +01:00
|
|
|
void
|
|
|
|
playlist::SongStarted()
|
|
|
|
{
|
|
|
|
assert(current >= 0);
|
2014-11-26 08:54:16 +01:00
|
|
|
|
|
|
|
/* reset a song's "priority" when playback starts */
|
|
|
|
if (queue.SetPriority(queue.OrderToPosition(current), 0, -1, false))
|
|
|
|
OnModified();
|
2014-11-26 08:49:19 +01:00
|
|
|
}
|
|
|
|
|
2014-11-25 19:21:22 +01:00
|
|
|
inline void
|
|
|
|
playlist::QueuedSongStarted(PlayerControl &pc)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-10-19 18:48:38 +02:00
|
|
|
assert(pc.next_song == nullptr);
|
2014-11-25 19:21:22 +01:00
|
|
|
assert(queued >= -1);
|
2014-11-26 08:25:48 +01:00
|
|
|
assert(current >= 0);
|
2009-01-23 07:33:15 +01:00
|
|
|
|
2010-06-19 13:33:32 +02:00
|
|
|
/* queued song has started: copy queued to current,
|
|
|
|
and notify the clients */
|
2010-06-01 09:59:46 +02:00
|
|
|
|
2014-11-25 19:21:22 +01:00
|
|
|
const int old_current = current;
|
|
|
|
current = queued;
|
|
|
|
queued = -1;
|
2010-05-31 23:32:11 +02:00
|
|
|
|
2014-11-25 19:21:22 +01:00
|
|
|
if (queue.consume)
|
|
|
|
DeleteOrder(pc, old_current);
|
2010-06-19 13:33:32 +02:00
|
|
|
|
2016-03-10 20:10:14 +01:00
|
|
|
listener.OnQueueSongStarted();
|
2014-11-26 08:49:19 +01:00
|
|
|
|
|
|
|
SongStarted();
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
const DetachedSong *
|
2013-01-07 10:55:05 +01:00
|
|
|
playlist::GetQueuedSong() const
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
return playing && queued >= 0
|
2013-10-19 18:48:38 +02:00
|
|
|
? &queue.GetOrder(queued)
|
2013-01-07 10:55:05 +01:00
|
|
|
: nullptr;
|
2009-02-04 18:52:37 +01:00
|
|
|
}
|
|
|
|
|
2009-02-04 20:31:22 +01:00
|
|
|
void
|
2014-01-07 21:39:47 +01:00
|
|
|
playlist::UpdateQueuedSong(PlayerControl &pc, const DetachedSong *prev)
|
2009-02-04 18:52:37 +01:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (!playing)
|
2009-02-04 18:52:37 +01:00
|
|
|
return;
|
|
|
|
|
2014-07-11 20:01:53 +02:00
|
|
|
if (prev == nullptr && bulk_edit)
|
|
|
|
/* postponed until CommitBulk() to avoid always
|
|
|
|
queueing the first song that is being added (in
|
|
|
|
random mode) */
|
|
|
|
return;
|
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
assert(!queue.IsEmpty());
|
2013-10-02 08:13:28 +02:00
|
|
|
assert((queued < 0) == (prev == nullptr));
|
2009-02-04 18:52:37 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
const int next_order = current >= 0
|
|
|
|
? queue.GetNextOrder(current)
|
2009-02-04 18:52:37 +01:00
|
|
|
: 0;
|
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
if (next_order == 0 && queue.random && !queue.single) {
|
2009-02-04 18:52:37 +01:00
|
|
|
/* shuffle the song order again, so we get a different
|
|
|
|
order each time the playlist is played
|
|
|
|
completely */
|
2013-01-07 10:55:05 +01:00
|
|
|
const unsigned current_position =
|
|
|
|
queue.OrderToPosition(current);
|
2009-02-04 18:52:37 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.ShuffleOrder();
|
2009-02-04 18:52:37 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
/* make sure that the current still points to
|
2009-02-04 18:52:37 +01:00
|
|
|
the current song, after the song order has been
|
|
|
|
shuffled */
|
2013-01-07 10:55:05 +01:00
|
|
|
current = queue.PositionToOrder(current_position);
|
2009-02-04 18:52:37 +01:00
|
|
|
}
|
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
const DetachedSong *const next_song = next_order >= 0
|
2013-10-19 18:48:38 +02:00
|
|
|
? &queue.GetOrder(next_order)
|
2013-01-07 10:55:05 +01:00
|
|
|
: nullptr;
|
2009-02-04 18:52:37 +01:00
|
|
|
|
2013-10-02 08:13:28 +02:00
|
|
|
if (prev != nullptr && next_song != prev) {
|
2009-02-04 18:52:37 +01:00
|
|
|
/* clear the currently queued song */
|
2015-11-11 16:50:57 +01:00
|
|
|
pc.LockCancel();
|
2013-01-07 10:55:05 +01:00
|
|
|
queued = -1;
|
2009-02-04 18:52:37 +01:00
|
|
|
}
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:52:37 +01:00
|
|
|
if (next_order >= 0) {
|
|
|
|
if (next_song != prev)
|
2014-11-26 08:34:51 +01:00
|
|
|
QueueSongOrder(pc, next_order);
|
2009-02-04 18:52:37 +01:00
|
|
|
else
|
2013-01-07 10:55:05 +01:00
|
|
|
queued = next_order;
|
2009-02-04 18:52:37 +01:00
|
|
|
}
|
2008-04-12 06:11:56 +02:00
|
|
|
}
|
|
|
|
|
2016-09-08 10:29:49 +02:00
|
|
|
void
|
|
|
|
playlist::PlayOrder(PlayerControl &pc, unsigned order)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
playing = true;
|
|
|
|
queued = -1;
|
2007-12-28 03:56:25 +01:00
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
const DetachedSong &song = queue.GetOrder(order);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2016-03-18 17:49:29 +01:00
|
|
|
FormatDebug(playlist_domain, "play %u:\"%s\"", order, song.GetURI());
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
current = order;
|
2014-11-26 08:49:19 +01:00
|
|
|
|
2016-09-08 10:29:49 +02:00
|
|
|
pc.Play(new DetachedSong(song));
|
2015-11-11 19:57:37 +01:00
|
|
|
|
2014-11-26 08:49:19 +01:00
|
|
|
SongStarted();
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2013-10-28 10:12:21 +01:00
|
|
|
playlist::SyncWithPlayer(PlayerControl &pc)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (!playing)
|
2009-01-23 07:33:15 +01:00
|
|
|
/* this event has reached us out of sync: we aren't
|
|
|
|
playing anymore; ignore the event */
|
2006-07-20 18:02:40 +02:00
|
|
|
return;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2013-01-20 17:48:23 +01:00
|
|
|
pc.Lock();
|
2013-09-27 22:07:20 +02:00
|
|
|
const PlayerState pc_state = pc.GetState();
|
2014-01-07 21:39:47 +01:00
|
|
|
const DetachedSong *pc_next_song = pc.next_song;
|
2013-01-20 17:48:23 +01:00
|
|
|
pc.Unlock();
|
2010-06-19 13:15:42 +02:00
|
|
|
|
2013-09-27 22:07:20 +02:00
|
|
|
if (pc_state == PlayerState::STOP)
|
2009-01-23 07:33:15 +01:00
|
|
|
/* the player thread has stopped: check if playback
|
|
|
|
should be restarted with the next song. That can
|
|
|
|
happen if the playlist isn't filling the queue fast
|
|
|
|
enough */
|
2014-11-26 08:34:51 +01:00
|
|
|
ResumePlayback(pc);
|
2008-08-26 08:27:18 +02:00
|
|
|
else {
|
2009-01-23 07:33:15 +01:00
|
|
|
/* check if the player thread has already started
|
|
|
|
playing the queued song */
|
2013-01-07 10:55:05 +01:00
|
|
|
if (pc_next_song == nullptr && queued != -1)
|
2014-11-25 19:21:22 +01:00
|
|
|
QueuedSongStarted(pc);
|
2009-01-23 07:33:15 +01:00
|
|
|
|
2013-01-20 17:48:23 +01:00
|
|
|
pc.Lock();
|
2013-01-07 10:55:05 +01:00
|
|
|
pc_next_song = pc.next_song;
|
2013-01-20 17:48:23 +01:00
|
|
|
pc.Unlock();
|
2012-08-15 22:47:08 +02:00
|
|
|
|
2009-01-23 07:33:15 +01:00
|
|
|
/* make sure the queued song is always set (if
|
|
|
|
possible) */
|
2013-01-07 10:55:05 +01:00
|
|
|
if (pc_next_song == nullptr && queued < 0)
|
|
|
|
UpdateQueuedSong(pc, nullptr);
|
2008-08-26 08:27:18 +02:00
|
|
|
}
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2014-11-26 08:34:51 +01:00
|
|
|
inline void
|
|
|
|
playlist::ResumePlayback(PlayerControl &pc)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2014-11-26 08:34:51 +01:00
|
|
|
assert(playing);
|
2013-10-19 18:48:38 +02:00
|
|
|
assert(pc.GetState() == PlayerState::STOP);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2013-10-19 18:48:38 +02:00
|
|
|
const auto error = pc.GetErrorType();
|
2013-09-27 22:07:20 +02:00
|
|
|
if (error == PlayerError::NONE)
|
2014-11-26 08:34:51 +01:00
|
|
|
error_count = 0;
|
2009-01-23 06:40:52 +01:00
|
|
|
else
|
2014-11-26 08:34:51 +01:00
|
|
|
++error_count;
|
2009-01-23 06:40:52 +01:00
|
|
|
|
2014-11-26 08:34:51 +01:00
|
|
|
if ((stop_on_error && error != PlayerError::NONE) ||
|
2013-09-27 22:07:20 +02:00
|
|
|
error == PlayerError::OUTPUT ||
|
2014-11-26 08:34:51 +01:00
|
|
|
error_count >= queue.GetLength())
|
2009-01-23 07:33:15 +01:00
|
|
|
/* too many errors, or critical error: stop
|
|
|
|
playback */
|
2014-11-26 08:34:51 +01:00
|
|
|
Stop(pc);
|
2009-01-23 06:40:52 +01:00
|
|
|
else
|
2009-01-23 07:33:15 +01:00
|
|
|
/* continue playback at the next song */
|
2016-09-08 10:29:49 +02:00
|
|
|
try {
|
|
|
|
PlayNext(pc);
|
|
|
|
} catch (...) {
|
|
|
|
/* TODO: log error? */
|
|
|
|
}
|
2009-03-30 00:01:02 +02:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2013-10-28 10:12:21 +01:00
|
|
|
playlist::SetRepeat(PlayerControl &pc, bool status)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (status == queue.repeat)
|
2009-01-23 00:07:20 +01:00
|
|
|
return;
|
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.repeat = status;
|
2012-08-25 08:44:31 +02:00
|
|
|
|
2015-11-11 16:50:57 +01:00
|
|
|
pc.LockSetBorderPause(queue.single && !queue.repeat);
|
2008-10-14 22:38:14 +02:00
|
|
|
|
2009-02-04 18:52:37 +01:00
|
|
|
/* if the last song is currently being played, the "next song"
|
|
|
|
might change when repeat mode is toggled */
|
2013-01-07 10:55:05 +01:00
|
|
|
UpdateQueuedSong(pc, GetQueuedSong());
|
2009-02-04 18:52:37 +01:00
|
|
|
|
2016-03-10 20:10:14 +01:00
|
|
|
listener.OnQueueOptionsChanged();
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
static void
|
2013-10-19 18:48:38 +02:00
|
|
|
playlist_order(playlist &playlist)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-10-19 18:48:38 +02:00
|
|
|
if (playlist.current >= 0)
|
2009-01-23 07:33:15 +01:00
|
|
|
/* update playlist.current, order==position now */
|
2013-10-19 18:48:38 +02:00
|
|
|
playlist.current = playlist.queue.OrderToPosition(playlist.current);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2013-10-19 18:48:38 +02:00
|
|
|
playlist.queue.RestoreOrder();
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2013-10-28 10:12:21 +01:00
|
|
|
playlist::SetSingle(PlayerControl &pc, bool status)
|
2009-03-27 14:42:55 +01:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (status == queue.single)
|
2009-03-27 15:28:49 +01:00
|
|
|
return;
|
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.single = status;
|
2012-08-25 08:44:31 +02:00
|
|
|
|
2015-11-11 16:50:57 +01:00
|
|
|
pc.LockSetBorderPause(queue.single && !queue.repeat);
|
2009-03-27 14:42:55 +01:00
|
|
|
|
|
|
|
/* if the last song is currently being played, the "next song"
|
2009-03-27 15:28:49 +01:00
|
|
|
might change when single mode is toggled */
|
2013-01-07 10:55:05 +01:00
|
|
|
UpdateQueuedSong(pc, GetQueuedSong());
|
2009-03-27 14:42:55 +01:00
|
|
|
|
2016-03-10 20:10:14 +01:00
|
|
|
listener.OnQueueOptionsChanged();
|
2009-03-27 14:42:55 +01:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2013-01-07 10:55:05 +01:00
|
|
|
playlist::SetConsume(bool status)
|
2009-03-30 00:01:02 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (status == queue.consume)
|
2009-03-30 00:01:02 +02:00
|
|
|
return;
|
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.consume = status;
|
2016-03-10 20:10:14 +01:00
|
|
|
listener.OnQueueOptionsChanged();
|
2009-03-30 00:01:02 +02:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2013-10-28 10:12:21 +01:00
|
|
|
playlist::SetRandom(PlayerControl &pc, bool status)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (status == queue.random)
|
2008-10-08 11:05:02 +02:00
|
|
|
return;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
const DetachedSong *const queued_song = GetQueuedSong();
|
2009-01-23 00:07:10 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.random = status;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
if (queue.random) {
|
|
|
|
/* shuffle the queue order, but preserve current */
|
2009-01-23 07:33:15 +01:00
|
|
|
|
2014-07-11 19:41:39 +02:00
|
|
|
const int current_position = playing
|
|
|
|
? GetCurrentPosition()
|
|
|
|
: -1;
|
2009-01-23 00:08:40 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.ShuffleOrder();
|
2009-01-23 00:08:40 +01:00
|
|
|
|
|
|
|
if (current_position >= 0) {
|
2009-01-23 07:33:15 +01:00
|
|
|
/* make sure the current song is the first in
|
|
|
|
the order list, so the whole rest of the
|
|
|
|
playlist is played after that */
|
2009-01-23 00:08:40 +01:00
|
|
|
unsigned current_order =
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.PositionToOrder(current_position);
|
Fix for priority order bug if reordering in SetRandom()
Fix for the problem where order with priorities gets out of whack in case it's
reordered by SetRandom() while another song is currently playing.
What happens is, if some song is already playing and you have set some
priorities before switching on the random mode, and then turn the mode on, the
original code swaps position of the first song in the order (i.e., the highest
priority song) with current, so that current is 0 (which it should be). The
problem is, the "original" first song then goes to the place "current" song was
after reordering, wherever that is, instead of going after the "current" song.
This patch fixes the issue.
Also the fix makes MoveOrder() public, because why shouldn't it be, anyway. It
certainly makes more sense than just having SwapOrders() public for some
reason.
Signed-off-by: Eugene Baklanov <miltenfiremage@gmail.com>
2016-11-12 02:11:14 +01:00
|
|
|
queue.MoveOrder(current_order, 0);
|
2013-01-07 10:55:05 +01:00
|
|
|
current = 0;
|
2009-02-11 18:02:50 +01:00
|
|
|
} else
|
2013-01-07 10:55:05 +01:00
|
|
|
current = -1;
|
2008-10-08 11:05:02 +02:00
|
|
|
} else
|
2013-10-19 18:48:38 +02:00
|
|
|
playlist_order(*this);
|
2008-10-14 22:38:14 +02:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
UpdateQueuedSong(pc, queued_song);
|
2009-02-04 18:52:37 +01:00
|
|
|
|
2016-03-10 20:10:14 +01:00
|
|
|
listener.OnQueueOptionsChanged();
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
int
|
2013-01-07 10:55:05 +01:00
|
|
|
playlist::GetCurrentPosition() const
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
return current >= 0
|
|
|
|
? queue.OrderToPosition(current)
|
|
|
|
: -1;
|
2006-03-26 15:46:05 +02:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
int
|
2013-01-07 10:55:05 +01:00
|
|
|
playlist::GetNextPosition() const
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (current < 0)
|
|
|
|
return -1;
|
2006-03-26 15:46:05 +02:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
if (queue.single && queue.repeat)
|
|
|
|
return queue.OrderToPosition(current);
|
|
|
|
else if (queue.IsValidOrder(current + 1))
|
|
|
|
return queue.OrderToPosition(current + 1);
|
|
|
|
else if (queue.repeat)
|
|
|
|
return queue.OrderToPosition(0);
|
2006-03-26 15:46:05 +02:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
return -1;
|
2006-03-26 15:46:05 +02:00
|
|
|
}
|