aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Bignon <romain@peerfuse.org>2009-03-27 15:28:49 +0100
committerRomain Bignon <romain@peerfuse.org>2009-03-27 15:28:49 +0100
commite7519829ac588e4b261c1832bb0e7d6ffbd47322 (patch)
treeec9ab205b3a4344b76dcd60dddc8496ed8357cde
parente46722b2ebe05fce63bc7b86100c159b5cadd297 (diff)
downloadmpd-e7519829ac588e4b261c1832bb0e7d6ffbd47322.tar.gz
mpd-e7519829ac588e4b261c1832bb0e7d6ffbd47322.tar.xz
mpd-e7519829ac588e4b261c1832bb0e7d6ffbd47322.zip
renamed smartstop to single and changed behavior
When single mode is enabled, after current song it stops playback, or it replay same song if repeat mode is activated.
-rw-r--r--doc/protocol.xml11
-rw-r--r--src/command.c12
-rw-r--r--src/playlist.c23
-rw-r--r--src/playlist.h4
-rw-r--r--src/playlist_control.c4
-rw-r--r--src/playlist_state.c14
-rw-r--r--src/queue.c11
-rw-r--r--src/queue.h4
8 files changed, 49 insertions, 34 deletions
diff --git a/doc/protocol.xml b/doc/protocol.xml
index fc833f7bf..3dcfedeb5 100644
--- a/doc/protocol.xml
+++ b/doc/protocol.xml
@@ -218,7 +218,7 @@
</listitem>
<listitem>
<para>
- <varname>smartstop</varname>:
+ <varname>single</varname>:
<returnvalue>0 or 1</returnvalue>
</para>
</listitem>
@@ -408,18 +408,19 @@
</para>
</listitem>
</varlistentry>
- <varlistentry id="command_smartstop">
+ <varlistentry id="command_single">
<term>
<cmdsynopsis>
- <command>smartstop</command>
+ <command>single</command>
<arg choice="req"><replaceable>STATE</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
- Sets smartstop state to <varname>STATE</varname>,
+ Sets single state to <varname>STATE</varname>,
<varname>STATE</varname> should be 0 or 1.
- When smartstop is activated, playback is stopped after current song.
+ When single is activated, playback is stopped after current song, or
+ song is repeated if the 'repeat' mode is enabled.
</para>
</listitem>
</varlistentry>
diff --git a/src/command.c b/src/command.c
index 82b088587..69fbe514f 100644
--- a/src/command.c
+++ b/src/command.c
@@ -59,7 +59,7 @@
#define COMMAND_STATUS_VOLUME "volume"
#define COMMAND_STATUS_STATE "state"
#define COMMAND_STATUS_REPEAT "repeat"
-#define COMMAND_STATUS_SMARTSTOP "smartstop"
+#define COMMAND_STATUS_SINGLE "single"
#define COMMAND_STATUS_RANDOM "random"
#define COMMAND_STATUS_PLAYLIST "playlist"
#define COMMAND_STATUS_PLAYLIST_LENGTH "playlistlength"
@@ -470,7 +470,7 @@ handle_status(struct client *client,
COMMAND_STATUS_VOLUME ": %i\n"
COMMAND_STATUS_REPEAT ": %i\n"
COMMAND_STATUS_RANDOM ": %i\n"
- COMMAND_STATUS_SMARTSTOP ": %i\n"
+ COMMAND_STATUS_SINGLE ": %i\n"
COMMAND_STATUS_PLAYLIST ": %li\n"
COMMAND_STATUS_PLAYLIST_LENGTH ": %i\n"
COMMAND_STATUS_CROSSFADE ": %i\n"
@@ -478,7 +478,7 @@ handle_status(struct client *client,
volume_level_get(),
getPlaylistRepeatStatus(&g_playlist),
getPlaylistRandomStatus(&g_playlist),
- getPlaylistSmartstopStatus(&g_playlist),
+ getPlaylistSingleStatus(&g_playlist),
getPlaylistVersion(&g_playlist),
getPlaylistLength(&g_playlist),
(int)(getPlayerCrossFade() + 0.5),
@@ -1096,7 +1096,7 @@ handle_repeat(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
}
static enum command_return
-handle_smartstop(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
+handle_single(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
{
int status;
@@ -1109,7 +1109,7 @@ handle_smartstop(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
return COMMAND_RETURN_ERROR;
}
- setPlaylistSmartstopStatus(&g_playlist, status);
+ setPlaylistSingleStatus(&g_playlist, status);
return COMMAND_RETURN_OK;
}
@@ -1623,7 +1623,7 @@ static const struct command commands[] = {
{ "seekid", PERMISSION_CONTROL, 2, 2, handle_seekid },
{ "setvol", PERMISSION_CONTROL, 1, 1, handle_setvol },
{ "shuffle", PERMISSION_CONTROL, 0, 1, handle_shuffle },
- { "smartstop", PERMISSION_CONTROL, 1, 1, handle_smartstop },
+ { "single", PERMISSION_CONTROL, 1, 1, handle_single },
{ "stats", PERMISSION_READ, 0, 0, handle_stats },
{ "status", PERMISSION_READ, 0, 0, handle_status },
#ifdef ENABLE_SQLITE
diff --git a/src/playlist.c b/src/playlist.c
index 0ec46492a..776308db0 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -262,9 +262,9 @@ getPlaylistRandomStatus(const struct playlist *playlist)
}
bool
-getPlaylistSmartstopStatus(const struct playlist *playlist)
+getPlaylistSingleStatus(const struct playlist *playlist)
{
- return playlist->queue.smartstop;
+ return playlist->queue.single;
}
void setPlaylistRepeatStatus(struct playlist *playlist, bool status)
@@ -292,12 +292,15 @@ static void orderPlaylist(struct playlist *playlist)
queue_restore_order(&playlist->queue);
}
-void setPlaylistSmartstopStatus(struct playlist *playlist, bool status)
+void setPlaylistSingleStatus(struct playlist *playlist, bool status)
{
- playlist->queue.smartstop = status;
+ if (status == playlist->queue.single)
+ return;
+
+ playlist->queue.single = status;
/* if the last song is currently being played, the "next song"
- might change when repeat mode is toggled */
+ might change when single mode is toggled */
playlist_update_queued_song(playlist,
playlist_get_queued_song(playlist));
@@ -359,8 +362,14 @@ int getPlaylistNextSong(const struct playlist *playlist)
{
if (playlist->current >= 0)
{
- if (playlist->queue.smartstop == 1)
- return -1;
+ if (playlist->queue.single == 1)
+ {
+ if (playlist->queue.repeat == 1)
+ return queue_order_to_position(&playlist->queue,
+ playlist->current);
+ else
+ return -1;
+ }
if (playlist->current + 1 < (int)queue_length(&playlist->queue))
return queue_order_to_position(&playlist->queue,
playlist->current + 1);
diff --git a/src/playlist.h b/src/playlist.h
index 4e11ec421..17862b335 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -180,9 +180,9 @@ getPlaylistRandomStatus(const struct playlist *playlist);
void setPlaylistRandomStatus(struct playlist *playlist, bool status);
bool
-getPlaylistSmartstopStatus(const struct playlist *playlist);
+getPlaylistSingleStatus(const struct playlist *playlist);
-void setPlaylistSmartstopStatus(struct playlist *playlist, bool status);
+void setPlaylistSingleStatus(struct playlist *playlist, bool status);
int getPlaylistCurrentSong(const struct playlist *playlist);
diff --git a/src/playlist_control.c b/src/playlist_control.c
index 90aab5f29..9e31c07ab 100644
--- a/src/playlist_control.c
+++ b/src/playlist_control.c
@@ -152,8 +152,8 @@ nextSongInPlaylist(struct playlist *playlist)
next_order = queue_next_order(&playlist->queue, playlist->current);
if (next_order < 0) {
- /* cancel smartstop */
- playlist->queue.smartstop = false;
+ /* cancel single */
+ playlist->queue.single = false;
/* no song after this one: stop playback */
stopPlaylist(playlist);
return;
diff --git a/src/playlist_state.c b/src/playlist_state.c
index 6d1756eed..f5b1456d7 100644
--- a/src/playlist_state.c
+++ b/src/playlist_state.c
@@ -34,7 +34,7 @@
#define PLAYLIST_STATE_FILE_STATE "state: "
#define PLAYLIST_STATE_FILE_RANDOM "random: "
#define PLAYLIST_STATE_FILE_REPEAT "repeat: "
-#define PLAYLIST_STATE_FILE_SMARTSTOP "smartstop: "
+#define PLAYLIST_STATE_FILE_SINGLE "single: "
#define PLAYLIST_STATE_FILE_CURRENT "current: "
#define PLAYLIST_STATE_FILE_TIME "time: "
#define PLAYLIST_STATE_FILE_CROSSFADE "crossfade: "
@@ -72,8 +72,8 @@ playlist_state_save(FILE *fp, const struct playlist *playlist)
playlist->queue.random);
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_REPEAT,
playlist->queue.repeat);
- fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_SMARTSTOP,
- playlist->queue.smartstop);
+ fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_SINGLE,
+ playlist->queue.single);
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CROSSFADE,
(int)(getPlayerCrossFade()));
fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_BEGIN);
@@ -139,13 +139,13 @@ playlist_state_restore(FILE *fp, struct playlist *playlist)
setPlaylistRepeatStatus(playlist, true);
} else
setPlaylistRepeatStatus(playlist, false);
- } else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_SMARTSTOP)) {
+ } else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_SINGLE)) {
if (strcmp
- (&(buffer[strlen(PLAYLIST_STATE_FILE_SMARTSTOP)]),
+ (&(buffer[strlen(PLAYLIST_STATE_FILE_SINGLE)]),
"1") == 0) {
- setPlaylistSmartstopStatus(playlist, true);
+ setPlaylistSingleStatus(playlist, true);
} else
- setPlaylistSmartstopStatus(playlist, false);
+ setPlaylistSingleStatus(playlist, false);
} else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_CROSSFADE)) {
setPlayerCrossFade(atoi
(&
diff --git a/src/queue.c b/src/queue.c
index 28da0e5a3..21d4884c6 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -40,8 +40,13 @@ queue_next_order(const struct queue *queue, unsigned order)
{
assert(order < queue->length);
- if (queue->smartstop)
- return -1;
+ if (queue->single)
+ {
+ if (queue->repeat)
+ return order;
+ else
+ return -1;
+ }
if (order + 1 < queue->length)
return order + 1;
else if (queue->repeat)
@@ -277,7 +282,7 @@ queue_init(struct queue *queue, unsigned max_length)
queue->version = 1;
queue->repeat = false;
queue->random = false;
- queue->smartstop = false;
+ queue->single = false;
queue->items = g_new(struct queue_item, max_length);
queue->order = g_malloc(sizeof(queue->order[0]) *
diff --git a/src/queue.h b/src/queue.h
index 63b71d199..452084ce8 100644
--- a/src/queue.h
+++ b/src/queue.h
@@ -81,8 +81,8 @@ struct queue {
reached? */
bool repeat;
- /** stop playing after that song. */
- bool smartstop;
+ /** play only current song. */
+ bool single;
/** play back songs in random order? */
bool random;