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.
This commit is contained in:
@@ -114,7 +114,11 @@ bz2_open(const char *pathname, GError **error_r)
|
||||
refcount_init(&context->ref);
|
||||
|
||||
//open archive
|
||||
context->istream = input_stream_open(pathname, error_r);
|
||||
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
|
||||
context->istream = input_stream_open(pathname,
|
||||
g_static_mutex_get_mutex(&mutex),
|
||||
NULL,
|
||||
error_r);
|
||||
if (context->istream == NULL) {
|
||||
g_free(context);
|
||||
return NULL;
|
||||
@@ -169,12 +173,15 @@ bz2_close(struct archive_file *file)
|
||||
/* single archive handling */
|
||||
|
||||
static struct input_stream *
|
||||
bz2_open_stream(struct archive_file *file, const char *path, GError **error_r)
|
||||
bz2_open_stream(struct archive_file *file, const char *path,
|
||||
GMutex *mutex, GCond *cond,
|
||||
GError **error_r)
|
||||
{
|
||||
struct bz2_archive_file *context = (struct bz2_archive_file *) file;
|
||||
struct bz2_input_stream *bis = g_new(struct bz2_input_stream, 1);
|
||||
|
||||
input_stream_init(&bis->base, &bz2_inputplugin, path);
|
||||
input_stream_init(&bis->base, &bz2_inputplugin, path,
|
||||
mutex, cond);
|
||||
|
||||
bis->archive = context;
|
||||
|
||||
|
@@ -173,15 +173,17 @@ struct iso9660_input_stream {
|
||||
};
|
||||
|
||||
static struct input_stream *
|
||||
iso9660_archive_open_stream(struct archive_file *file,
|
||||
const char *pathname, GError **error_r)
|
||||
iso9660_archive_open_stream(struct archive_file *file, const char *pathname,
|
||||
GMutex *mutex, GCond *cond,
|
||||
GError **error_r)
|
||||
{
|
||||
struct iso9660_archive_file *context =
|
||||
(struct iso9660_archive_file *)file;
|
||||
struct iso9660_input_stream *iis;
|
||||
|
||||
iis = g_new(struct iso9660_input_stream, 1);
|
||||
input_stream_init(&iis->base, &iso9660_input_plugin, pathname);
|
||||
input_stream_init(&iis->base, &iso9660_input_plugin, pathname,
|
||||
mutex, cond);
|
||||
|
||||
iis->archive = context;
|
||||
iis->statbuf = iso9660_ifs_stat_translate(context->iso, pathname);
|
||||
|
@@ -135,14 +135,17 @@ struct zzip_input_stream {
|
||||
|
||||
static struct input_stream *
|
||||
zzip_archive_open_stream(struct archive_file *file,
|
||||
const char *pathname, GError **error_r)
|
||||
const char *pathname,
|
||||
GMutex *mutex, GCond *cond,
|
||||
GError **error_r)
|
||||
{
|
||||
struct zzip_archive *context = (struct zzip_archive *) file;
|
||||
struct zzip_input_stream *zis;
|
||||
ZZIP_STAT z_stat;
|
||||
|
||||
zis = g_new(struct zzip_input_stream, 1);
|
||||
input_stream_init(&zis->base, &zzip_input_plugin, pathname);
|
||||
input_stream_init(&zis->base, &zzip_input_plugin, pathname,
|
||||
mutex, cond);
|
||||
|
||||
zis->archive = context;
|
||||
zis->file = zzip_file_open(context->dir, pathname, 0);
|
||||
|
Reference in New Issue
Block a user