Commit 898d885a authored by Max Kellermann's avatar Max Kellermann

test/dump_playlist: try playlist_list_open_uri() first

parent a61d0c95
...@@ -43,6 +43,7 @@ int main(int argc, char **argv) ...@@ -43,6 +43,7 @@ int main(int argc, char **argv)
{ {
const char *uri; const char *uri;
struct input_stream is; struct input_stream is;
bool stream_open = false;
bool success; bool success;
GError *error = NULL; GError *error = NULL;
struct playlist_provider *playlist; struct playlist_provider *playlist;
...@@ -74,32 +75,39 @@ int main(int argc, char **argv) ...@@ -74,32 +75,39 @@ int main(int argc, char **argv)
input_stream_global_init(); input_stream_global_init();
playlist_list_global_init(); playlist_list_global_init();
/* open the stream and wait until it becomes ready */ /* open the playlist */
success = input_stream_open(&is, uri); playlist = playlist_list_open_uri(uri);
if (!success) { if (playlist == NULL) {
g_printerr("input_stream_open() failed\n"); /* open the stream and wait until it becomes ready */
return 2;
}
while (!is.ready) { success = input_stream_open(&is, uri);
int ret = input_stream_buffer(&is); if (!success) {
if (ret < 0) g_printerr("input_stream_open() failed\n");
/* error */
return 2; return 2;
}
if (ret == 0) while (!is.ready) {
/* nothing was buffered - wait */ int ret = input_stream_buffer(&is);
g_usleep(10000); 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); stream_open = true;
if (playlist == NULL) {
input_stream_close(&is); /* open the playlist */
g_printerr("Failed to open playlist\n");
return 2; 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 */ /* dump the playlist */
...@@ -115,7 +123,8 @@ int main(int argc, char **argv) ...@@ -115,7 +123,8 @@ int main(int argc, char **argv)
/* deinitialize everything */ /* deinitialize everything */
playlist_plugin_close(playlist); playlist_plugin_close(playlist);
input_stream_close(&is); if (stream_open)
input_stream_close(&is);
playlist_list_global_finish(); playlist_list_global_finish();
input_stream_global_finish(); input_stream_global_finish();
config_global_finish(); config_global_finish();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment