aboutsummaryrefslogtreecommitdiffstats
path: root/src/input_internal.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 /src/input_internal.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 'src/input_internal.c')
-rw-r--r--src/input_internal.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/input_internal.c b/src/input_internal.c
index 4d675fc97..92a71856e 100644
--- a/src/input_internal.c
+++ b/src/input_internal.c
@@ -25,7 +25,7 @@
void
input_stream_init(struct input_stream *is, const struct input_plugin *plugin,
- const char *uri)
+ const char *uri, GMutex *mutex, GCond *cond)
{
assert(is != NULL);
assert(plugin != NULL);
@@ -33,6 +33,8 @@ input_stream_init(struct input_stream *is, const struct input_plugin *plugin,
is->plugin = plugin;
is->uri = g_strdup(uri);
+ is->mutex = mutex;
+ is->cond = cond;
is->ready = false;
is->seekable = false;
is->size = -1;
@@ -49,3 +51,23 @@ input_stream_deinit(struct input_stream *is)
g_free(is->uri);
g_free(is->mime);
}
+
+void
+input_stream_signal_client(struct input_stream *is)
+{
+ if (is->cond != NULL)
+ g_cond_broadcast(is->cond);
+}
+
+void
+input_stream_set_ready(struct input_stream *is)
+{
+ g_mutex_lock(is->mutex);
+
+ if (!is->ready) {
+ is->ready = true;
+ input_stream_signal_client(is);
+ }
+
+ g_mutex_unlock(is->mutex);
+}