diff options
author | Max Kellermann <max@duempel.org> | 2009-01-04 19:09:34 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-04 19:09:34 +0100 |
commit | fed719197c7014151710c4aae9174990fd131d59 (patch) | |
tree | 0fb6d6f69aa60ecdf9eb89286f8354316fffcc92 /src/playlist.c | |
parent | ea8ae68e6f1a686fd96530fdaf7b428e33f58ec4 (diff) | |
download | mpd-fed719197c7014151710c4aae9174990fd131d59.tar.gz mpd-fed719197c7014151710c4aae9174990fd131d59.tar.xz mpd-fed719197c7014151710c4aae9174990fd131d59.zip |
song: allocate the result of song_get_url()
Diffstat (limited to '')
-rw-r--r-- | src/playlist.c | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/src/playlist.c b/src/playlist.c index 414e5a63a..df60fe99b 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -224,20 +224,20 @@ void clearPlaylist(void) void showPlaylist(struct client *client) { - char path_max_tmp[MPD_PATH_MAX]; - - for (unsigned i = 0; i < playlist.length; i++) - client_printf(client, "%i:%s\n", i, - song_get_url(playlist.songs[i], path_max_tmp)); + for (unsigned i = 0; i < playlist.length; i++) { + char *uri = song_get_uri(playlist.songs[i]); + client_printf(client, "%i:%s\n", i, uri); + g_free(uri); + } } static void playlist_save(FILE *fp) { - char path_max_tmp[MPD_PATH_MAX]; - - for (unsigned i = 0; i < playlist.length; i++) - fprintf(fp, "%i:%s\n", i, - song_get_url(playlist.songs[i], path_max_tmp)); + for (unsigned i = 0; i < playlist.length; i++) { + char *uri = song_get_uri(playlist.songs[i]); + fprintf(fp, "%i:%s\n", i, uri); + g_free(uri); + } } void savePlaylistState(FILE *fp) @@ -483,26 +483,30 @@ static void swapSongs(unsigned song1, unsigned song2) static void queueNextSongInPlaylist(void) { - char path_max_tmp[MPD_PATH_MAX]; - if (playlist.current < (int)playlist.length - 1) { + char *uri; + playlist.queued = playlist.current + 1; + + uri = song_get_uri(playlist. songs[playlist.order[playlist.queued]]); g_debug("playlist: queue song %i:\"%s\"", - playlist.queued, - song_get_url(playlist. - songs[playlist.order[playlist.queued]], - path_max_tmp)); + playlist.queued, uri); + g_free(uri); + queueSong(playlist.songs[playlist.order[playlist.queued]]); } else if (playlist.length && playlist.repeat) { + char *uri; + if (playlist.length > 1 && playlist.random) { randomizeOrder(0, playlist.length - 1); } playlist.queued = 0; + + uri = song_get_uri(playlist. songs[playlist.order[playlist.queued]]); g_debug("playlist: queue song %i:\"%s\"", - playlist.queued, - song_get_url(playlist. - songs[playlist.order[playlist.queued]], - path_max_tmp)); + playlist.queued, uri); + g_free(uri); + queueSong(playlist.songs[playlist.order[playlist.queued]]); } } @@ -783,15 +787,15 @@ void stopPlaylist(void) static void playPlaylistOrderNumber(int orderNum) { - char path_max_tmp[MPD_PATH_MAX]; + char *uri; playlist_state = PLAYLIST_STATE_PLAY; playlist_noGoToNext = 0; playlist.queued = -1; - g_debug("playlist: play %i:\"%s\"", orderNum, - song_get_url(playlist.songs[playlist.order[orderNum]], - path_max_tmp)); + uri = song_get_uri(playlist.songs[playlist.order[orderNum]]); + g_debug("playlist: play %i:\"%s\"", orderNum, uri); + g_free(uri); playerPlay(playlist.songs[playlist.order[orderNum]]); playlist.current = orderNum; |