Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
e7519829
Commit
e7519829
authored
Mar 27, 2009
by
Romain Bignon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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.
parent
e46722b2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
49 additions
and
34 deletions
+49
-34
protocol.xml
doc/protocol.xml
+6
-5
command.c
src/command.c
+6
-6
playlist.c
src/playlist.c
+16
-7
playlist.h
src/playlist.h
+2
-2
playlist_control.c
src/playlist_control.c
+2
-2
playlist_state.c
src/playlist_state.c
+7
-7
queue.c
src/queue.c
+8
-3
queue.h
src/queue.h
+2
-2
No files found.
doc/protocol.xml
View file @
e7519829
...
...
@@ -218,7 +218,7 @@
</listitem>
<listitem>
<para>
<varname>
s
martstop
</varname>
:
<varname>
s
ingle
</varname>
:
<returnvalue>
0 or 1
</returnvalue>
</para>
</listitem>
...
...
@@ -408,18 +408,19 @@
</para>
</listitem>
</varlistentry>
<varlistentry
id=
"command_s
martstop
"
>
<varlistentry
id=
"command_s
ingle
"
>
<term>
<cmdsynopsis>
<command>
s
martstop
</command>
<command>
s
ingle
</command>
<arg
choice=
"req"
><replaceable>
STATE
</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Sets s
martstop
state to
<varname>
STATE
</varname>
,
Sets s
ingle
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>
...
...
src/command.c
View file @
e7519829
...
...
@@ -59,7 +59,7 @@
#define COMMAND_STATUS_VOLUME "volume"
#define COMMAND_STATUS_STATE "state"
#define COMMAND_STATUS_REPEAT "repeat"
#define COMMAND_STATUS_S
MARTSTOP "smartstop
"
#define COMMAND_STATUS_S
INGLE "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_S
MARTSTOP
": %i
\n
"
COMMAND_STATUS_S
INGLE
": %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
),
getPlaylistS
martstop
Status
(
&
g_playlist
),
getPlaylistS
ingle
Status
(
&
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_s
martstop
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
char
*
argv
[])
handle_s
ingle
(
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
;
}
setPlaylistS
martstop
Status
(
&
g_playlist
,
status
);
setPlaylistS
ingle
Status
(
&
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
},
{
"s
martstop"
,
PERMISSION_CONTROL
,
1
,
1
,
handle_smartstop
},
{
"s
ingle"
,
PERMISSION_CONTROL
,
1
,
1
,
handle_single
},
{
"stats"
,
PERMISSION_READ
,
0
,
0
,
handle_stats
},
{
"status"
,
PERMISSION_READ
,
0
,
0
,
handle_status
},
#ifdef ENABLE_SQLITE
...
...
src/playlist.c
View file @
e7519829
...
...
@@ -262,9 +262,9 @@ getPlaylistRandomStatus(const struct playlist *playlist)
}
bool
getPlaylistS
martstop
Status
(
const
struct
playlist
*
playlist
)
getPlaylistS
ingle
Status
(
const
struct
playlist
*
playlist
)
{
return
playlist
->
queue
.
s
martstop
;
return
playlist
->
queue
.
s
ingle
;
}
void
setPlaylistRepeatStatus
(
struct
playlist
*
playlist
,
bool
status
)
...
...
@@ -292,12 +292,15 @@ static void orderPlaylist(struct playlist *playlist)
queue_restore_order
(
&
playlist
->
queue
);
}
void
setPlaylistS
martstop
Status
(
struct
playlist
*
playlist
,
bool
status
)
void
setPlaylistS
ingle
Status
(
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
);
...
...
src/playlist.h
View file @
e7519829
...
...
@@ -180,9 +180,9 @@ getPlaylistRandomStatus(const struct playlist *playlist);
void
setPlaylistRandomStatus
(
struct
playlist
*
playlist
,
bool
status
);
bool
getPlaylistS
martstop
Status
(
const
struct
playlist
*
playlist
);
getPlaylistS
ingle
Status
(
const
struct
playlist
*
playlist
);
void
setPlaylistS
martstop
Status
(
struct
playlist
*
playlist
,
bool
status
);
void
setPlaylistS
ingle
Status
(
struct
playlist
*
playlist
,
bool
status
);
int
getPlaylistCurrentSong
(
const
struct
playlist
*
playlist
);
...
...
src/playlist_control.c
View file @
e7519829
...
...
@@ -152,8 +152,8 @@ nextSongInPlaylist(struct playlist *playlist)
next_order
=
queue_next_order
(
&
playlist
->
queue
,
playlist
->
current
);
if
(
next_order
<
0
)
{
/* cancel s
martstop
*/
playlist
->
queue
.
s
martstop
=
false
;
/* cancel s
ingle
*/
playlist
->
queue
.
s
ingle
=
false
;
/* no song after this one: stop playback */
stopPlaylist
(
playlist
);
return
;
...
...
src/playlist_state.c
View file @
e7519829
...
...
@@ -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_S
MARTSTOP "smartstop
: "
#define PLAYLIST_STATE_FILE_S
INGLE "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_S
MARTSTOP
,
playlist
->
queue
.
s
martstop
);
fprintf
(
fp
,
"%s%i
\n
"
,
PLAYLIST_STATE_FILE_S
INGLE
,
playlist
->
queue
.
s
ingle
);
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_S
MARTSTOP
))
{
}
else
if
(
g_str_has_prefix
(
buffer
,
PLAYLIST_STATE_FILE_S
INGLE
))
{
if
(
strcmp
(
&
(
buffer
[
strlen
(
PLAYLIST_STATE_FILE_S
MARTSTOP
)]),
(
&
(
buffer
[
strlen
(
PLAYLIST_STATE_FILE_S
INGLE
)]),
"1"
)
==
0
)
{
setPlaylistS
martstop
Status
(
playlist
,
true
);
setPlaylistS
ingle
Status
(
playlist
,
true
);
}
else
setPlaylistS
martstop
Status
(
playlist
,
false
);
setPlaylistS
ingle
Status
(
playlist
,
false
);
}
else
if
(
g_str_has_prefix
(
buffer
,
PLAYLIST_STATE_FILE_CROSSFADE
))
{
setPlayerCrossFade
(
atoi
(
&
...
...
src/queue.c
View file @
e7519829
...
...
@@ -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
->
s
martstop
=
false
;
queue
->
s
ingle
=
false
;
queue
->
items
=
g_new
(
struct
queue_item
,
max_length
);
queue
->
order
=
g_malloc
(
sizeof
(
queue
->
order
[
0
])
*
...
...
src/queue.h
View file @
e7519829
...
...
@@ -81,8 +81,8 @@ struct queue {
reached? */
bool
repeat
;
/**
stop playing after tha
t song. */
bool
s
martstop
;
/**
play only curren
t song. */
bool
s
ingle
;
/** play back songs in random order? */
bool
random
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment