aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-08-14 02:17:20 +0200
committerMax Kellermann <max@duempel.org>2012-08-14 02:17:25 +0200
commitf8bf3afeae9ed757b516c64f62d8c1f3ef9ffaeb (patch)
tree2ab17792ed0b514b041229f0d803dc031249603f /src
parentf703da1516f1093259cf54e973dcf8181f3f3924 (diff)
downloadmpd-f8bf3afeae9ed757b516c64f62d8c1f3ef9ffaeb.tar.gz
mpd-f8bf3afeae9ed757b516c64f62d8c1f3ef9ffaeb.tar.xz
mpd-f8bf3afeae9ed757b516c64f62d8c1f3ef9ffaeb.zip
playlist_song: move code to playlist_check_load_song()
Diffstat (limited to '')
-rw-r--r--src/playlist_song.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/playlist_song.c b/src/playlist_song.c
index 8a3ba303e..85089a4d1 100644
--- a/src/playlist_song.c
+++ b/src/playlist_song.c
@@ -83,12 +83,31 @@ apply_song_metadata(struct song *dest, const struct song *src)
return tmp;
}
+static struct song *
+playlist_check_load_song(struct song *song, const char *uri, bool secure)
+{
+ struct song *dest;
+
+ if (uri_has_scheme(uri)) {
+ dest = song_remote_new(uri);
+ } else if (g_path_is_absolute(uri) && secure) {
+ dest = song_file_load(uri, NULL);
+ if (dest == NULL)
+ return NULL;
+ } else {
+ dest = db_get_song(uri);
+ if (dest == NULL)
+ /* not found in database */
+ return NULL;
+ }
+
+ return apply_song_metadata(dest, song);
+}
+
struct song *
playlist_check_translate_song(struct song *song, const char *base_uri,
bool secure)
{
- struct song *dest;
-
if (song_in_database(song))
/* already ok */
return song;
@@ -135,27 +154,8 @@ playlist_check_translate_song(struct song *song, const char *base_uri,
else
uri = g_strdup(uri);
- if (uri_has_scheme(uri)) {
- dest = song_remote_new(uri);
- g_free(uri);
- } else if (g_path_is_absolute(uri) && secure) {
- dest = song_file_load(uri, NULL);
- if (dest == NULL) {
- song_free(song);
- return NULL;
- }
- } else {
- dest = db_get_song(uri);
- g_free(uri);
- if (dest == NULL) {
- /* not found in database */
- song_free(song);
- return dest;
- }
- }
-
- dest = apply_song_metadata(dest, song);
+ struct song *dest = playlist_check_load_song(song, uri, secure);
song_free(song);
-
+ g_free(uri);
return dest;
}