aboutsummaryrefslogtreecommitdiffstats
path: root/test/dump_playlist.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/dump_playlist.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 'test/dump_playlist.c')
-rw-r--r--test/dump_playlist.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/test/dump_playlist.c b/test/dump_playlist.c
index bf3fed7c9..079fdeac0 100644
--- a/test/dump_playlist.c
+++ b/test/dump_playlist.c
@@ -92,11 +92,14 @@ int main(int argc, char **argv)
/* open the playlist */
- playlist = playlist_list_open_uri(uri);
+ GMutex *mutex = g_mutex_new();
+ GCond *cond = g_cond_new();
+
+ playlist = playlist_list_open_uri(uri, mutex, cond);
if (playlist == NULL) {
/* open the stream and wait until it becomes ready */
- is = input_stream_open(uri, &error);
+ is = input_stream_open(uri, mutex, cond, &error);
if (is == NULL) {
if (error != NULL) {
g_warning("%s", error->message);
@@ -106,19 +109,7 @@ int main(int argc, char **argv)
return 2;
}
- 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;
- }
-
- if (ret == 0)
- /* nothing was buffered - wait */
- g_usleep(10000);
- }
+ input_stream_lock_wait_ready(is);
/* open the playlist */
@@ -157,6 +148,10 @@ int main(int argc, char **argv)
playlist_plugin_close(playlist);
if (is != NULL)
input_stream_close(is);
+
+ g_cond_free(cond);
+ g_mutex_free(mutex);
+
playlist_list_global_finish();
input_stream_global_finish();
io_thread_deinit();