aboutsummaryrefslogtreecommitdiffstats
path: root/test/dump_playlist.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-12-30 23:27:37 +0100
committerMax Kellermann <max@duempel.org>2010-01-01 17:25:07 +0100
commitd3b763a48c09a60a0c0b5ccb6cccd9376875c470 (patch)
tree83b8794f78ef8941806cf5757888d8abf2eaa126 /test/dump_playlist.c
parent816b6ad4a71c3ade95e62b62396f2b0415c03f20 (diff)
downloadmpd-d3b763a48c09a60a0c0b5ccb6cccd9376875c470.tar.gz
mpd-d3b763a48c09a60a0c0b5ccb6cccd9376875c470.tar.xz
mpd-d3b763a48c09a60a0c0b5ccb6cccd9376875c470.zip
input_stream: return allocated input_stream objects
Major API redesign: don't let the caller allocate the input_stream object. Let each input plugin allocate its own (derived/extended) input_stream pointer. The "data" attribute can now be removed, and all input plugins simply cast the input_stream pointer to their own structure (with an "struct input_stream base" as the first attribute).
Diffstat (limited to '')
-rw-r--r--test/dump_playlist.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/test/dump_playlist.c b/test/dump_playlist.c
index 7be9b973f..95207e24d 100644
--- a/test/dump_playlist.c
+++ b/test/dump_playlist.c
@@ -44,8 +44,7 @@ my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level,
int main(int argc, char **argv)
{
const char *uri;
- struct input_stream is;
- bool stream_open = false;
+ struct input_stream *is = NULL;
bool success;
GError *error = NULL;
struct playlist_provider *playlist;
@@ -88,8 +87,8 @@ int main(int argc, char **argv)
if (playlist == NULL) {
/* open the stream and wait until it becomes ready */
- success = input_stream_open(&is, uri, &error);
- if (!success) {
+ is = input_stream_open(uri, &error);
+ if (is == NULL) {
if (error != NULL) {
g_warning("%s", error->message);
g_error_free(error);
@@ -98,8 +97,8 @@ int main(int argc, char **argv)
return 2;
}
- while (!is.ready) {
- int ret = input_stream_buffer(&is, &error);
+ while (!is->ready) {
+ int ret = input_stream_buffer(is, &error);
if (ret < 0) {
/* error */
g_warning("%s", error->message);
@@ -112,13 +111,11 @@ int main(int argc, char **argv)
g_usleep(10000);
}
- stream_open = true;
-
/* open the playlist */
- playlist = playlist_list_open_stream(&is, uri);
+ playlist = playlist_list_open_stream(is, uri);
if (playlist == NULL) {
- input_stream_close(&is);
+ input_stream_close(is);
g_printerr("Failed to open playlist\n");
return 2;
}
@@ -145,8 +142,8 @@ int main(int argc, char **argv)
/* deinitialize everything */
playlist_plugin_close(playlist);
- if (stream_open)
- input_stream_close(&is);
+ if (is != NULL)
+ input_stream_close(is);
playlist_list_global_finish();
input_stream_global_finish();
config_global_finish();