aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-12-26 02:34:34 +0100
committerMax Kellermann <max@duempel.org>2009-12-26 03:01:52 +0100
commit216dff98d2f558f4095de50c6a848e3b074c70e6 (patch)
tree372955679ebd77906de684d024db6c72a2f2b309
parent032354e65c39a91c722d65cbbc9eb358ca81862f (diff)
downloadmpd-216dff98d2f558f4095de50c6a848e3b074c70e6.tar.gz
mpd-216dff98d2f558f4095de50c6a848e3b074c70e6.tar.xz
mpd-216dff98d2f558f4095de50c6a848e3b074c70e6.zip
playlist_queue: try open by URI first
If that fails, try opening the file as a stream.
Diffstat (limited to '')
-rw-r--r--src/playlist_queue.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/playlist_queue.c b/src/playlist_queue.c
index 5b4439bbb..a184db9f8 100644
--- a/src/playlist_queue.c
+++ b/src/playlist_queue.c
@@ -103,12 +103,30 @@ playlist_open_remote_into_queue(const char *uri, struct playlist *dest)
}
static enum playlist_result
-playlist_open_local_into_queue(const char *uri, struct playlist *dest)
+playlist_open_path_into_queue(char *path_fs, struct playlist *dest)
{
struct playlist_provider *playlist;
+ struct input_stream is;
+ enum playlist_result result;
+
+ if ((playlist = playlist_list_open_uri(path_fs)) != NULL)
+ result = playlist_load_into_queue(playlist, dest);
+ else if ((playlist = playlist_list_open_path(&is, path_fs)) != NULL) {
+ result = playlist_load_into_queue(playlist, dest);
+ input_stream_close(&is);
+ } else
+ return PLAYLIST_RESULT_NO_SUCH_LIST;
+
+ playlist_plugin_close(playlist);
+
+ return result;
+}
+
+static enum playlist_result
+playlist_open_local_into_queue(const char *uri, struct playlist *dest)
+{
const char *playlist_directory_fs;
char *path_fs;
- struct input_stream is;
enum playlist_result result;
assert(spl_valid_name(uri));
@@ -118,15 +136,8 @@ playlist_open_local_into_queue(const char *uri, struct playlist *dest)
return PLAYLIST_RESULT_DISABLED;
path_fs = g_build_filename(playlist_directory_fs, uri, NULL);
- playlist = playlist_list_open_path(&is, path_fs);
+ result = playlist_open_path_into_queue(path_fs, dest);
g_free(path_fs);
- if (playlist == NULL)
- return PLAYLIST_RESULT_NO_SUCH_LIST;
-
- result = playlist_load_into_queue(playlist, dest);
- playlist_plugin_close(playlist);
-
- input_stream_close(&is);
return result;
}