playlist: no CamelCase
This commit is contained in:
parent
5a886da93b
commit
d897170455
|
@ -570,7 +570,7 @@ handle_add(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
|
||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = addToPlaylist(&g_playlist, uri, NULL);
|
result = playlist_append_uri(&g_playlist, uri, NULL);
|
||||||
return print_playlist_result(client, result);
|
return print_playlist_result(client, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,7 +606,7 @@ handle_addid(struct client *client, int argc, char *argv[])
|
||||||
return COMMAND_RETURN_ERROR;
|
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)
|
if (result != PLAYLIST_RESULT_SUCCESS)
|
||||||
|
@ -616,11 +616,11 @@ handle_addid(struct client *client, int argc, char *argv[])
|
||||||
int to;
|
int to;
|
||||||
if (!check_int(client, &to, argv[2], check_integer, argv[2]))
|
if (!check_int(client, &to, argv[2], check_integer, argv[2]))
|
||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
result = moveSongInPlaylistById(&g_playlist, added_id, to);
|
result = playlist_move_id(&g_playlist, added_id, to);
|
||||||
if (result != PLAYLIST_RESULT_SUCCESS) {
|
if (result != PLAYLIST_RESULT_SUCCESS) {
|
||||||
enum command_return ret =
|
enum command_return ret =
|
||||||
print_playlist_result(client, result);
|
print_playlist_result(client, result);
|
||||||
deleteFromPlaylistById(&g_playlist, added_id);
|
playlist_delete_id(&g_playlist, added_id);
|
||||||
return ret;
|
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))
|
if (!check_int(client, &song, argv[1], need_positive))
|
||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
|
|
||||||
result = deleteFromPlaylist(&g_playlist, song);
|
result = playlist_delete(&g_playlist, song);
|
||||||
return print_playlist_result(client, result);
|
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))
|
if (!check_int(client, &id, argv[1], need_positive))
|
||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
|
|
||||||
result = deleteFromPlaylistById(&g_playlist, id);
|
result = playlist_delete_id(&g_playlist, id);
|
||||||
return print_playlist_result(client, result);
|
return print_playlist_result(client, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,7 +672,7 @@ handle_shuffle(G_GNUC_UNUSED struct client *client,
|
||||||
argv[1], need_range))
|
argv[1], need_range))
|
||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
|
|
||||||
shufflePlaylist(&g_playlist, start, end);
|
playlist_shuffle(&g_playlist, start, end);
|
||||||
return COMMAND_RETURN_OK;
|
return COMMAND_RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,7 +680,7 @@ static enum command_return
|
||||||
handle_clear(G_GNUC_UNUSED struct client *client,
|
handle_clear(G_GNUC_UNUSED struct client *client,
|
||||||
G_GNUC_UNUSED int argc, G_GNUC_UNUSED char *argv[])
|
G_GNUC_UNUSED int argc, G_GNUC_UNUSED char *argv[])
|
||||||
{
|
{
|
||||||
clearPlaylist(&g_playlist);
|
playlist_clear(&g_playlist);
|
||||||
return COMMAND_RETURN_OK;
|
return COMMAND_RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1228,7 +1228,7 @@ handle_move(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
|
||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
if (!check_int(client, &to, argv[2], check_integer, argv[2]))
|
if (!check_int(client, &to, argv[2], check_integer, argv[2]))
|
||||||
return COMMAND_RETURN_ERROR;
|
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);
|
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;
|
return COMMAND_RETURN_ERROR;
|
||||||
if (!check_int(client, &to, argv[2], check_integer, argv[2]))
|
if (!check_int(client, &to, argv[2], check_integer, argv[2]))
|
||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
result = moveSongInPlaylistById(&g_playlist, id, to);
|
result = playlist_move_id(&g_playlist, id, to);
|
||||||
return print_playlist_result(client, result);
|
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;
|
return COMMAND_RETURN_ERROR;
|
||||||
if (!check_int(client, &song2, argv[2], check_integer, argv[2]))
|
if (!check_int(client, &song2, argv[2], check_integer, argv[2]))
|
||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
result = swapSongsInPlaylist(&g_playlist, song1, song2);
|
result = playlist_swap_songs(&g_playlist, song1, song2);
|
||||||
return print_playlist_result(client, result);
|
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;
|
return COMMAND_RETURN_ERROR;
|
||||||
if (!check_int(client, &id2, argv[2], check_integer, argv[2]))
|
if (!check_int(client, &id2, argv[2], check_integer, argv[2]))
|
||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
result = swapSongsInPlaylistById(&g_playlist, id1, id2);
|
result = playlist_swap_songs_id(&g_playlist, id1, id2);
|
||||||
return print_playlist_result(client, result);
|
return print_playlist_result(client, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ int printAllIn(struct client *client, const char *name)
|
||||||
static int
|
static int
|
||||||
directoryAddSongToPlaylist(struct song *song, G_GNUC_UNUSED void *data)
|
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 {
|
struct add_data {
|
||||||
|
|
|
@ -281,7 +281,7 @@ int main(int argc, char *argv[])
|
||||||
path_global_init();
|
path_global_init();
|
||||||
mapper_init();
|
mapper_init();
|
||||||
initPermissions();
|
initPermissions();
|
||||||
initPlaylist();
|
playlist_global_init();
|
||||||
spl_global_init();
|
spl_global_init();
|
||||||
#ifdef ENABLE_ARCHIVE
|
#ifdef ENABLE_ARCHIVE
|
||||||
archive_plugin_init_all();
|
archive_plugin_init_all();
|
||||||
|
@ -344,7 +344,7 @@ int main(int argc, char *argv[])
|
||||||
finishZeroconf();
|
finishZeroconf();
|
||||||
client_manager_deinit();
|
client_manager_deinit();
|
||||||
listen_global_finish();
|
listen_global_finish();
|
||||||
finishPlaylist();
|
playlist_global_finish();
|
||||||
|
|
||||||
start = clock();
|
start = clock();
|
||||||
db_finish();
|
db_finish();
|
||||||
|
|
|
@ -109,7 +109,7 @@ static void syncPlaylistWithQueue(struct playlist *playlist)
|
||||||
playlist->queued = -1;
|
playlist->queued = -1;
|
||||||
|
|
||||||
if(playlist->queue.consume)
|
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);
|
idle_add(IDLE_PLAYER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,9 +93,11 @@ struct playlist {
|
||||||
/** the global playlist object */
|
/** the global playlist object */
|
||||||
extern struct playlist g_playlist;
|
extern struct playlist g_playlist;
|
||||||
|
|
||||||
void initPlaylist(void);
|
void
|
||||||
|
playlist_global_init(void);
|
||||||
|
|
||||||
void finishPlaylist(void);
|
void
|
||||||
|
playlist_global_finish(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
playlist_init(struct playlist *playlist);
|
playlist_init(struct playlist *playlist);
|
||||||
|
@ -115,7 +117,7 @@ playlist_get_queue(const struct playlist *playlist)
|
||||||
return &playlist->queue;
|
return &playlist->queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearPlaylist(struct playlist *playlist);
|
void playlist_clear(struct playlist *playlist);
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
/**
|
/**
|
||||||
|
@ -128,17 +130,18 @@ playlist_append_file(struct playlist *playlist, const char *path, int uid,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum playlist_result
|
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
|
enum playlist_result
|
||||||
addSongToPlaylist(struct playlist *playlist,
|
playlist_append_song(struct playlist *playlist,
|
||||||
struct song *song, unsigned *added_id);
|
struct song *song, unsigned *added_id);
|
||||||
|
|
||||||
enum playlist_result
|
enum playlist_result
|
||||||
deleteFromPlaylist(struct playlist *playlist, unsigned song);
|
playlist_delete(struct playlist *playlist, unsigned song);
|
||||||
|
|
||||||
enum playlist_result
|
enum playlist_result
|
||||||
deleteFromPlaylistById(struct playlist *playlist, unsigned song);
|
playlist_delete_id(struct playlist *playlist, unsigned song);
|
||||||
|
|
||||||
void stopPlaylist(struct playlist *playlist);
|
void stopPlaylist(struct playlist *playlist);
|
||||||
|
|
||||||
|
@ -154,22 +157,23 @@ void syncPlayerAndPlaylist(struct playlist *playlist);
|
||||||
|
|
||||||
void previousSongInPlaylist(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
|
void
|
||||||
deleteASongFromPlaylist(struct playlist *playlist, const struct song *song);
|
playlist_delete_song(struct playlist *playlist, const struct song *song);
|
||||||
|
|
||||||
enum playlist_result
|
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
|
enum playlist_result
|
||||||
moveSongInPlaylistById(struct playlist *playlist, unsigned id, int to);
|
playlist_move_id(struct playlist *playlist, unsigned id, int to);
|
||||||
|
|
||||||
enum playlist_result
|
enum playlist_result
|
||||||
swapSongsInPlaylist(struct playlist *playlist, unsigned song1, unsigned song2);
|
playlist_swap_songs(struct playlist *playlist, unsigned song1, unsigned song2);
|
||||||
|
|
||||||
enum playlist_result
|
enum playlist_result
|
||||||
swapSongsInPlaylistById(struct playlist *playlist, unsigned id1, unsigned id2);
|
playlist_swap_songs_id(struct playlist *playlist, unsigned id1, unsigned id2);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
getPlaylistRepeatStatus(const struct playlist *playlist);
|
getPlaylistRepeatStatus(const struct playlist *playlist);
|
||||||
|
|
|
@ -183,7 +183,7 @@ nextSongInPlaylist(struct playlist *playlist)
|
||||||
|
|
||||||
/* Consume mode removes each played songs. */
|
/* Consume mode removes each played songs. */
|
||||||
if(playlist->queue.consume)
|
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)
|
void previousSongInPlaylist(struct playlist *playlist)
|
||||||
|
|
|
@ -35,14 +35,14 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static void incrPlaylistVersion(struct playlist *playlist)
|
static void playlist_increment_version(struct playlist *playlist)
|
||||||
{
|
{
|
||||||
queue_increment_version(&playlist->queue);
|
queue_increment_version(&playlist->queue);
|
||||||
|
|
||||||
idle_add(IDLE_PLAYLIST);
|
idle_add(IDLE_PLAYLIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearPlaylist(struct playlist *playlist)
|
void playlist_clear(struct playlist *playlist)
|
||||||
{
|
{
|
||||||
stopPlaylist(playlist);
|
stopPlaylist(playlist);
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ void clearPlaylist(struct playlist *playlist)
|
||||||
|
|
||||||
playlist->current = -1;
|
playlist->current = -1;
|
||||||
|
|
||||||
incrPlaylistVersion(playlist);
|
playlist_increment_version(playlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
@ -86,41 +86,12 @@ playlist_append_file(struct playlist *playlist, const char *path, int uid,
|
||||||
if (song == NULL)
|
if (song == NULL)
|
||||||
return PLAYLIST_RESULT_NO_SUCH_SONG;
|
return PLAYLIST_RESULT_NO_SUCH_SONG;
|
||||||
|
|
||||||
return addSongToPlaylist(playlist, song, added_id);
|
return playlist_append_song(playlist, song, added_id);
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
enum playlist_result
|
||||||
addToPlaylist(struct playlist *playlist, const char *url, unsigned *added_id)
|
playlist_append_song(struct playlist *playlist,
|
||||||
{
|
|
||||||
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,
|
|
||||||
struct song *song, unsigned *added_id)
|
struct song *song, unsigned *added_id)
|
||||||
{
|
{
|
||||||
const struct song *queued;
|
const struct song *queued;
|
||||||
|
@ -147,7 +118,7 @@ addSongToPlaylist(struct playlist *playlist,
|
||||||
queue_length(&playlist->queue));
|
queue_length(&playlist->queue));
|
||||||
}
|
}
|
||||||
|
|
||||||
incrPlaylistVersion(playlist);
|
playlist_increment_version(playlist);
|
||||||
|
|
||||||
playlist_update_queued_song(playlist, queued);
|
playlist_update_queued_song(playlist, queued);
|
||||||
|
|
||||||
|
@ -157,8 +128,38 @@ addSongToPlaylist(struct playlist *playlist,
|
||||||
return PLAYLIST_RESULT_SUCCESS;
|
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
|
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;
|
const struct song *queued;
|
||||||
|
|
||||||
|
@ -188,7 +189,7 @@ swapSongsInPlaylist(struct playlist *playlist, unsigned song1, unsigned song2)
|
||||||
playlist->current = song1;
|
playlist->current = song1;
|
||||||
}
|
}
|
||||||
|
|
||||||
incrPlaylistVersion(playlist);
|
playlist_increment_version(playlist);
|
||||||
|
|
||||||
playlist_update_queued_song(playlist, queued);
|
playlist_update_queued_song(playlist, queued);
|
||||||
|
|
||||||
|
@ -196,7 +197,7 @@ swapSongsInPlaylist(struct playlist *playlist, unsigned song1, unsigned song2)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum playlist_result
|
enum playlist_result
|
||||||
swapSongsInPlaylistById(struct playlist *playlist, unsigned id1, unsigned id2)
|
playlist_swap_songs_id(struct playlist *playlist, unsigned id1, unsigned id2)
|
||||||
{
|
{
|
||||||
int song1 = queue_id_to_position(&playlist->queue, id1);
|
int song1 = queue_id_to_position(&playlist->queue, id1);
|
||||||
int song2 = queue_id_to_position(&playlist->queue, id2);
|
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)
|
if (song1 < 0 || song2 < 0)
|
||||||
return PLAYLIST_RESULT_NO_SUCH_SONG;
|
return PLAYLIST_RESULT_NO_SUCH_SONG;
|
||||||
|
|
||||||
return swapSongsInPlaylist(playlist, song1, song2);
|
return playlist_swap_songs(playlist, song1, song2);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum playlist_result
|
enum playlist_result
|
||||||
deleteFromPlaylist(struct playlist *playlist, unsigned song)
|
playlist_delete(struct playlist *playlist, unsigned song)
|
||||||
{
|
{
|
||||||
const struct song *queued;
|
const struct song *queued;
|
||||||
unsigned songOrder;
|
unsigned songOrder;
|
||||||
|
@ -256,7 +257,7 @@ deleteFromPlaylist(struct playlist *playlist, unsigned song)
|
||||||
|
|
||||||
queue_delete(&playlist->queue, song);
|
queue_delete(&playlist->queue, song);
|
||||||
|
|
||||||
incrPlaylistVersion(playlist);
|
playlist_increment_version(playlist);
|
||||||
|
|
||||||
/* update the "current" and "queued" variables */
|
/* update the "current" and "queued" variables */
|
||||||
|
|
||||||
|
@ -270,27 +271,28 @@ deleteFromPlaylist(struct playlist *playlist, unsigned song)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum playlist_result
|
enum playlist_result
|
||||||
deleteFromPlaylistById(struct playlist *playlist, unsigned id)
|
playlist_delete_id(struct playlist *playlist, unsigned id)
|
||||||
{
|
{
|
||||||
int song = queue_id_to_position(&playlist->queue, id);
|
int song = queue_id_to_position(&playlist->queue, id);
|
||||||
if (song < 0)
|
if (song < 0)
|
||||||
return PLAYLIST_RESULT_NO_SUCH_SONG;
|
return PLAYLIST_RESULT_NO_SUCH_SONG;
|
||||||
|
|
||||||
return deleteFromPlaylist(playlist, song);
|
return playlist_delete(playlist, song);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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)
|
for (int i = queue_length(&playlist->queue) - 1; i >= 0; --i)
|
||||||
if (song == queue_get(&playlist->queue, i))
|
if (song == queue_get(&playlist->queue, i))
|
||||||
deleteFromPlaylist(playlist, i);
|
playlist_delete(playlist, i);
|
||||||
|
|
||||||
pc_song_deleted(song);
|
pc_song_deleted(song);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum playlist_result
|
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;
|
const struct song *queued;
|
||||||
int currentSong;
|
int currentSong;
|
||||||
|
@ -342,7 +344,7 @@ moveSongRangeInPlaylist(struct playlist *playlist, unsigned start, unsigned end,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
incrPlaylistVersion(playlist);
|
playlist_increment_version(playlist);
|
||||||
|
|
||||||
playlist_update_queued_song(playlist, queued);
|
playlist_update_queued_song(playlist, queued);
|
||||||
|
|
||||||
|
@ -350,16 +352,17 @@ moveSongRangeInPlaylist(struct playlist *playlist, unsigned start, unsigned end,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum playlist_result
|
enum playlist_result
|
||||||
moveSongInPlaylistById(struct playlist *playlist, unsigned id1, int to)
|
playlist_move_id(struct playlist *playlist, unsigned id1, int to)
|
||||||
{
|
{
|
||||||
int song = queue_id_to_position(&playlist->queue, id1);
|
int song = queue_id_to_position(&playlist->queue, id1);
|
||||||
if (song < 0)
|
if (song < 0)
|
||||||
return PLAYLIST_RESULT_NO_SUCH_SONG;
|
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;
|
const struct song *queued;
|
||||||
|
|
||||||
|
@ -399,7 +402,7 @@ void shufflePlaylist(struct playlist *playlist, unsigned start, unsigned end)
|
||||||
|
|
||||||
queue_shuffle_range(&playlist->queue, start, end);
|
queue_shuffle_range(&playlist->queue, start, end);
|
||||||
|
|
||||||
incrPlaylistVersion(playlist);
|
playlist_increment_version(playlist);
|
||||||
|
|
||||||
playlist_update_queued_song(playlist, queued);
|
playlist_update_queued_song(playlist, queued);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,8 @@ playlist_event(void)
|
||||||
syncPlayerAndPlaylist(&g_playlist);
|
syncPlayerAndPlaylist(&g_playlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initPlaylist(void)
|
void
|
||||||
|
playlist_global_init(void)
|
||||||
{
|
{
|
||||||
playlist_init(&g_playlist);
|
playlist_init(&g_playlist);
|
||||||
|
|
||||||
|
@ -48,7 +49,8 @@ void initPlaylist(void)
|
||||||
event_pipe_register(PIPE_EVENT_PLAYLIST, playlist_event);
|
event_pipe_register(PIPE_EVENT_PLAYLIST, playlist_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void finishPlaylist(void)
|
void
|
||||||
|
playlist_global_finish(void)
|
||||||
{
|
{
|
||||||
playlist_finish(&g_playlist);
|
playlist_finish(&g_playlist);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ playlist_load_spl(struct playlist *playlist, const char *name_utf8)
|
||||||
|
|
||||||
for (unsigned i = 0; i < list->len; ++i) {
|
for (unsigned i = 0; i < list->len; ++i) {
|
||||||
const char *temp = g_ptr_array_index(list, 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 */
|
/* for windows compatibility, convert slashes */
|
||||||
char *temp2 = g_strdup(temp);
|
char *temp2 = g_strdup(temp);
|
||||||
char *p = temp2;
|
char *p = temp2;
|
||||||
|
@ -124,7 +124,7 @@ playlist_load_spl(struct playlist *playlist, const char *name_utf8)
|
||||||
*p = '/';
|
*p = '/';
|
||||||
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_warning("can't add file \"%s\"", temp2);
|
||||||
}
|
}
|
||||||
g_free(temp2);
|
g_free(temp2);
|
||||||
|
|
|
@ -849,7 +849,7 @@ static void song_delete_event(void)
|
||||||
sticker_song_delete(delete);
|
sticker_song_delete(delete);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
deleteASongFromPlaylist(&g_playlist, delete);
|
playlist_delete_song(&g_playlist, delete);
|
||||||
delete = NULL;
|
delete = NULL;
|
||||||
|
|
||||||
notify_signal(&update_notify);
|
notify_signal(&update_notify);
|
||||||
|
|
Loading…
Reference in New Issue