playlist/Queue: add one-shot to single mode
This commit is contained in:
parent
1fb358249b
commit
1628d801f9
|
@ -947,6 +947,7 @@ endif
|
||||||
libbasic_a_SOURCES = \
|
libbasic_a_SOURCES = \
|
||||||
src/ReplayGainConfig.hxx \
|
src/ReplayGainConfig.hxx \
|
||||||
src/ReplayGainMode.cxx src/ReplayGainMode.hxx \
|
src/ReplayGainMode.cxx src/ReplayGainMode.hxx \
|
||||||
|
src/SingleMode.cxx src/SingleMode.hxx \
|
||||||
src/ReplayGainInfo.cxx src/ReplayGainInfo.hxx
|
src/ReplayGainInfo.cxx src/ReplayGainInfo.hxx
|
||||||
|
|
||||||
# configuration library
|
# configuration library
|
||||||
|
|
2
NEWS
2
NEWS
|
@ -5,6 +5,8 @@ ver 0.21 (not yet released)
|
||||||
- "outputs" prints the plugin name
|
- "outputs" prints the plugin name
|
||||||
- "outputset" sets runtime attributes
|
- "outputset" sets runtime attributes
|
||||||
- close connection when client sends HTTP request
|
- close connection when client sends HTTP request
|
||||||
|
* player
|
||||||
|
- "one-shot" single mode
|
||||||
* input
|
* input
|
||||||
- qobuz: new plugin to play Qobuz streams
|
- qobuz: new plugin to play Qobuz streams
|
||||||
- tidal: new plugin to play Tidal streams
|
- tidal: new plugin to play Tidal streams
|
||||||
|
|
|
@ -464,8 +464,8 @@
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<varname>single</varname>:
|
<varname>single</varname>:
|
||||||
<footnote id="since_0_15"><simpara>Introduced with <application>MPD</application> 0.15</simpara></footnote>
|
<footnote id="since_0_15"><simpara>Introduced with <application>MPD</application> 0.15 (oneshot introduced with 0.20)</simpara></footnote>
|
||||||
<returnvalue>0 or 1</returnvalue>
|
<returnvalue>0, 1, or oneshot</returnvalue>
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|
|
@ -109,6 +109,12 @@ Partition::SyncWithPlayer()
|
||||||
playlist.SyncWithPlayer(pc);
|
playlist.SyncWithPlayer(pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Partition::BorderPause()
|
||||||
|
{
|
||||||
|
playlist.BorderPause(pc);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Partition::OnQueueModified()
|
Partition::OnQueueModified()
|
||||||
{
|
{
|
||||||
|
@ -139,6 +145,12 @@ Partition::OnPlayerTagModified() noexcept
|
||||||
EmitGlobalEvent(TAG_MODIFIED);
|
EmitGlobalEvent(TAG_MODIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Partition::OnBorderPause() noexcept
|
||||||
|
{
|
||||||
|
EmitGlobalEvent(BORDER_PAUSE);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Partition::OnMixerVolumeChanged(gcc_unused Mixer &mixer, gcc_unused int volume)
|
Partition::OnMixerVolumeChanged(gcc_unused Mixer &mixer, gcc_unused int volume)
|
||||||
{
|
{
|
||||||
|
@ -156,4 +168,7 @@ Partition::OnGlobalEvent(unsigned mask)
|
||||||
|
|
||||||
if ((mask & TAG_MODIFIED) != 0)
|
if ((mask & TAG_MODIFIED) != 0)
|
||||||
TagModified();
|
TagModified();
|
||||||
|
|
||||||
|
if ((mask & BORDER_PAUSE) != 0)
|
||||||
|
BorderPause();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "player/Control.hxx"
|
#include "player/Control.hxx"
|
||||||
#include "player/Listener.hxx"
|
#include "player/Listener.hxx"
|
||||||
#include "ReplayGainMode.hxx"
|
#include "ReplayGainMode.hxx"
|
||||||
|
#include "SingleMode.hxx"
|
||||||
#include "Chrono.hxx"
|
#include "Chrono.hxx"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ class ClientListener;
|
||||||
struct Partition final : QueueListener, PlayerListener, MixerListener {
|
struct Partition final : QueueListener, PlayerListener, MixerListener {
|
||||||
static constexpr unsigned TAG_MODIFIED = 0x1;
|
static constexpr unsigned TAG_MODIFIED = 0x1;
|
||||||
static constexpr unsigned SYNC_WITH_PLAYER = 0x2;
|
static constexpr unsigned SYNC_WITH_PLAYER = 0x2;
|
||||||
|
static constexpr unsigned BORDER_PAUSE = 0x4;
|
||||||
|
|
||||||
Instance &instance;
|
Instance &instance;
|
||||||
|
|
||||||
|
@ -184,7 +186,7 @@ struct Partition final : QueueListener, PlayerListener, MixerListener {
|
||||||
playlist.SetRandom(pc, new_value);
|
playlist.SetRandom(pc, new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetSingle(bool new_value) {
|
void SetSingle(SingleMode new_value) {
|
||||||
playlist.SetSingle(pc, new_value);
|
playlist.SetSingle(pc, new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,6 +239,12 @@ struct Partition final : QueueListener, PlayerListener, MixerListener {
|
||||||
*/
|
*/
|
||||||
void SyncWithPlayer();
|
void SyncWithPlayer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border pause has just been enabled. Change single mode to off
|
||||||
|
* if it was one-shot.
|
||||||
|
*/
|
||||||
|
void BorderPause();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* virtual methods from class QueueListener */
|
/* virtual methods from class QueueListener */
|
||||||
void OnQueueModified() override;
|
void OnQueueModified() override;
|
||||||
|
@ -246,6 +254,7 @@ private:
|
||||||
/* virtual methods from class PlayerListener */
|
/* virtual methods from class PlayerListener */
|
||||||
void OnPlayerSync() noexcept override;
|
void OnPlayerSync() noexcept override;
|
||||||
void OnPlayerTagModified() noexcept override;
|
void OnPlayerTagModified() noexcept override;
|
||||||
|
void OnBorderPause() noexcept override;
|
||||||
|
|
||||||
/* virtual methods from class MixerListener */
|
/* virtual methods from class MixerListener */
|
||||||
void OnMixerVolumeChanged(Mixer &mixer, int volume) override;
|
void OnMixerVolumeChanged(Mixer &mixer, int volume) override;
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2003-2017 The Music Player Daemon Project
|
||||||
|
* http://www.musicpd.org
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "SingleMode.hxx"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
const char *
|
||||||
|
SingleToString(SingleMode mode) noexcept
|
||||||
|
{
|
||||||
|
switch (mode) {
|
||||||
|
case SingleMode::OFF:
|
||||||
|
return "0";
|
||||||
|
|
||||||
|
case SingleMode::ON:
|
||||||
|
return "1";
|
||||||
|
|
||||||
|
case SingleMode::ONE_SHOT:
|
||||||
|
return "oneshot";
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(false);
|
||||||
|
gcc_unreachable();
|
||||||
|
}
|
||||||
|
|
||||||
|
SingleMode
|
||||||
|
SingleFromString(const char *s)
|
||||||
|
{
|
||||||
|
assert(s != nullptr);
|
||||||
|
|
||||||
|
if (strcmp(s, "0") == 0)
|
||||||
|
return SingleMode::OFF;
|
||||||
|
else if (strcmp(s, "1") == 0)
|
||||||
|
return SingleMode::ON;
|
||||||
|
else if (strcmp(s, "oneshot") == 0)
|
||||||
|
return SingleMode::ONE_SHOT;
|
||||||
|
else
|
||||||
|
throw std::invalid_argument("Unrecognized single mode, expected 0, 1, or oneshot");
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2003-2017 The Music Player Daemon Project
|
||||||
|
* http://www.musicpd.org
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MPD_SINGLE_MODE_HXX
|
||||||
|
#define MPD_SINGLE_MODE_HXX
|
||||||
|
|
||||||
|
#include "Compiler.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
enum class SingleMode : uint8_t {
|
||||||
|
OFF,
|
||||||
|
ON,
|
||||||
|
ONE_SHOT,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the string representation of a #SingleMode.
|
||||||
|
*/
|
||||||
|
gcc_pure
|
||||||
|
const char *
|
||||||
|
SingleToString(SingleMode mode) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a string to a #SingleMode. Throws std::invalid_argument on error.
|
||||||
|
*/
|
||||||
|
SingleMode
|
||||||
|
SingleFromString(const char *s);
|
||||||
|
|
||||||
|
#endif
|
|
@ -23,6 +23,7 @@
|
||||||
#include "CommandError.hxx"
|
#include "CommandError.hxx"
|
||||||
#include "queue/Playlist.hxx"
|
#include "queue/Playlist.hxx"
|
||||||
#include "PlaylistPrint.hxx"
|
#include "PlaylistPrint.hxx"
|
||||||
|
#include "SingleMode.hxx"
|
||||||
#include "client/Client.hxx"
|
#include "client/Client.hxx"
|
||||||
#include "client/Response.hxx"
|
#include "client/Response.hxx"
|
||||||
#include "mixer/Volume.hxx"
|
#include "mixer/Volume.hxx"
|
||||||
|
@ -134,7 +135,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
|
||||||
|
|
||||||
r.Format(COMMAND_STATUS_REPEAT ": %i\n"
|
r.Format(COMMAND_STATUS_REPEAT ": %i\n"
|
||||||
COMMAND_STATUS_RANDOM ": %i\n"
|
COMMAND_STATUS_RANDOM ": %i\n"
|
||||||
COMMAND_STATUS_SINGLE ": %i\n"
|
COMMAND_STATUS_SINGLE ": %s\n"
|
||||||
COMMAND_STATUS_CONSUME ": %i\n"
|
COMMAND_STATUS_CONSUME ": %i\n"
|
||||||
COMMAND_STATUS_PLAYLIST ": %li\n"
|
COMMAND_STATUS_PLAYLIST ": %li\n"
|
||||||
COMMAND_STATUS_PLAYLIST_LENGTH ": %i\n"
|
COMMAND_STATUS_PLAYLIST_LENGTH ": %i\n"
|
||||||
|
@ -142,7 +143,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
|
||||||
COMMAND_STATUS_STATE ": %s\n",
|
COMMAND_STATUS_STATE ": %s\n",
|
||||||
playlist.GetRepeat(),
|
playlist.GetRepeat(),
|
||||||
playlist.GetRandom(),
|
playlist.GetRandom(),
|
||||||
playlist.GetSingle(),
|
SingleToString(playlist.GetSingle()),
|
||||||
playlist.GetConsume(),
|
playlist.GetConsume(),
|
||||||
(unsigned long)playlist.GetVersion(),
|
(unsigned long)playlist.GetVersion(),
|
||||||
playlist.GetLength(),
|
playlist.GetLength(),
|
||||||
|
@ -218,8 +219,8 @@ handle_next(Client &client, gcc_unused Request args, gcc_unused Response &r)
|
||||||
|
|
||||||
/* single mode is not considered when this is user who
|
/* single mode is not considered when this is user who
|
||||||
* wants to change song. */
|
* wants to change song. */
|
||||||
const bool single = playlist.queue.single;
|
const SingleMode single = playlist.queue.single;
|
||||||
playlist.queue.single = false;
|
playlist.queue.single = SingleMode::OFF;
|
||||||
|
|
||||||
AtScopeExit(&playlist, single) {
|
AtScopeExit(&playlist, single) {
|
||||||
playlist.queue.single = single;
|
playlist.queue.single = single;
|
||||||
|
@ -248,8 +249,8 @@ handle_repeat(Client &client, Request args, gcc_unused Response &r)
|
||||||
CommandResult
|
CommandResult
|
||||||
handle_single(Client &client, Request args, gcc_unused Response &r)
|
handle_single(Client &client, Request args, gcc_unused Response &r)
|
||||||
{
|
{
|
||||||
bool status = args.ParseBool(0);
|
auto new_mode = SingleFromString(args.front());
|
||||||
client.GetPartition().SetSingle(status);
|
client.GetPartition().SetSingle(new_mode);
|
||||||
return CommandResult::OK;
|
return CommandResult::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,11 @@ public:
|
||||||
* The current song's tag has changed.
|
* The current song's tag has changed.
|
||||||
*/
|
*/
|
||||||
virtual void OnPlayerTagModified() noexcept = 0;
|
virtual void OnPlayerTagModified() noexcept = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Playback went into border pause.
|
||||||
|
*/
|
||||||
|
virtual void OnBorderPause() noexcept = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -930,6 +930,7 @@ Player::SongBorder() noexcept
|
||||||
const bool border_pause = pc.ApplyBorderPause();
|
const bool border_pause = pc.ApplyBorderPause();
|
||||||
if (border_pause) {
|
if (border_pause) {
|
||||||
paused = true;
|
paused = true;
|
||||||
|
pc.listener.OnBorderPause();
|
||||||
idle_add(IDLE_PLAYER);
|
idle_add(IDLE_PLAYER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "PlaylistError.hxx"
|
#include "PlaylistError.hxx"
|
||||||
#include "player/Control.hxx"
|
#include "player/Control.hxx"
|
||||||
#include "DetachedSong.hxx"
|
#include "DetachedSong.hxx"
|
||||||
|
#include "SingleMode.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -136,7 +137,7 @@ playlist::UpdateQueuedSong(PlayerControl &pc, const DetachedSong *prev)
|
||||||
? queue.GetNextOrder(current)
|
? queue.GetNextOrder(current)
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
if (next_order == 0 && queue.random && !queue.single) {
|
if (next_order == 0 && queue.random && queue.single == SingleMode::OFF) {
|
||||||
/* shuffle the song order again, so we get a different
|
/* shuffle the song order again, so we get a different
|
||||||
order each time the playlist is played
|
order each time the playlist is played
|
||||||
completely */
|
completely */
|
||||||
|
@ -257,7 +258,7 @@ playlist::SetRepeat(PlayerControl &pc, bool status)
|
||||||
|
|
||||||
queue.repeat = status;
|
queue.repeat = status;
|
||||||
|
|
||||||
pc.LockSetBorderPause(queue.single && !queue.repeat);
|
pc.LockSetBorderPause(queue.single != SingleMode::OFF && !queue.repeat);
|
||||||
|
|
||||||
/* if the last song is currently being played, the "next song"
|
/* if the last song is currently being played, the "next song"
|
||||||
might change when repeat mode is toggled */
|
might change when repeat mode is toggled */
|
||||||
|
@ -277,14 +278,15 @@ playlist_order(playlist &playlist)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
playlist::SetSingle(PlayerControl &pc, bool status)
|
playlist::SetSingle(PlayerControl &pc, SingleMode status)
|
||||||
{
|
{
|
||||||
if (status == queue.single)
|
if (status == queue.single)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
queue.single = status;
|
queue.single = status;
|
||||||
|
|
||||||
pc.LockSetBorderPause(queue.single && !queue.repeat);
|
|
||||||
|
pc.LockSetBorderPause(queue.single != SingleMode::OFF && !queue.repeat);
|
||||||
|
|
||||||
/* if the last song is currently being played, the "next song"
|
/* if the last song is currently being played, the "next song"
|
||||||
might change when single mode is toggled */
|
might change when single mode is toggled */
|
||||||
|
@ -353,7 +355,7 @@ playlist::GetNextPosition() const noexcept
|
||||||
if (current < 0)
|
if (current < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (queue.single && queue.repeat)
|
if (queue.single != SingleMode::OFF && queue.repeat)
|
||||||
return queue.OrderToPosition(current);
|
return queue.OrderToPosition(current);
|
||||||
else if (queue.IsValidOrder(current + 1))
|
else if (queue.IsValidOrder(current + 1))
|
||||||
return queue.OrderToPosition(current + 1);
|
return queue.OrderToPosition(current + 1);
|
||||||
|
@ -362,3 +364,14 @@ playlist::GetNextPosition() const noexcept
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
playlist::BorderPause(PlayerControl &pc)
|
||||||
|
{
|
||||||
|
if (queue.single == SingleMode::ONE_SHOT) {
|
||||||
|
queue.single = SingleMode::OFF;
|
||||||
|
pc.LockSetBorderPause(false);
|
||||||
|
|
||||||
|
listener.OnQueueOptionsChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#ifndef MPD_PLAYLIST_HXX
|
#ifndef MPD_PLAYLIST_HXX
|
||||||
#define MPD_PLAYLIST_HXX
|
#define MPD_PLAYLIST_HXX
|
||||||
|
|
||||||
|
#include "SingleMode.hxx"
|
||||||
#include "queue/Queue.hxx"
|
#include "queue/Queue.hxx"
|
||||||
|
|
||||||
enum TagType : uint8_t;
|
enum TagType : uint8_t;
|
||||||
|
@ -133,6 +134,12 @@ struct playlist {
|
||||||
*/
|
*/
|
||||||
void SyncWithPlayer(PlayerControl &pc);
|
void SyncWithPlayer(PlayerControl &pc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the "BORDER_PAUSE" event handler. It is invoked by
|
||||||
|
* the player thread whenever playback goes into border pause.
|
||||||
|
*/
|
||||||
|
void BorderPause(PlayerControl &pc);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Called by all editing methods after a modification.
|
* Called by all editing methods after a modification.
|
||||||
|
@ -347,11 +354,11 @@ public:
|
||||||
|
|
||||||
void SetRandom(PlayerControl &pc, bool new_value);
|
void SetRandom(PlayerControl &pc, bool new_value);
|
||||||
|
|
||||||
bool GetSingle() const {
|
SingleMode GetSingle() const {
|
||||||
return queue.single;
|
return queue.single;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetSingle(PlayerControl &pc, bool new_value);
|
void SetSingle(PlayerControl &pc, SingleMode new_value);
|
||||||
|
|
||||||
bool GetConsume() const {
|
bool GetConsume() const {
|
||||||
return queue.consume;
|
return queue.consume;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "PlaylistState.hxx"
|
#include "PlaylistState.hxx"
|
||||||
#include "PlaylistError.hxx"
|
#include "PlaylistError.hxx"
|
||||||
#include "Playlist.hxx"
|
#include "Playlist.hxx"
|
||||||
|
#include "SingleMode.hxx"
|
||||||
#include "queue/QueueSave.hxx"
|
#include "queue/QueueSave.hxx"
|
||||||
#include "fs/io/TextFile.hxx"
|
#include "fs/io/TextFile.hxx"
|
||||||
#include "fs/io/BufferedOutputStream.hxx"
|
#include "fs/io/BufferedOutputStream.hxx"
|
||||||
|
@ -88,7 +89,8 @@ playlist_state_save(BufferedOutputStream &os, const struct playlist &playlist,
|
||||||
|
|
||||||
os.Format(PLAYLIST_STATE_FILE_RANDOM "%i\n", playlist.queue.random);
|
os.Format(PLAYLIST_STATE_FILE_RANDOM "%i\n", playlist.queue.random);
|
||||||
os.Format(PLAYLIST_STATE_FILE_REPEAT "%i\n", playlist.queue.repeat);
|
os.Format(PLAYLIST_STATE_FILE_REPEAT "%i\n", playlist.queue.repeat);
|
||||||
os.Format(PLAYLIST_STATE_FILE_SINGLE "%i\n", playlist.queue.single);
|
os.Format(PLAYLIST_STATE_FILE_SINGLE "%i\n",
|
||||||
|
(int)playlist.queue.single);
|
||||||
os.Format(PLAYLIST_STATE_FILE_CONSUME "%i\n", playlist.queue.consume);
|
os.Format(PLAYLIST_STATE_FILE_CONSUME "%i\n", playlist.queue.consume);
|
||||||
os.Format(PLAYLIST_STATE_FILE_CROSSFADE "%i\n",
|
os.Format(PLAYLIST_STATE_FILE_CROSSFADE "%i\n",
|
||||||
(int)pc.GetCrossFade());
|
(int)pc.GetCrossFade());
|
||||||
|
@ -153,7 +155,7 @@ playlist_state_restore(const char *line, TextFile &file,
|
||||||
} else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_REPEAT))) {
|
} else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_REPEAT))) {
|
||||||
playlist.SetRepeat(pc, StringIsEqual(p, "1"));
|
playlist.SetRepeat(pc, StringIsEqual(p, "1"));
|
||||||
} else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_SINGLE))) {
|
} else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_SINGLE))) {
|
||||||
playlist.SetSingle(pc, StringIsEqual(p, "1"));
|
playlist.SetSingle(pc, SingleFromString(p));
|
||||||
} else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_CONSUME))) {
|
} else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_CONSUME))) {
|
||||||
playlist.SetConsume(StringIsEqual(p, "1"));
|
playlist.SetConsume(StringIsEqual(p, "1"));
|
||||||
} else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_CROSSFADE))) {
|
} else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_CROSSFADE))) {
|
||||||
|
@ -233,9 +235,10 @@ playlist_state_get_hash(const playlist &playlist,
|
||||||
: 0) ^
|
: 0) ^
|
||||||
((int)pc.GetCrossFade() << 20) ^
|
((int)pc.GetCrossFade() << 20) ^
|
||||||
(unsigned(player_status.state) << 24) ^
|
(unsigned(player_status.state) << 24) ^
|
||||||
|
/* note that this takes 2 bits */
|
||||||
|
((int)playlist.queue.single << 25) ^
|
||||||
(playlist.queue.random << 27) ^
|
(playlist.queue.random << 27) ^
|
||||||
(playlist.queue.repeat << 28) ^
|
(playlist.queue.repeat << 28) ^
|
||||||
(playlist.queue.single << 29) ^
|
|
||||||
(playlist.queue.consume << 30) ^
|
(playlist.queue.consume << 30) ^
|
||||||
(playlist.queue.random << 31);
|
(playlist.queue.random << 31);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ Queue::GetNextOrder(unsigned _order) const noexcept
|
||||||
{
|
{
|
||||||
assert(_order < length);
|
assert(_order < length);
|
||||||
|
|
||||||
if (single && repeat && !consume)
|
if (single != SingleMode::OFF && repeat && !consume)
|
||||||
return _order;
|
return _order;
|
||||||
else if (_order + 1 < length)
|
else if (_order + 1 < length)
|
||||||
return _order + 1;
|
return _order + 1;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
#include "IdTable.hxx"
|
#include "IdTable.hxx"
|
||||||
|
#include "SingleMode.hxx"
|
||||||
#include "util/LazyRandomEngine.hxx"
|
#include "util/LazyRandomEngine.hxx"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -92,7 +93,7 @@ struct Queue {
|
||||||
bool repeat = false;
|
bool repeat = false;
|
||||||
|
|
||||||
/** play only current song. */
|
/** play only current song. */
|
||||||
bool single = false;
|
SingleMode single = SingleMode::OFF;
|
||||||
|
|
||||||
/** remove each played files. */
|
/** remove each played files. */
|
||||||
bool consume = false;
|
bool consume = false;
|
||||||
|
|
Loading…
Reference in New Issue