diff options
Diffstat (limited to '')
-rw-r--r-- | src/playlist_edit.c | 7 | ||||
-rw-r--r-- | src/playlist_print.c | 4 | ||||
-rw-r--r-- | src/playlist_queue.c | 6 | ||||
-rw-r--r-- | src/playlist_song.c | 11 |
4 files changed, 16 insertions, 12 deletions
diff --git a/src/playlist_edit.c b/src/playlist_edit.c index 1dfe68daa..3cd737705 100644 --- a/src/playlist_edit.c +++ b/src/playlist_edit.c @@ -128,7 +128,12 @@ playlist_append_uri(struct playlist *playlist, struct player_control *pc, if (song == NULL) return PLAYLIST_RESULT_NO_SUCH_SONG; - return playlist_append_song(playlist, pc, song, added_id); + enum playlist_result result = + playlist_append_song(playlist, pc, song, added_id); + if (song_in_database(song)) + db_return_song(song); + + return result; } enum playlist_result diff --git a/src/playlist_print.c b/src/playlist_print.c index 204ce3582..b1b689893 100644 --- a/src/playlist_print.c +++ b/src/playlist_print.c @@ -127,6 +127,7 @@ spl_print(struct client *client, const char *name_utf8, bool detail, struct song *song = db_get_song(temp); if (song) { song_print_info(client, song); + db_return_song(song); wrote = true; } } @@ -157,8 +158,7 @@ playlist_provider_print(struct client *client, const char *uri, else song_print_uri(client, song); - if (!song_in_database(song) || song_is_detached(song)) - song_free(song); + song_free(song); } g_free(base_uri); diff --git a/src/playlist_queue.c b/src/playlist_queue.c index aada94984..8eb535dbd 100644 --- a/src/playlist_queue.c +++ b/src/playlist_queue.c @@ -41,8 +41,7 @@ playlist_load_into_queue(const char *uri, struct playlist_provider *source, ++i) { if (i < start_index) { /* skip songs before the start index */ - if (!song_in_database(song)) - song_free(song); + song_free(song); continue; } @@ -51,9 +50,8 @@ playlist_load_into_queue(const char *uri, struct playlist_provider *source, continue; result = playlist_append_song(dest, pc, song, NULL); + song_free(song); if (result != PLAYLIST_RESULT_SUCCESS) { - if (!song_in_database(song)) - song_free(song); g_free(base_uri); return result; } diff --git a/src/playlist_song.c b/src/playlist_song.c index 29efef2e3..3b8de6307 100644 --- a/src/playlist_song.c +++ b/src/playlist_song.c @@ -79,9 +79,7 @@ apply_song_metadata(struct song *dest, const struct song *src) (e.g. last track on a CUE file); fix it up here */ tmp->tag->time = dest->tag->time - src->start_ms / 1000; - if (!song_in_database(dest)) - song_free(dest); - + song_free(dest); return tmp; } @@ -97,10 +95,13 @@ playlist_check_load_song(const struct song *song, const char *uri, bool secure) if (dest == NULL) return NULL; } else { - dest = db_get_song(uri); - if (dest == NULL) + struct song *tmp = db_get_song(uri); + if (tmp == NULL) /* not found in database */ return NULL; + + dest = song_dup_detached(tmp); + db_return_song(tmp); } return apply_song_metadata(dest, song); |