aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-15 22:34:47 +0200
committerMax Kellermann <max@duempel.org>2008-10-15 22:34:47 +0200
commit6d3488c8b38c07c197e97843a516868bbab7571a (patch)
tree01eb4624d2f4456eb530d87de6727b1fb13fa503 /src/playlist.c
parent4a7ad5b618957f75da5b305a3d0cc8006e3e7416 (diff)
downloadmpd-6d3488c8b38c07c197e97843a516868bbab7571a.tar.gz
mpd-6d3488c8b38c07c197e97843a516868bbab7571a.tar.xz
mpd-6d3488c8b38c07c197e97843a516868bbab7571a.zip
song: added song_in_database()
Some functions assume that a song is not in the database when it is a remote song. Based on that, they decide whether they are responsible for freeing the song struct. Add a special function which checks whether a song is in the database (currently equal to song_is_file()).
Diffstat (limited to 'src/playlist.c')
-rw-r--r--src/playlist.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/playlist.c b/src/playlist.c
index bfcfb1f7a..dc098a03f 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -181,11 +181,9 @@ static int getNextId(void)
void finishPlaylist(void)
{
int i;
- for (i = 0; i < playlist.length; i++) {
- if (!song_is_file(playlist.songs[i])) {
+ for (i = 0; i < playlist.length; i++)
+ if (!song_in_database(playlist.songs[i]))
song_free(playlist.songs[i]);
- }
- }
playlist.length = 0;
@@ -208,9 +206,9 @@ void clearPlaylist(void)
stopPlaylist();
for (i = 0; i < playlist.length; i++) {
- if (!song_is_file(playlist.songs[i])) {
+ if (!song_in_database(playlist.songs[i]))
song_free(playlist.songs[i]);
- }
+
playlist.idToPosition[playlist.positionToId[i]] = -1;
playlist.songs[i] = NULL;
}
@@ -678,9 +676,8 @@ enum playlist_result deleteFromPlaylist(int song)
|| playlist.order[playlist.current] == song))
clearPlayerQueue();
- if (!song_is_file(playlist.songs[song])) {
+ if (!song_in_database(playlist.songs[song]))
song_free(playlist.songs[song]);
- }
playlist.idToPosition[playlist.positionToId[song]] = -1;
@@ -858,6 +855,8 @@ static void syncCurrentPlayerDecodeMetadata(void)
if (!song_is_file(song) &&
0 == strcmp(song_get_url(song, path_max_tmp), songPlayer->url) &&
!tag_equal(song->tag, songPlayer->tag)) {
+ assert(!song_in_database(song));
+
if (song->tag)
tag_free(song->tag);
song->tag = tag_dup(songPlayer->tag);