aboutsummaryrefslogtreecommitdiffstats
path: root/test/run_decoder.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-09-14 21:46:41 +0200
committerMax Kellermann <max@duempel.org>2011-09-16 21:22:13 +0200
commit754f26a97c816781e80500d98f2515ae97836145 (patch)
treecaa7dbaa879b29d018a4559524390670ad33a605 /test/run_decoder.c
parent29241c4f835797f635816a9f37528aa981f722b5 (diff)
downloadmpd-754f26a97c816781e80500d98f2515ae97836145.tar.gz
mpd-754f26a97c816781e80500d98f2515ae97836145.tar.xz
mpd-754f26a97c816781e80500d98f2515ae97836145.zip
input_stream: non-blocking I/O
Add GMutex, GCond attributes which will be used by callers to conditionally wait on the stream. Remove the (now-useless) plugin method buffer(), wait on GCond instead. Lock the input_stream before each method call. Do the same with the playlist plugins.
Diffstat (limited to '')
-rw-r--r--test/run_decoder.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/test/run_decoder.c b/test/run_decoder.c
index efc246f55..455b73ce7 100644
--- a/test/run_decoder.c
+++ b/test/run_decoder.c
@@ -112,7 +112,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, NULL);
+ return input_stream_lock_read(is, buffer, length, NULL);
}
void
@@ -209,8 +209,11 @@ int main(int argc, char **argv)
decoder_plugin_file_decode(decoder.plugin, &decoder,
decoder.uri);
} else if (decoder.plugin->stream_decode != NULL) {
+ GMutex *mutex = g_mutex_new();
+ GCond *cond = g_cond_new();
+
struct input_stream *is =
- input_stream_open(decoder.uri, &error);
+ input_stream_open(decoder.uri, mutex, cond, &error);
if (is == NULL) {
if (error != NULL) {
g_warning("%s", error->message);
@@ -224,6 +227,9 @@ int main(int argc, char **argv)
decoder_plugin_stream_decode(decoder.plugin, &decoder, is);
input_stream_close(is);
+
+ g_cond_free(cond);
+ g_mutex_free(mutex);
} else {
g_printerr("Decoder plugin is not usable\n");
return 1;