aboutsummaryrefslogtreecommitdiff
path: root/test/dump_playlist.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-10-13 16:25:37 +0200
committerMax Kellermann <max@duempel.org>2009-10-13 16:25:37 +0200
commit898d885ae2145653f8bb6173001595b67aa133e1 (patch)
treecc2b17c476440cdb56c37ce75f455c25a8ca7154 /test/dump_playlist.c
parenta61d0c95673aca05ff643550dd704e4436171c11 (diff)
test/dump_playlist: try playlist_list_open_uri() first
Diffstat (limited to 'test/dump_playlist.c')
-rw-r--r--test/dump_playlist.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/test/dump_playlist.c b/test/dump_playlist.c
index f789a282..146f5862 100644
--- a/test/dump_playlist.c
+++ b/test/dump_playlist.c
@@ -43,6 +43,7 @@ int main(int argc, char **argv)
{
const char *uri;
struct input_stream is;
+ bool stream_open = false;
bool success;
GError *error = NULL;
struct playlist_provider *playlist;
@@ -74,32 +75,39 @@ int main(int argc, char **argv)
input_stream_global_init();
playlist_list_global_init();
- /* open the stream and wait until it becomes ready */
+ /* open the playlist */
- success = input_stream_open(&is, uri);
- if (!success) {
- g_printerr("input_stream_open() failed\n");
- return 2;
- }
+ playlist = playlist_list_open_uri(uri);
+ if (playlist == NULL) {
+ /* open the stream and wait until it becomes ready */
- while (!is.ready) {
- int ret = input_stream_buffer(&is);
- if (ret < 0)
- /* error */
+ success = input_stream_open(&is, uri);
+ if (!success) {
+ g_printerr("input_stream_open() failed\n");
return 2;
+ }
- if (ret == 0)
- /* nothing was buffered - wait */
- g_usleep(10000);
- }
+ while (!is.ready) {
+ int ret = input_stream_buffer(&is);
+ if (ret < 0)
+ /* error */
+ return 2;
- /* open the playlist */
+ if (ret == 0)
+ /* nothing was buffered - wait */
+ g_usleep(10000);
+ }
- playlist = playlist_list_open_stream(&is, uri);
- if (playlist == NULL) {
- input_stream_close(&is);
- g_printerr("Failed to open playlist\n");
- return 2;
+ stream_open = true;
+
+ /* open the playlist */
+
+ playlist = playlist_list_open_stream(&is, uri);
+ if (playlist == NULL) {
+ input_stream_close(&is);
+ g_printerr("Failed to open playlist\n");
+ return 2;
+ }
}
/* dump the playlist */
@@ -115,7 +123,8 @@ int main(int argc, char **argv)
/* deinitialize everything */
playlist_plugin_close(playlist);
- input_stream_close(&is);
+ if (stream_open)
+ input_stream_close(&is);
playlist_list_global_finish();
input_stream_global_finish();
config_global_finish();