playlist: CamelCaseIsBad
Renamed all playlist functions to non-CamelCase.
This commit is contained in:
		@@ -399,7 +399,7 @@ handle_play(struct client *client, int argc, char *argv[])
 | 
			
		||||
 | 
			
		||||
	if (argc == 2 && !check_int(client, &song, argv[1], need_positive))
 | 
			
		||||
		return COMMAND_RETURN_ERROR;
 | 
			
		||||
	result = playPlaylist(&g_playlist, song);
 | 
			
		||||
	result = playlist_play(&g_playlist, song);
 | 
			
		||||
	return print_playlist_result(client, result);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -412,7 +412,7 @@ handle_playid(struct client *client, int argc, char *argv[])
 | 
			
		||||
	if (argc == 2 && !check_int(client, &id, argv[1], need_positive))
 | 
			
		||||
		return COMMAND_RETURN_ERROR;
 | 
			
		||||
 | 
			
		||||
	result = playPlaylistById(&g_playlist, id);
 | 
			
		||||
	result = playlist_play_id(&g_playlist, id);
 | 
			
		||||
	return print_playlist_result(client, result);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -420,7 +420,7 @@ static enum command_return
 | 
			
		||||
handle_stop(G_GNUC_UNUSED struct client *client,
 | 
			
		||||
	    G_GNUC_UNUSED int argc, G_GNUC_UNUSED char *argv[])
 | 
			
		||||
{
 | 
			
		||||
	stopPlaylist(&g_playlist);
 | 
			
		||||
	playlist_stop(&g_playlist);
 | 
			
		||||
	return COMMAND_RETURN_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -479,21 +479,21 @@ handle_status(struct client *client,
 | 
			
		||||
		      COMMAND_STATUS_CROSSFADE ": %i\n"
 | 
			
		||||
		      COMMAND_STATUS_STATE ": %s\n",
 | 
			
		||||
		      volume_level_get(),
 | 
			
		||||
		      getPlaylistRepeatStatus(&g_playlist),
 | 
			
		||||
		      getPlaylistRandomStatus(&g_playlist),
 | 
			
		||||
		      getPlaylistSingleStatus(&g_playlist),
 | 
			
		||||
		      getPlaylistConsumeStatus(&g_playlist),
 | 
			
		||||
		      getPlaylistVersion(&g_playlist),
 | 
			
		||||
		      getPlaylistLength(&g_playlist),
 | 
			
		||||
		      playlist_get_repeat(&g_playlist),
 | 
			
		||||
		      playlist_get_random(&g_playlist),
 | 
			
		||||
		      playlist_get_single(&g_playlist),
 | 
			
		||||
		      playlist_get_consume(&g_playlist),
 | 
			
		||||
		      playlist_get_version(&g_playlist),
 | 
			
		||||
		      playlist_get_length(&g_playlist),
 | 
			
		||||
		      (int)(getPlayerCrossFade() + 0.5),
 | 
			
		||||
		      state);
 | 
			
		||||
 | 
			
		||||
	song = getPlaylistCurrentSong(&g_playlist);
 | 
			
		||||
	song = playlist_get_current_song(&g_playlist);
 | 
			
		||||
	if (song >= 0) {
 | 
			
		||||
		client_printf(client,
 | 
			
		||||
			      COMMAND_STATUS_SONG ": %i\n"
 | 
			
		||||
			      COMMAND_STATUS_SONGID ": %u\n",
 | 
			
		||||
			      song, getPlaylistSongId(&g_playlist, song));
 | 
			
		||||
			      song, playlist_get_song_id(&g_playlist, song));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (getPlayerState() != PLAYER_STATE_STOP) {
 | 
			
		||||
@@ -521,12 +521,12 @@ handle_status(struct client *client,
 | 
			
		||||
			      getPlayerErrorStr());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	song = getPlaylistNextSong(&g_playlist);
 | 
			
		||||
	song = playlist_get_next_song(&g_playlist);
 | 
			
		||||
	if (song >= 0) {
 | 
			
		||||
		client_printf(client,
 | 
			
		||||
			      COMMAND_STATUS_NEXTSONG ": %i\n"
 | 
			
		||||
			      COMMAND_STATUS_NEXTSONGID ": %u\n",
 | 
			
		||||
			      song, getPlaylistSongId(&g_playlist, song));
 | 
			
		||||
			      song, playlist_get_song_id(&g_playlist, song));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return COMMAND_RETURN_OK;
 | 
			
		||||
@@ -1021,7 +1021,7 @@ handle_next(G_GNUC_UNUSED struct client *client,
 | 
			
		||||
	int single = g_playlist.queue.single;
 | 
			
		||||
	g_playlist.queue.single = false;
 | 
			
		||||
 | 
			
		||||
	nextSongInPlaylist(&g_playlist);
 | 
			
		||||
	playlist_next(&g_playlist);
 | 
			
		||||
 | 
			
		||||
	g_playlist.queue.single = single;
 | 
			
		||||
	return COMMAND_RETURN_OK;
 | 
			
		||||
@@ -1031,7 +1031,7 @@ static enum command_return
 | 
			
		||||
handle_previous(G_GNUC_UNUSED struct client *client,
 | 
			
		||||
		G_GNUC_UNUSED int argc, G_GNUC_UNUSED char *argv[])
 | 
			
		||||
{
 | 
			
		||||
	previousSongInPlaylist(&g_playlist);
 | 
			
		||||
	playlist_previous(&g_playlist);
 | 
			
		||||
	return COMMAND_RETURN_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1090,7 +1090,7 @@ handle_repeat(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
 | 
			
		||||
		return COMMAND_RETURN_ERROR;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	setPlaylistRepeatStatus(&g_playlist, status);
 | 
			
		||||
	playlist_set_repeat(&g_playlist, status);
 | 
			
		||||
	return COMMAND_RETURN_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1108,7 +1108,7 @@ handle_single(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
 | 
			
		||||
		return COMMAND_RETURN_ERROR;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	setPlaylistSingleStatus(&g_playlist, status);
 | 
			
		||||
	playlist_set_single(&g_playlist, status);
 | 
			
		||||
	return COMMAND_RETURN_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1126,7 +1126,7 @@ handle_consume(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
 | 
			
		||||
		return COMMAND_RETURN_ERROR;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	setPlaylistConsumeStatus(&g_playlist, status);
 | 
			
		||||
	playlist_set_consume(&g_playlist, status);
 | 
			
		||||
	return COMMAND_RETURN_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1144,7 +1144,7 @@ handle_random(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
 | 
			
		||||
		return COMMAND_RETURN_ERROR;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	setPlaylistRandomStatus(&g_playlist, status);
 | 
			
		||||
	playlist_set_random(&g_playlist, status);
 | 
			
		||||
	return COMMAND_RETURN_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1285,7 +1285,7 @@ handle_seek(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
 | 
			
		||||
	if (!check_int(client, &seek_time, argv[2], check_integer, argv[2]))
 | 
			
		||||
		return COMMAND_RETURN_ERROR;
 | 
			
		||||
 | 
			
		||||
	result = seekSongInPlaylist(&g_playlist, song, seek_time);
 | 
			
		||||
	result = playlist_seek_song(&g_playlist, song, seek_time);
 | 
			
		||||
	return print_playlist_result(client, result);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1300,7 +1300,7 @@ handle_seekid(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
 | 
			
		||||
	if (!check_int(client, &seek_time, argv[2], check_integer, argv[2]))
 | 
			
		||||
		return COMMAND_RETURN_ERROR;
 | 
			
		||||
 | 
			
		||||
	result = seekSongInPlaylistById(&g_playlist, id, seek_time);
 | 
			
		||||
	result = playlist_seek_song_id(&g_playlist, id, seek_time);
 | 
			
		||||
	return print_playlist_result(client, result);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ enum pipe_event {
 | 
			
		||||
	/** an idle event was emitted */
 | 
			
		||||
	PIPE_EVENT_IDLE,
 | 
			
		||||
 | 
			
		||||
	/** must call syncPlayerAndPlaylist() */
 | 
			
		||||
	/** must call playlist_sync() */
 | 
			
		||||
	PIPE_EVENT_PLAYLIST,
 | 
			
		||||
 | 
			
		||||
	/** the current song's tag has changed */
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,8 @@
 | 
			
		||||
#undef G_LOG_DOMAIN
 | 
			
		||||
#define G_LOG_DOMAIN "playlist"
 | 
			
		||||
 | 
			
		||||
void playlistVersionChange(struct playlist *playlist)
 | 
			
		||||
void
 | 
			
		||||
playlist_increment_version_all(struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	queue_modify_all(&playlist->queue);
 | 
			
		||||
	idle_add(IDLE_PLAYLIST);
 | 
			
		||||
@@ -98,7 +99,8 @@ playlist_queue_song_order(struct playlist *playlist, unsigned order)
 | 
			
		||||
 * Check if the player thread has already started playing the "queued"
 | 
			
		||||
 * song.
 | 
			
		||||
 */
 | 
			
		||||
static void syncPlaylistWithQueue(struct playlist *playlist)
 | 
			
		||||
static void
 | 
			
		||||
playlist_sync_with_queue(struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	if (pc.next_song == NULL && playlist->queued != -1) {
 | 
			
		||||
		/* queued song has started: copy queued to current,
 | 
			
		||||
@@ -178,7 +180,7 @@ playlist_update_queued_song(struct playlist *playlist, const struct song *prev)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
playPlaylistOrderNumber(struct playlist *playlist, int orderNum)
 | 
			
		||||
playlist_play_order(struct playlist *playlist, int orderNum)
 | 
			
		||||
{
 | 
			
		||||
	struct song *song;
 | 
			
		||||
	char *uri;
 | 
			
		||||
@@ -197,13 +199,14 @@ playPlaylistOrderNumber(struct playlist *playlist, int orderNum)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
playPlaylistIfPlayerStopped(struct playlist *playlist);
 | 
			
		||||
playlist_resume_playback(struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This is the "PLAYLIST" event handler.  It is invoked by the player
 | 
			
		||||
 * thread whenever it requests a new queued song, or when it exits.
 | 
			
		||||
 */
 | 
			
		||||
void syncPlayerAndPlaylist(struct playlist *playlist)
 | 
			
		||||
void
 | 
			
		||||
playlist_sync(struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	if (!playlist->playing)
 | 
			
		||||
		/* this event has reached us out of sync: we aren't
 | 
			
		||||
@@ -215,11 +218,11 @@ void syncPlayerAndPlaylist(struct playlist *playlist)
 | 
			
		||||
		   should be restarted with the next song.  That can
 | 
			
		||||
		   happen if the playlist isn't filling the queue fast
 | 
			
		||||
		   enough */
 | 
			
		||||
		playPlaylistIfPlayerStopped(playlist);
 | 
			
		||||
		playlist_resume_playback(playlist);
 | 
			
		||||
	else {
 | 
			
		||||
		/* check if the player thread has already started
 | 
			
		||||
		   playing the queued song */
 | 
			
		||||
		syncPlaylistWithQueue(playlist);
 | 
			
		||||
		playlist_sync_with_queue(playlist);
 | 
			
		||||
 | 
			
		||||
		/* make sure the queued song is always set (if
 | 
			
		||||
		   possible) */
 | 
			
		||||
@@ -233,7 +236,7 @@ void syncPlayerAndPlaylist(struct playlist *playlist)
 | 
			
		||||
 * decide whether to re-start playback
 | 
			
		||||
 */
 | 
			
		||||
static void
 | 
			
		||||
playPlaylistIfPlayerStopped(struct playlist *playlist)
 | 
			
		||||
playlist_resume_playback(struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	enum player_error error;
 | 
			
		||||
 | 
			
		||||
@@ -251,37 +254,38 @@ playPlaylistIfPlayerStopped(struct playlist *playlist)
 | 
			
		||||
	    playlist->error_count >= queue_length(&playlist->queue))
 | 
			
		||||
		/* too many errors, or critical error: stop
 | 
			
		||||
		   playback */
 | 
			
		||||
		stopPlaylist(playlist);
 | 
			
		||||
		playlist_stop(playlist);
 | 
			
		||||
	else
 | 
			
		||||
		/* continue playback at the next song */
 | 
			
		||||
		nextSongInPlaylist(playlist);
 | 
			
		||||
		playlist_next(playlist);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
getPlaylistRepeatStatus(const struct playlist *playlist)
 | 
			
		||||
playlist_get_repeat(const struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	return playlist->queue.repeat;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
getPlaylistRandomStatus(const struct playlist *playlist)
 | 
			
		||||
playlist_get_random(const struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	return playlist->queue.random;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
getPlaylistSingleStatus(const struct playlist *playlist)
 | 
			
		||||
playlist_get_single(const struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	return playlist->queue.single;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
getPlaylistConsumeStatus(const struct playlist *playlist)
 | 
			
		||||
playlist_get_consume(const struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	return playlist->queue.consume;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void setPlaylistRepeatStatus(struct playlist *playlist, bool status)
 | 
			
		||||
void
 | 
			
		||||
playlist_set_repeat(struct playlist *playlist, bool status)
 | 
			
		||||
{
 | 
			
		||||
	if (status == playlist->queue.repeat)
 | 
			
		||||
		return;
 | 
			
		||||
@@ -296,7 +300,8 @@ void setPlaylistRepeatStatus(struct playlist *playlist, bool status)
 | 
			
		||||
	idle_add(IDLE_OPTIONS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void orderPlaylist(struct playlist *playlist)
 | 
			
		||||
static void
 | 
			
		||||
playlist_order(struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	if (playlist->current >= 0)
 | 
			
		||||
		/* update playlist.current, order==position now */
 | 
			
		||||
@@ -306,7 +311,8 @@ static void orderPlaylist(struct playlist *playlist)
 | 
			
		||||
	queue_restore_order(&playlist->queue);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void setPlaylistSingleStatus(struct playlist *playlist, bool status)
 | 
			
		||||
void
 | 
			
		||||
playlist_set_single(struct playlist *playlist, bool status)
 | 
			
		||||
{
 | 
			
		||||
	if (status == playlist->queue.single)
 | 
			
		||||
		return;
 | 
			
		||||
@@ -321,7 +327,8 @@ void setPlaylistSingleStatus(struct playlist *playlist, bool status)
 | 
			
		||||
	idle_add(IDLE_OPTIONS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void setPlaylistConsumeStatus(struct playlist *playlist, bool status)
 | 
			
		||||
void
 | 
			
		||||
playlist_set_consume(struct playlist *playlist, bool status)
 | 
			
		||||
{
 | 
			
		||||
	if (status == playlist->queue.consume)
 | 
			
		||||
		return;
 | 
			
		||||
@@ -330,7 +337,8 @@ void setPlaylistConsumeStatus(struct playlist *playlist, bool status)
 | 
			
		||||
	idle_add(IDLE_OPTIONS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void setPlaylistRandomStatus(struct playlist *playlist, bool status)
 | 
			
		||||
void
 | 
			
		||||
playlist_set_random(struct playlist *playlist, bool status)
 | 
			
		||||
{
 | 
			
		||||
	const struct song *queued;
 | 
			
		||||
 | 
			
		||||
@@ -365,14 +373,15 @@ void setPlaylistRandomStatus(struct playlist *playlist, bool status)
 | 
			
		||||
		} else
 | 
			
		||||
			playlist->current = -1;
 | 
			
		||||
	} else
 | 
			
		||||
		orderPlaylist(playlist);
 | 
			
		||||
		playlist_order(playlist);
 | 
			
		||||
 | 
			
		||||
	playlist_update_queued_song(playlist, queued);
 | 
			
		||||
 | 
			
		||||
	idle_add(IDLE_OPTIONS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int getPlaylistCurrentSong(const struct playlist *playlist)
 | 
			
		||||
int
 | 
			
		||||
playlist_get_current_song(const struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	if (playlist->current >= 0)
 | 
			
		||||
		return queue_order_to_position(&playlist->queue,
 | 
			
		||||
@@ -381,7 +390,8 @@ int getPlaylistCurrentSong(const struct playlist *playlist)
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int getPlaylistNextSong(const struct playlist *playlist)
 | 
			
		||||
int
 | 
			
		||||
playlist_get_next_song(const struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	if (playlist->current >= 0)
 | 
			
		||||
	{
 | 
			
		||||
@@ -404,19 +414,19 @@ int getPlaylistNextSong(const struct playlist *playlist)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned long
 | 
			
		||||
getPlaylistVersion(const struct playlist *playlist)
 | 
			
		||||
playlist_get_version(const struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	return playlist->queue.version;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
getPlaylistLength(const struct playlist *playlist)
 | 
			
		||||
playlist_get_length(const struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	return queue_length(&playlist->queue);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned
 | 
			
		||||
getPlaylistSongId(const struct playlist *playlist, unsigned song)
 | 
			
		||||
playlist_get_song_id(const struct playlist *playlist, unsigned song)
 | 
			
		||||
{
 | 
			
		||||
	return queue_position_to_id(&playlist->queue, song);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -117,7 +117,8 @@ playlist_get_queue(const struct playlist *playlist)
 | 
			
		||||
	return &playlist->queue;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void playlist_clear(struct playlist *playlist);
 | 
			
		||||
void
 | 
			
		||||
playlist_clear(struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
#ifndef WIN32
 | 
			
		||||
/**
 | 
			
		||||
@@ -143,19 +144,23 @@ playlist_delete(struct playlist *playlist, unsigned song);
 | 
			
		||||
enum playlist_result
 | 
			
		||||
playlist_delete_id(struct playlist *playlist, unsigned song);
 | 
			
		||||
 | 
			
		||||
void stopPlaylist(struct playlist *playlist);
 | 
			
		||||
void
 | 
			
		||||
playlist_stop(struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
enum playlist_result
 | 
			
		||||
playPlaylist(struct playlist *playlist, int song);
 | 
			
		||||
playlist_play(struct playlist *playlist, int song);
 | 
			
		||||
 | 
			
		||||
enum playlist_result
 | 
			
		||||
playPlaylistById(struct playlist *playlist, int song);
 | 
			
		||||
playlist_play_id(struct playlist *playlist, int song);
 | 
			
		||||
 | 
			
		||||
void nextSongInPlaylist(struct playlist *playlist);
 | 
			
		||||
void
 | 
			
		||||
playlist_next(struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
void syncPlayerAndPlaylist(struct playlist *playlist);
 | 
			
		||||
void
 | 
			
		||||
playlist_sync(struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
void previousSongInPlaylist(struct playlist *playlist);
 | 
			
		||||
void
 | 
			
		||||
playlist_previous(struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
playlist_shuffle(struct playlist *playlist, unsigned start, unsigned end);
 | 
			
		||||
@@ -176,46 +181,52 @@ enum playlist_result
 | 
			
		||||
playlist_swap_songs_id(struct playlist *playlist, unsigned id1, unsigned id2);
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
getPlaylistRepeatStatus(const struct playlist *playlist);
 | 
			
		||||
playlist_get_repeat(const struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
void setPlaylistRepeatStatus(struct playlist *playlist, bool status);
 | 
			
		||||
void
 | 
			
		||||
playlist_set_repeat(struct playlist *playlist, bool status);
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
getPlaylistRandomStatus(const struct playlist *playlist);
 | 
			
		||||
playlist_get_random(const struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
void setPlaylistRandomStatus(struct playlist *playlist, bool status);
 | 
			
		||||
void
 | 
			
		||||
playlist_set_random(struct playlist *playlist, bool status);
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
getPlaylistSingleStatus(const struct playlist *playlist);
 | 
			
		||||
playlist_get_single(const struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
void setPlaylistSingleStatus(struct playlist *playlist, bool status);
 | 
			
		||||
void
 | 
			
		||||
playlist_set_single(struct playlist *playlist, bool status);
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
getPlaylistConsumeStatus(const struct playlist *playlist);
 | 
			
		||||
playlist_get_consume(const struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
void setPlaylistConsumeStatus(struct playlist *playlist, bool status);
 | 
			
		||||
void
 | 
			
		||||
playlist_set_consume(struct playlist *playlist, bool status);
 | 
			
		||||
 | 
			
		||||
int getPlaylistCurrentSong(const struct playlist *playlist);
 | 
			
		||||
int
 | 
			
		||||
playlist_get_current_song(const struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
int getPlaylistNextSong(const struct playlist *playlist);
 | 
			
		||||
int
 | 
			
		||||
playlist_get_next_song(const struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
unsigned
 | 
			
		||||
getPlaylistSongId(const struct playlist *playlist, unsigned song);
 | 
			
		||||
playlist_get_song_id(const struct playlist *playlist, unsigned song);
 | 
			
		||||
 | 
			
		||||
int getPlaylistLength(const struct playlist *playlist);
 | 
			
		||||
int
 | 
			
		||||
playlist_get_length(const struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
unsigned long
 | 
			
		||||
getPlaylistVersion(const struct playlist *playlist);
 | 
			
		||||
playlist_get_version(const struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
enum playlist_result
 | 
			
		||||
seekSongInPlaylist(struct playlist *playlist, unsigned song, float seek_time);
 | 
			
		||||
playlist_seek_song(struct playlist *playlist, unsigned song, float seek_time);
 | 
			
		||||
 | 
			
		||||
enum playlist_result
 | 
			
		||||
seekSongInPlaylistById(struct playlist *playlist,
 | 
			
		||||
playlist_seek_song_id(struct playlist *playlist,
 | 
			
		||||
		       unsigned id, float seek_time);
 | 
			
		||||
 | 
			
		||||
void playlistVersionChange(struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
int is_valid_playlist_name(const char *utf8path);
 | 
			
		||||
void
 | 
			
		||||
playlist_increment_version_all(struct playlist *playlist);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ enum {
 | 
			
		||||
	PLAYLIST_PREV_UNLESS_ELAPSED = 10,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void stopPlaylist(struct playlist *playlist)
 | 
			
		||||
void playlist_stop(struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	if (!playlist->playing)
 | 
			
		||||
		return;
 | 
			
		||||
@@ -68,7 +68,7 @@ void stopPlaylist(struct playlist *playlist)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
enum playlist_result playPlaylist(struct playlist *playlist, int song)
 | 
			
		||||
enum playlist_result playlist_play(struct playlist *playlist, int song)
 | 
			
		||||
{
 | 
			
		||||
	unsigned i = song;
 | 
			
		||||
 | 
			
		||||
@@ -115,28 +115,28 @@ enum playlist_result playPlaylist(struct playlist *playlist, int song)
 | 
			
		||||
	playlist->stop_on_error = false;
 | 
			
		||||
	playlist->error_count = 0;
 | 
			
		||||
 | 
			
		||||
	playPlaylistOrderNumber(playlist, i);
 | 
			
		||||
	playlist_play_order(playlist, i);
 | 
			
		||||
	return PLAYLIST_RESULT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
enum playlist_result
 | 
			
		||||
playPlaylistById(struct playlist *playlist, int id)
 | 
			
		||||
playlist_play_id(struct playlist *playlist, int id)
 | 
			
		||||
{
 | 
			
		||||
	int song;
 | 
			
		||||
 | 
			
		||||
	if (id == -1) {
 | 
			
		||||
		return playPlaylist(playlist, id);
 | 
			
		||||
		return playlist_play(playlist, id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	song = queue_id_to_position(&playlist->queue, id);
 | 
			
		||||
	if (song < 0)
 | 
			
		||||
		return PLAYLIST_RESULT_NO_SUCH_SONG;
 | 
			
		||||
 | 
			
		||||
	return playPlaylist(playlist, song);
 | 
			
		||||
	return playlist_play(playlist, song);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
nextSongInPlaylist(struct playlist *playlist)
 | 
			
		||||
playlist_next(struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	int next_order;
 | 
			
		||||
	int current;
 | 
			
		||||
@@ -157,7 +157,7 @@ nextSongInPlaylist(struct playlist *playlist)
 | 
			
		||||
		/* cancel single */
 | 
			
		||||
		playlist->queue.single = false;
 | 
			
		||||
		/* no song after this one: stop playback */
 | 
			
		||||
		stopPlaylist(playlist);
 | 
			
		||||
		playlist_stop(playlist);
 | 
			
		||||
 | 
			
		||||
		/* reset "current song" */
 | 
			
		||||
		playlist->current = -1;
 | 
			
		||||
@@ -174,11 +174,11 @@ nextSongInPlaylist(struct playlist *playlist)
 | 
			
		||||
			queue_shuffle_order(&playlist->queue);
 | 
			
		||||
 | 
			
		||||
			/* note that playlist->current and playlist->queued are
 | 
			
		||||
			   now invalid, but playPlaylistOrderNumber() will
 | 
			
		||||
			   now invalid, but playlist_play_order() will
 | 
			
		||||
			   discard them anyway */
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		playPlaylistOrderNumber(playlist, next_order);
 | 
			
		||||
		playlist_play_order(playlist, next_order);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Consume mode removes each played songs. */
 | 
			
		||||
@@ -186,7 +186,7 @@ nextSongInPlaylist(struct playlist *playlist)
 | 
			
		||||
		playlist_delete(playlist, queue_order_to_position(&playlist->queue, current));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void previousSongInPlaylist(struct playlist *playlist)
 | 
			
		||||
void playlist_previous(struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	if (!playlist->playing)
 | 
			
		||||
		return;
 | 
			
		||||
@@ -196,20 +196,20 @@ void previousSongInPlaylist(struct playlist *playlist)
 | 
			
		||||
		/* re-start playing the current song (just like the
 | 
			
		||||
		   "prev" button on CD players) */
 | 
			
		||||
 | 
			
		||||
		playPlaylistOrderNumber(playlist, playlist->current);
 | 
			
		||||
		playlist_play_order(playlist, playlist->current);
 | 
			
		||||
	} else {
 | 
			
		||||
		if (playlist->current > 0) {
 | 
			
		||||
			/* play the preceding song */
 | 
			
		||||
			playPlaylistOrderNumber(playlist,
 | 
			
		||||
			playlist_play_order(playlist,
 | 
			
		||||
						playlist->current - 1);
 | 
			
		||||
		} else if (playlist->queue.repeat) {
 | 
			
		||||
			/* play the last song in "repeat" mode */
 | 
			
		||||
			playPlaylistOrderNumber(playlist,
 | 
			
		||||
			playlist_play_order(playlist,
 | 
			
		||||
						queue_length(&playlist->queue) - 1);
 | 
			
		||||
		} else {
 | 
			
		||||
			/* re-start playing the current song if it's
 | 
			
		||||
			   the first one */
 | 
			
		||||
			playPlaylistOrderNumber(playlist, playlist->current);
 | 
			
		||||
			playlist_play_order(playlist, playlist->current);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -217,7 +217,7 @@ void previousSongInPlaylist(struct playlist *playlist)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
enum playlist_result
 | 
			
		||||
seekSongInPlaylist(struct playlist *playlist, unsigned song, float seek_time)
 | 
			
		||||
playlist_seek_song(struct playlist *playlist, unsigned song, float seek_time)
 | 
			
		||||
{
 | 
			
		||||
	const struct song *queued;
 | 
			
		||||
	unsigned i;
 | 
			
		||||
@@ -241,7 +241,7 @@ seekSongInPlaylist(struct playlist *playlist, unsigned song, float seek_time)
 | 
			
		||||
		/* seeking is not within the current song - first
 | 
			
		||||
		   start playing the new song */
 | 
			
		||||
 | 
			
		||||
		playPlaylistOrderNumber(playlist, i);
 | 
			
		||||
		playlist_play_order(playlist, i);
 | 
			
		||||
		queued = NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -259,11 +259,11 @@ seekSongInPlaylist(struct playlist *playlist, unsigned song, float seek_time)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
enum playlist_result
 | 
			
		||||
seekSongInPlaylistById(struct playlist *playlist, unsigned id, float seek_time)
 | 
			
		||||
playlist_seek_song_id(struct playlist *playlist, unsigned id, float seek_time)
 | 
			
		||||
{
 | 
			
		||||
	int song = queue_id_to_position(&playlist->queue, id);
 | 
			
		||||
	if (song < 0)
 | 
			
		||||
		return PLAYLIST_RESULT_NO_SUCH_SONG;
 | 
			
		||||
 | 
			
		||||
	return seekSongInPlaylist(playlist, song, seek_time);
 | 
			
		||||
	return playlist_seek_song(playlist, song, seek_time);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,7 @@ static void playlist_increment_version(struct playlist *playlist)
 | 
			
		||||
 | 
			
		||||
void playlist_clear(struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	stopPlaylist(playlist);
 | 
			
		||||
	playlist_stop(playlist);
 | 
			
		||||
 | 
			
		||||
	/* make sure there are no references to allocated songs
 | 
			
		||||
	   anymore */
 | 
			
		||||
@@ -238,11 +238,11 @@ playlist_delete(struct playlist *playlist, unsigned song)
 | 
			
		||||
 | 
			
		||||
		if (playlist->current >= 0 && !paused)
 | 
			
		||||
			/* play the song after the deleted one */
 | 
			
		||||
			playPlaylistOrderNumber(playlist, playlist->current);
 | 
			
		||||
			playlist_play_order(playlist, playlist->current);
 | 
			
		||||
		else
 | 
			
		||||
			/* no songs left to play, stop playback
 | 
			
		||||
			   completely */
 | 
			
		||||
			stopPlaylist(playlist);
 | 
			
		||||
			playlist_stop(playlist);
 | 
			
		||||
 | 
			
		||||
		queued = NULL;
 | 
			
		||||
	} else if (playlist->current == (int)songOrder)
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,7 @@ playlist_tag_event(void)
 | 
			
		||||
static void
 | 
			
		||||
playlist_event(void)
 | 
			
		||||
{
 | 
			
		||||
	syncPlayerAndPlaylist(&g_playlist);
 | 
			
		||||
	playlist_sync(&g_playlist);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
 
 | 
			
		||||
@@ -47,6 +47,6 @@ playlist_update_queued_song(struct playlist *playlist,
 | 
			
		||||
			    const struct song *prev);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
playPlaylistOrderNumber(struct playlist *playlist, int orderNum);
 | 
			
		||||
playlist_play_order(struct playlist *playlist, int orderNum);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -69,7 +69,7 @@ playlist_print_id(struct client *client, const struct playlist *playlist,
 | 
			
		||||
bool
 | 
			
		||||
playlist_print_current(struct client *client, const struct playlist *playlist)
 | 
			
		||||
{
 | 
			
		||||
	int current_position = getPlaylistCurrentSong(playlist);
 | 
			
		||||
	int current_position = playlist_get_current_song(playlist);
 | 
			
		||||
 | 
			
		||||
	if (current_position < 0)
 | 
			
		||||
		return false;
 | 
			
		||||
 
 | 
			
		||||
@@ -144,23 +144,23 @@ playlist_state_restore(const char *line, FILE *fp, struct playlist *playlist)
 | 
			
		||||
			if (strcmp
 | 
			
		||||
			    (&(buffer[strlen(PLAYLIST_STATE_FILE_REPEAT)]),
 | 
			
		||||
			     "1") == 0) {
 | 
			
		||||
				setPlaylistRepeatStatus(playlist, true);
 | 
			
		||||
				playlist_set_repeat(playlist, true);
 | 
			
		||||
			} else
 | 
			
		||||
				setPlaylistRepeatStatus(playlist, false);
 | 
			
		||||
				playlist_set_repeat(playlist, false);
 | 
			
		||||
		} else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_SINGLE)) {
 | 
			
		||||
			if (strcmp
 | 
			
		||||
			    (&(buffer[strlen(PLAYLIST_STATE_FILE_SINGLE)]),
 | 
			
		||||
			     "1") == 0) {
 | 
			
		||||
				setPlaylistSingleStatus(playlist, true);
 | 
			
		||||
				playlist_set_single(playlist, true);
 | 
			
		||||
			} else
 | 
			
		||||
				setPlaylistSingleStatus(playlist, false);
 | 
			
		||||
				playlist_set_single(playlist, false);
 | 
			
		||||
		} else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_CONSUME)) {
 | 
			
		||||
			if (strcmp
 | 
			
		||||
			    (&(buffer[strlen(PLAYLIST_STATE_FILE_CONSUME)]),
 | 
			
		||||
			     "1") == 0) {
 | 
			
		||||
				setPlaylistConsumeStatus(playlist, true);
 | 
			
		||||
				playlist_set_consume(playlist, true);
 | 
			
		||||
			} else
 | 
			
		||||
				setPlaylistConsumeStatus(playlist, false);
 | 
			
		||||
				playlist_set_consume(playlist, false);
 | 
			
		||||
		} else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_CROSSFADE)) {
 | 
			
		||||
			setPlayerCrossFade(atoi
 | 
			
		||||
					   (&
 | 
			
		||||
@@ -181,7 +181,7 @@ playlist_state_restore(const char *line, FILE *fp, struct playlist *playlist)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	setPlaylistRandomStatus(playlist, random_mode);
 | 
			
		||||
	playlist_set_random(playlist, random_mode);
 | 
			
		||||
 | 
			
		||||
	if (!queue_is_empty(&playlist->queue)) {
 | 
			
		||||
		if (!queue_valid_position(&playlist->queue, current))
 | 
			
		||||
@@ -190,9 +190,9 @@ playlist_state_restore(const char *line, FILE *fp, struct playlist *playlist)
 | 
			
		||||
		if (state == PLAYER_STATE_STOP /* && config_option */)
 | 
			
		||||
			playlist->current = current;
 | 
			
		||||
		else if (seek_time == 0)
 | 
			
		||||
			playPlaylist(playlist, current);
 | 
			
		||||
			playlist_play(playlist, current);
 | 
			
		||||
		else
 | 
			
		||||
			seekSongInPlaylist(playlist, current, seek_time);
 | 
			
		||||
			playlist_seek_song(playlist, current, seek_time);
 | 
			
		||||
 | 
			
		||||
		if (state == PLAYER_STATE_PAUSE)
 | 
			
		||||
			playerPause();
 | 
			
		||||
 
 | 
			
		||||
@@ -868,7 +868,7 @@ static void update_finished_event(void)
 | 
			
		||||
 | 
			
		||||
	if (modified) {
 | 
			
		||||
		/* send "idle" events */
 | 
			
		||||
		playlistVersionChange(&g_playlist);
 | 
			
		||||
		playlist_increment_version_all(&g_playlist);
 | 
			
		||||
		idle_add(IDLE_DATABASE);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user