From 754f26a97c816781e80500d98f2515ae97836145 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 14 Sep 2011 21:46:41 +0200 Subject: 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. --- src/song_update.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/song_update.c') diff --git a/src/song_update.c b/src/song_update.c index e2a845eef..e7279a6f6 100644 --- a/src/song_update.c +++ b/src/song_update.c @@ -131,6 +131,9 @@ song_file_update(struct song *song) song->mtime = st.st_mtime; + GMutex *mutex = NULL; + GCond *cond; + do { /* load file tag */ song->tag = decoder_plugin_tag_dup(plugin, path_fs); @@ -141,8 +144,12 @@ song_file_update(struct song *song) if (plugin->stream_tag != NULL) { /* open the input_stream (if not already open) */ - if (is == NULL) - is = input_stream_open(path_fs, NULL); + if (is == NULL) { + mutex = g_mutex_new(); + cond = g_cond_new(); + is = input_stream_open(path_fs, mutex, cond, + NULL); + } /* now try the stream_tag() method */ if (is != NULL) { @@ -151,7 +158,7 @@ song_file_update(struct song *song) if (song->tag != NULL) break; - input_stream_seek(is, 0, SEEK_SET, NULL); + input_stream_lock_seek(is, 0, SEEK_SET, NULL); } } @@ -161,6 +168,11 @@ song_file_update(struct song *song) if (is != NULL) input_stream_close(is); + if (mutex != NULL) { + g_cond_free(cond); + g_mutex_free(mutex); + } + if (song->tag != NULL && tag_is_empty(song->tag)) song->tag = tag_fallback(path_fs, song->tag); -- cgit v1.2.3