aboutsummaryrefslogtreecommitdiffstats
path: root/test/run_input.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/run_input.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/test/run_input.c b/test/run_input.c
index a50cd70ab..676e4e618 100644
--- a/test/run_input.c
+++ b/test/run_input.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2010 The Music Player Daemon Project
+ * Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,6 +18,7 @@
*/
#include "config.h"
+#include "io_thread.h"
#include "input_init.h"
#include "input_stream.h"
#include "tag_pool.h"
@@ -32,6 +33,7 @@
#include <glib.h>
#include <unistd.h>
+#include <stdlib.h>
static void
my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level,
@@ -51,20 +53,17 @@ dump_input_stream(struct input_stream *is)
size_t num_read;
ssize_t num_written;
+ input_stream_lock(is);
+
/* wait until the stream becomes ready */
- while (!is->ready) {
- int ret = input_stream_buffer(is, &error);
- if (ret < 0) {
- /* error */
- g_warning("%s", error->message);
- g_error_free(error);
- return 2;
- }
+ input_stream_wait_ready(is);
- if (ret == 0)
- /* nothing was buffered - wait */
- g_usleep(10000);
+ if (!input_stream_check(is, &error)) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ input_stream_unlock(is);
+ return EXIT_FAILURE;
}
/* print meta data */
@@ -98,6 +97,15 @@ dump_input_stream(struct input_stream *is)
break;
}
+ if (!input_stream_check(is, &error)) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ input_stream_unlock(is);
+ return EXIT_FAILURE;
+ }
+
+ input_stream_unlock(is);
+
return 0;
}
@@ -122,6 +130,13 @@ int main(int argc, char **argv)
tag_pool_init();
config_global_init();
+ io_thread_init();
+ if (!io_thread_start(&error)) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ return EXIT_FAILURE;
+ }
+
#ifdef ENABLE_ARCHIVE
archive_plugin_init_all();
#endif
@@ -134,7 +149,10 @@ int main(int argc, char **argv)
/* open the stream and dump it */
- is = input_stream_open(argv[1], &error);
+ GMutex *mutex = g_mutex_new();
+ GCond *cond = g_cond_new();
+
+ is = input_stream_open(argv[1], mutex, cond, &error);
if (is != NULL) {
ret = dump_input_stream(is);
input_stream_close(is);
@@ -147,6 +165,9 @@ int main(int argc, char **argv)
ret = 2;
}
+ g_cond_free(cond);
+ g_mutex_free(mutex);
+
/* deinitialize everything */
input_stream_global_finish();
@@ -155,6 +176,8 @@ int main(int argc, char **argv)
archive_plugin_deinit_all();
#endif
+ io_thread_deinit();
+
config_global_finish();
tag_pool_deinit();