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
d8971704
Commit
d8971704
authored
Jul 14, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist: no CamelCase
parent
5a886da9
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
95 additions
and
86 deletions
+95
-86
command.c
src/command.c
+12
-12
dbUtils.c
src/dbUtils.c
+1
-1
main.c
src/main.c
+2
-2
playlist.c
src/playlist.c
+1
-1
playlist.h
src/playlist.h
+17
-13
playlist_control.c
src/playlist_control.c
+1
-1
playlist_edit.c
src/playlist_edit.c
+54
-51
playlist_global.c
src/playlist_global.c
+4
-2
playlist_save.c
src/playlist_save.c
+2
-2
update.c
src/update.c
+1
-1
No files found.
src/command.c
View file @
d8971704
...
...
@@ -570,7 +570,7 @@ handle_add(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
}
result
=
addToPlaylist
(
&
g_playlist
,
uri
,
NULL
);
result
=
playlist_append_uri
(
&
g_playlist
,
uri
,
NULL
);
return
print_playlist_result
(
client
,
result
);
}
...
...
@@ -606,7 +606,7 @@ handle_addid(struct client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
}
result
=
addToPlaylist
(
&
g_playlist
,
uri
,
&
added_id
);
result
=
playlist_append_uri
(
&
g_playlist
,
uri
,
&
added_id
);
}
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
...
...
@@ -616,11 +616,11 @@ handle_addid(struct client *client, int argc, char *argv[])
int
to
;
if
(
!
check_int
(
client
,
&
to
,
argv
[
2
],
check_integer
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
result
=
moveSongInPlaylistByI
d
(
&
g_playlist
,
added_id
,
to
);
result
=
playlist_move_i
d
(
&
g_playlist
,
added_id
,
to
);
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
{
enum
command_return
ret
=
print_playlist_result
(
client
,
result
);
deleteFromPlaylistByI
d
(
&
g_playlist
,
added_id
);
playlist_delete_i
d
(
&
g_playlist
,
added_id
);
return
ret
;
}
}
...
...
@@ -638,7 +638,7 @@ handle_delete(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
check_int
(
client
,
&
song
,
argv
[
1
],
need_positive
))
return
COMMAND_RETURN_ERROR
;
result
=
deleteFromPlaylist
(
&
g_playlist
,
song
);
result
=
playlist_delete
(
&
g_playlist
,
song
);
return
print_playlist_result
(
client
,
result
);
}
...
...
@@ -651,7 +651,7 @@ handle_deleteid(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
check_int
(
client
,
&
id
,
argv
[
1
],
need_positive
))
return
COMMAND_RETURN_ERROR
;
result
=
deleteFromPlaylistByI
d
(
&
g_playlist
,
id
);
result
=
playlist_delete_i
d
(
&
g_playlist
,
id
);
return
print_playlist_result
(
client
,
result
);
}
...
...
@@ -672,7 +672,7 @@ handle_shuffle(G_GNUC_UNUSED struct client *client,
argv
[
1
],
need_range
))
return
COMMAND_RETURN_ERROR
;
shufflePlaylist
(
&
g_playlist
,
start
,
end
);
playlist_shuffle
(
&
g_playlist
,
start
,
end
);
return
COMMAND_RETURN_OK
;
}
...
...
@@ -680,7 +680,7 @@ static enum command_return
handle_clear
(
G_GNUC_UNUSED
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
clearPlaylist
(
&
g_playlist
);
playlist_clear
(
&
g_playlist
);
return
COMMAND_RETURN_OK
;
}
...
...
@@ -1228,7 +1228,7 @@ handle_move(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
if
(
!
check_int
(
client
,
&
to
,
argv
[
2
],
check_integer
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
result
=
moveSongRangeInPlaylist
(
&
g_playlist
,
start
,
end
,
to
);
result
=
playlist_move_range
(
&
g_playlist
,
start
,
end
,
to
);
return
print_playlist_result
(
client
,
result
);
}
...
...
@@ -1242,7 +1242,7 @@ handle_moveid(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
if
(
!
check_int
(
client
,
&
to
,
argv
[
2
],
check_integer
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
result
=
moveSongInPlaylistByI
d
(
&
g_playlist
,
id
,
to
);
result
=
playlist_move_i
d
(
&
g_playlist
,
id
,
to
);
return
print_playlist_result
(
client
,
result
);
}
...
...
@@ -1256,7 +1256,7 @@ handle_swap(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
if
(
!
check_int
(
client
,
&
song2
,
argv
[
2
],
check_integer
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
result
=
swapSongsInPlaylist
(
&
g_playlist
,
song1
,
song2
);
result
=
playlist_swap_songs
(
&
g_playlist
,
song1
,
song2
);
return
print_playlist_result
(
client
,
result
);
}
...
...
@@ -1270,7 +1270,7 @@ handle_swapid(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
if
(
!
check_int
(
client
,
&
id2
,
argv
[
2
],
check_integer
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
result
=
swapSongsInPlaylistByI
d
(
&
g_playlist
,
id1
,
id2
);
result
=
playlist_swap_songs_i
d
(
&
g_playlist
,
id1
,
id2
);
return
print_playlist_result
(
client
,
result
);
}
...
...
src/dbUtils.c
View file @
d8971704
...
...
@@ -168,7 +168,7 @@ int printAllIn(struct client *client, const char *name)
static
int
directoryAddSongToPlaylist
(
struct
song
*
song
,
G_GNUC_UNUSED
void
*
data
)
{
return
addSongToPlaylist
(
&
g_playlist
,
song
,
NULL
);
return
playlist_append_song
(
&
g_playlist
,
song
,
NULL
);
}
struct
add_data
{
...
...
src/main.c
View file @
d8971704
...
...
@@ -281,7 +281,7 @@ int main(int argc, char *argv[])
path_global_init
();
mapper_init
();
initPermissions
();
initPlaylis
t
();
playlist_global_ini
t
();
spl_global_init
();
#ifdef ENABLE_ARCHIVE
archive_plugin_init_all
();
...
...
@@ -344,7 +344,7 @@ int main(int argc, char *argv[])
finishZeroconf
();
client_manager_deinit
();
listen_global_finish
();
finishPlaylist
();
playlist_global_finish
();
start
=
clock
();
db_finish
();
...
...
src/playlist.c
View file @
d8971704
...
...
@@ -109,7 +109,7 @@ static void syncPlaylistWithQueue(struct playlist *playlist)
playlist
->
queued
=
-
1
;
if
(
playlist
->
queue
.
consume
)
deleteFromPlaylist
(
playlist
,
queue_order_to_position
(
&
playlist
->
queue
,
current
));
playlist_delete
(
playlist
,
queue_order_to_position
(
&
playlist
->
queue
,
current
));
idle_add
(
IDLE_PLAYER
);
}
...
...
src/playlist.h
View file @
d8971704
...
...
@@ -93,9 +93,11 @@ struct playlist {
/** the global playlist object */
extern
struct
playlist
g_playlist
;
void
initPlaylist
(
void
);
void
playlist_global_init
(
void
);
void
finishPlaylist
(
void
);
void
playlist_global_finish
(
void
);
void
playlist_init
(
struct
playlist
*
playlist
);
...
...
@@ -115,7 +117,7 @@ playlist_get_queue(const struct playlist *playlist)
return
&
playlist
->
queue
;
}
void
clearPlaylist
(
struct
playlist
*
playlist
);
void
playlist_clear
(
struct
playlist
*
playlist
);
#ifndef WIN32
/**
...
...
@@ -128,17 +130,18 @@ playlist_append_file(struct playlist *playlist, const char *path, int uid,
#endif
enum
playlist_result
addToPlaylist
(
struct
playlist
*
playlist
,
const
char
*
file
,
unsigned
*
added_id
);
playlist_append_uri
(
struct
playlist
*
playlist
,
const
char
*
file
,
unsigned
*
added_id
);
enum
playlist_result
addSongToPlaylist
(
struct
playlist
*
playlist
,
playlist_append_song
(
struct
playlist
*
playlist
,
struct
song
*
song
,
unsigned
*
added_id
);
enum
playlist_result
deleteFromPlaylist
(
struct
playlist
*
playlist
,
unsigned
song
);
playlist_delete
(
struct
playlist
*
playlist
,
unsigned
song
);
enum
playlist_result
deleteFromPlaylistByI
d
(
struct
playlist
*
playlist
,
unsigned
song
);
playlist_delete_i
d
(
struct
playlist
*
playlist
,
unsigned
song
);
void
stopPlaylist
(
struct
playlist
*
playlist
);
...
...
@@ -154,22 +157,23 @@ void syncPlayerAndPlaylist(struct playlist *playlist);
void
previousSongInPlaylist
(
struct
playlist
*
playlist
);
void
shufflePlaylist
(
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
);
void
playlist_shuffle
(
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
);
void
deleteASongFromPlaylist
(
struct
playlist
*
playlist
,
const
struct
song
*
song
);
playlist_delete_song
(
struct
playlist
*
playlist
,
const
struct
song
*
song
);
enum
playlist_result
moveSongRangeInPlaylist
(
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
,
int
to
);
playlist_move_range
(
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
,
int
to
);
enum
playlist_result
moveSongInPlaylistByI
d
(
struct
playlist
*
playlist
,
unsigned
id
,
int
to
);
playlist_move_i
d
(
struct
playlist
*
playlist
,
unsigned
id
,
int
to
);
enum
playlist_result
swapSongsInPlaylist
(
struct
playlist
*
playlist
,
unsigned
song1
,
unsigned
song2
);
playlist_swap_songs
(
struct
playlist
*
playlist
,
unsigned
song1
,
unsigned
song2
);
enum
playlist_result
swapSongsInPlaylistByI
d
(
struct
playlist
*
playlist
,
unsigned
id1
,
unsigned
id2
);
playlist_swap_songs_i
d
(
struct
playlist
*
playlist
,
unsigned
id1
,
unsigned
id2
);
bool
getPlaylistRepeatStatus
(
const
struct
playlist
*
playlist
);
...
...
src/playlist_control.c
View file @
d8971704
...
...
@@ -183,7 +183,7 @@ nextSongInPlaylist(struct playlist *playlist)
/* Consume mode removes each played songs. */
if
(
playlist
->
queue
.
consume
)
deleteFromPlaylist
(
playlist
,
queue_order_to_position
(
&
playlist
->
queue
,
current
));
playlist_delete
(
playlist
,
queue_order_to_position
(
&
playlist
->
queue
,
current
));
}
void
previousSongInPlaylist
(
struct
playlist
*
playlist
)
...
...
src/playlist_edit.c
View file @
d8971704
...
...
@@ -35,14 +35,14 @@
#include <unistd.h>
#include <stdlib.h>
static
void
incrPlaylistV
ersion
(
struct
playlist
*
playlist
)
static
void
playlist_increment_v
ersion
(
struct
playlist
*
playlist
)
{
queue_increment_version
(
&
playlist
->
queue
);
idle_add
(
IDLE_PLAYLIST
);
}
void
clearPlaylist
(
struct
playlist
*
playlist
)
void
playlist_clear
(
struct
playlist
*
playlist
)
{
stopPlaylist
(
playlist
);
...
...
@@ -58,7 +58,7 @@ void clearPlaylist(struct playlist *playlist)
playlist
->
current
=
-
1
;
incrPlaylistV
ersion
(
playlist
);
playlist_increment_v
ersion
(
playlist
);
}
#ifndef WIN32
...
...
@@ -86,41 +86,12 @@ playlist_append_file(struct playlist *playlist, const char *path, int uid,
if
(
song
==
NULL
)
return
PLAYLIST_RESULT_NO_SUCH_SONG
;
return
addSongToPlaylist
(
playlist
,
song
,
added_id
);
return
playlist_append_song
(
playlist
,
song
,
added_id
);
}
#endif
static
struct
song
*
song_by_url
(
const
char
*
url
)
{
struct
song
*
song
;
song
=
db_get_song
(
url
);
if
(
song
!=
NULL
)
return
song
;
if
(
uri_has_scheme
(
url
))
return
song_remote_new
(
url
);
return
NULL
;
}
enum
playlist_result
addToPlaylist
(
struct
playlist
*
playlist
,
const
char
*
url
,
unsigned
*
added_id
)
{
struct
song
*
song
;
g_debug
(
"add to playlist: %s"
,
url
);
song
=
song_by_url
(
url
);
if
(
song
==
NULL
)
return
PLAYLIST_RESULT_NO_SUCH_SONG
;
return
addSongToPlaylist
(
playlist
,
song
,
added_id
);
}
enum
playlist_result
addSongToPlaylist
(
struct
playlist
*
playlist
,
playlist_append_song
(
struct
playlist
*
playlist
,
struct
song
*
song
,
unsigned
*
added_id
)
{
const
struct
song
*
queued
;
...
...
@@ -147,7 +118,7 @@ addSongToPlaylist(struct playlist *playlist,
queue_length
(
&
playlist
->
queue
));
}
incrPlaylistV
ersion
(
playlist
);
playlist_increment_v
ersion
(
playlist
);
playlist_update_queued_song
(
playlist
,
queued
);
...
...
@@ -157,8 +128,38 @@ addSongToPlaylist(struct playlist *playlist,
return
PLAYLIST_RESULT_SUCCESS
;
}
static
struct
song
*
song_by_uri
(
const
char
*
uri
)
{
struct
song
*
song
;
song
=
db_get_song
(
uri
);
if
(
song
!=
NULL
)
return
song
;
if
(
uri_has_scheme
(
uri
))
return
song_remote_new
(
uri
);
return
NULL
;
}
enum
playlist_result
swapSongsInPlaylist
(
struct
playlist
*
playlist
,
unsigned
song1
,
unsigned
song2
)
playlist_append_uri
(
struct
playlist
*
playlist
,
const
char
*
uri
,
unsigned
*
added_id
)
{
struct
song
*
song
;
g_debug
(
"add to playlist: %s"
,
uri
);
song
=
song_by_uri
(
uri
);
if
(
song
==
NULL
)
return
PLAYLIST_RESULT_NO_SUCH_SONG
;
return
playlist_append_song
(
playlist
,
song
,
added_id
);
}
enum
playlist_result
playlist_swap_songs
(
struct
playlist
*
playlist
,
unsigned
song1
,
unsigned
song2
)
{
const
struct
song
*
queued
;
...
...
@@ -188,7 +189,7 @@ swapSongsInPlaylist(struct playlist *playlist, unsigned song1, unsigned song2)
playlist
->
current
=
song1
;
}
incrPlaylistV
ersion
(
playlist
);
playlist_increment_v
ersion
(
playlist
);
playlist_update_queued_song
(
playlist
,
queued
);
...
...
@@ -196,7 +197,7 @@ swapSongsInPlaylist(struct playlist *playlist, unsigned song1, unsigned song2)
}
enum
playlist_result
swapSongsInPlaylistByI
d
(
struct
playlist
*
playlist
,
unsigned
id1
,
unsigned
id2
)
playlist_swap_songs_i
d
(
struct
playlist
*
playlist
,
unsigned
id1
,
unsigned
id2
)
{
int
song1
=
queue_id_to_position
(
&
playlist
->
queue
,
id1
);
int
song2
=
queue_id_to_position
(
&
playlist
->
queue
,
id2
);
...
...
@@ -204,11 +205,11 @@ swapSongsInPlaylistById(struct playlist *playlist, unsigned id1, unsigned id2)
if
(
song1
<
0
||
song2
<
0
)
return
PLAYLIST_RESULT_NO_SUCH_SONG
;
return
swapSongsInPlaylist
(
playlist
,
song1
,
song2
);
return
playlist_swap_songs
(
playlist
,
song1
,
song2
);
}
enum
playlist_result
deleteFromPlaylist
(
struct
playlist
*
playlist
,
unsigned
song
)
playlist_delete
(
struct
playlist
*
playlist
,
unsigned
song
)
{
const
struct
song
*
queued
;
unsigned
songOrder
;
...
...
@@ -256,7 +257,7 @@ deleteFromPlaylist(struct playlist *playlist, unsigned song)
queue_delete
(
&
playlist
->
queue
,
song
);
incrPlaylistV
ersion
(
playlist
);
playlist_increment_v
ersion
(
playlist
);
/* update the "current" and "queued" variables */
...
...
@@ -270,27 +271,28 @@ deleteFromPlaylist(struct playlist *playlist, unsigned song)
}
enum
playlist_result
deleteFromPlaylistByI
d
(
struct
playlist
*
playlist
,
unsigned
id
)
playlist_delete_i
d
(
struct
playlist
*
playlist
,
unsigned
id
)
{
int
song
=
queue_id_to_position
(
&
playlist
->
queue
,
id
);
if
(
song
<
0
)
return
PLAYLIST_RESULT_NO_SUCH_SONG
;
return
deleteFromPlaylist
(
playlist
,
song
);
return
playlist_delete
(
playlist
,
song
);
}
void
deleteASongFromPlaylist
(
struct
playlist
*
playlist
,
const
struct
song
*
song
)
playlist_delete_song
(
struct
playlist
*
playlist
,
const
struct
song
*
song
)
{
for
(
int
i
=
queue_length
(
&
playlist
->
queue
)
-
1
;
i
>=
0
;
--
i
)
if
(
song
==
queue_get
(
&
playlist
->
queue
,
i
))
deleteFromPlaylist
(
playlist
,
i
);
playlist_delete
(
playlist
,
i
);
pc_song_deleted
(
song
);
}
enum
playlist_result
moveSongRangeInPlaylist
(
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
,
int
to
)
playlist_move_range
(
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
,
int
to
)
{
const
struct
song
*
queued
;
int
currentSong
;
...
...
@@ -342,7 +344,7 @@ moveSongRangeInPlaylist(struct playlist *playlist, unsigned start, unsigned end,
}
}
incrPlaylistV
ersion
(
playlist
);
playlist_increment_v
ersion
(
playlist
);
playlist_update_queued_song
(
playlist
,
queued
);
...
...
@@ -350,16 +352,17 @@ moveSongRangeInPlaylist(struct playlist *playlist, unsigned start, unsigned end,
}
enum
playlist_result
moveSongInPlaylistByI
d
(
struct
playlist
*
playlist
,
unsigned
id1
,
int
to
)
playlist_move_i
d
(
struct
playlist
*
playlist
,
unsigned
id1
,
int
to
)
{
int
song
=
queue_id_to_position
(
&
playlist
->
queue
,
id1
);
if
(
song
<
0
)
return
PLAYLIST_RESULT_NO_SUCH_SONG
;
return
moveSongRangeInPlaylist
(
playlist
,
song
,
song
+
1
,
to
);
return
playlist_move_range
(
playlist
,
song
,
song
+
1
,
to
);
}
void
shufflePlaylist
(
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
)
void
playlist_shuffle
(
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
)
{
const
struct
song
*
queued
;
...
...
@@ -399,7 +402,7 @@ void shufflePlaylist(struct playlist *playlist, unsigned start, unsigned end)
queue_shuffle_range
(
&
playlist
->
queue
,
start
,
end
);
incrPlaylistV
ersion
(
playlist
);
playlist_increment_v
ersion
(
playlist
);
playlist_update_queued_song
(
playlist
,
queued
);
}
src/playlist_global.c
View file @
d8971704
...
...
@@ -40,7 +40,8 @@ playlist_event(void)
syncPlayerAndPlaylist
(
&
g_playlist
);
}
void
initPlaylist
(
void
)
void
playlist_global_init
(
void
)
{
playlist_init
(
&
g_playlist
);
...
...
@@ -48,7 +49,8 @@ void initPlaylist(void)
event_pipe_register
(
PIPE_EVENT_PLAYLIST
,
playlist_event
);
}
void
finishPlaylist
(
void
)
void
playlist_global_finish
(
void
)
{
playlist_finish
(
&
g_playlist
);
}
src/playlist_save.c
View file @
d8971704
...
...
@@ -115,7 +115,7 @@ playlist_load_spl(struct playlist *playlist, const char *name_utf8)
for
(
unsigned
i
=
0
;
i
<
list
->
len
;
++
i
)
{
const
char
*
temp
=
g_ptr_array_index
(
list
,
i
);
if
((
addToPlaylist
(
playlist
,
temp
,
NULL
))
!=
PLAYLIST_RESULT_SUCCESS
)
{
if
((
playlist_append_uri
(
playlist
,
temp
,
NULL
))
!=
PLAYLIST_RESULT_SUCCESS
)
{
/* for windows compatibility, convert slashes */
char
*
temp2
=
g_strdup
(
temp
);
char
*
p
=
temp2
;
...
...
@@ -124,7 +124,7 @@ playlist_load_spl(struct playlist *playlist, const char *name_utf8)
*
p
=
'/'
;
p
++
;
}
if
((
addToPlaylist
(
playlist
,
temp
,
NULL
))
!=
PLAYLIST_RESULT_SUCCESS
)
{
if
((
playlist_append_uri
(
playlist
,
temp
,
NULL
))
!=
PLAYLIST_RESULT_SUCCESS
)
{
g_warning
(
"can't add file
\"
%s
\"
"
,
temp2
);
}
g_free
(
temp2
);
...
...
src/update.c
View file @
d8971704
...
...
@@ -849,7 +849,7 @@ static void song_delete_event(void)
sticker_song_delete
(
delete
);
#endif
deleteASongFromPlaylist
(
&
g_playlist
,
delete
);
playlist_delete_song
(
&
g_playlist
,
delete
);
delete
=
NULL
;
notify_signal
(
&
update_notify
);
...
...
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