aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-14 23:53:04 +0100
committerMax Kellermann <max@duempel.org>2009-12-15 23:12:11 +0100
commit228b03edf8513aa1cdaf4e4647279cc580245555 (patch)
tree7f5b03a9727fb8c371885469296eb7f49f6fa68b /test
parentd000d31355c824a076324b647a3f056aab9ddabe (diff)
downloadmpd-228b03edf8513aa1cdaf4e4647279cc580245555.tar.gz
mpd-228b03edf8513aa1cdaf4e4647279cc580245555.tar.xz
mpd-228b03edf8513aa1cdaf4e4647279cc580245555.zip
input_stream: return errors with GError
Diffstat (limited to '')
-rw-r--r--test/dump_playlist.c15
-rw-r--r--test/read_tags.c2
-rw-r--r--test/run_decoder.c13
-rw-r--r--test/run_input.c27
4 files changed, 43 insertions, 14 deletions
diff --git a/test/dump_playlist.c b/test/dump_playlist.c
index fba9498a7..bf31400fe 100644
--- a/test/dump_playlist.c
+++ b/test/dump_playlist.c
@@ -88,17 +88,24 @@ int main(int argc, char **argv)
if (playlist == NULL) {
/* open the stream and wait until it becomes ready */
- success = input_stream_open(&is, uri);
+ success = input_stream_open(&is, uri, &error);
if (!success) {
- g_printerr("input_stream_open() failed\n");
+ if (error != NULL) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ } else
+ g_printerr("input_stream_open() failed\n");
return 2;
}
while (!is.ready) {
- int ret = input_stream_buffer(&is);
- if (ret < 0)
+ int ret = input_stream_buffer(&is, &error);
+ if (ret < 0) {
/* error */
+ g_warning("%s", error->message);
+ g_error_free(error);
return 2;
+ }
if (ret == 0)
/* nothing was buffered - wait */
diff --git a/test/read_tags.c b/test/read_tags.c
index 647f7eacf..2e2c95ca5 100644
--- a/test/read_tags.c
+++ b/test/read_tags.c
@@ -93,7 +93,7 @@ decoder_read(G_GNUC_UNUSED struct decoder *decoder,
struct input_stream *is,
void *buffer, size_t length)
{
- return input_stream_read(is, buffer, length);
+ return input_stream_read(is, buffer, length, NULL);
}
enum decoder_command
diff --git a/test/run_decoder.c b/test/run_decoder.c
index dd1ecdb67..0ac5a7f21 100644
--- a/test/run_decoder.c
+++ b/test/run_decoder.c
@@ -114,7 +114,7 @@ decoder_read(G_GNUC_UNUSED struct decoder *decoder,
struct input_stream *is,
void *buffer, size_t length)
{
- return input_stream_read(is, buffer, length);
+ return input_stream_read(is, buffer, length, NULL);
}
enum decoder_command
@@ -175,9 +175,16 @@ int main(int argc, char **argv)
} else if (decoder.plugin->stream_decode != NULL) {
struct input_stream is;
- ret = input_stream_open(&is, decoder.uri);
- if (!ret)
+ ret = input_stream_open(&is, decoder.uri, &error);
+ if (!ret) {
+ if (error != NULL) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ } else
+ g_printerr("input_stream_open() failed\n");
+
return 1;
+ }
decoder_plugin_stream_decode(decoder.plugin, &decoder, &is);
diff --git a/test/run_input.c b/test/run_input.c
index bd66a1b1a..a7423a2e7 100644
--- a/test/run_input.c
+++ b/test/run_input.c
@@ -45,6 +45,7 @@ my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level,
static int
dump_input_stream(struct input_stream *is)
{
+ GError *error = NULL;
char buffer[4096];
size_t num_read;
ssize_t num_written;
@@ -52,10 +53,13 @@ dump_input_stream(struct input_stream *is)
/* wait until the stream becomes ready */
while (!is->ready) {
- int ret = input_stream_buffer(is);
- if (ret < 0)
+ int ret = input_stream_buffer(is, &error);
+ if (ret < 0) {
/* error */
+ g_warning("%s", error->message);
+ g_error_free(error);
return 2;
+ }
if (ret == 0)
/* nothing was buffered - wait */
@@ -77,9 +81,16 @@ dump_input_stream(struct input_stream *is)
tag_free(tag);
}
- num_read = input_stream_read(is, buffer, sizeof(buffer));
- if (num_read == 0)
+ num_read = input_stream_read(is, buffer, sizeof(buffer),
+ &error);
+ if (num_read == 0) {
+ if (error != NULL) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ }
+
break;
+ }
num_written = write(1, buffer, num_read);
if (num_written <= 0)
@@ -122,11 +133,15 @@ int main(int argc, char **argv)
/* open the stream and dump it */
- if (input_stream_open(&is, argv[1])) {
+ if (input_stream_open(&is, argv[1], &error)) {
ret = dump_input_stream(&is);
input_stream_close(&is);
} else {
- g_printerr("input_stream_open() failed\n");
+ if (error != NULL) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ } else
+ g_printerr("input_stream_open() failed\n");
ret = 2;
}