input_plugin: add method check()
To check for errors without reading. The decoder thread wants to do that, before it passes the input stream to the plugin.
This commit is contained in:
@@ -774,6 +774,23 @@ input_curl_free(struct input_curl *c)
|
||||
g_free(c);
|
||||
}
|
||||
|
||||
static bool
|
||||
input_curl_check(struct input_stream *is, GError **error_r)
|
||||
{
|
||||
struct input_curl *c = (struct input_curl *)is;
|
||||
|
||||
g_mutex_lock(c->mutex);
|
||||
|
||||
bool success = c->postponed_error == NULL;
|
||||
if (!success) {
|
||||
g_propagate_error(error_r, c->postponed_error);
|
||||
c->postponed_error = NULL;
|
||||
}
|
||||
|
||||
g_mutex_unlock(c->mutex);
|
||||
return success;
|
||||
}
|
||||
|
||||
static struct tag *
|
||||
input_curl_tag(struct input_stream *is)
|
||||
{
|
||||
@@ -1318,6 +1335,7 @@ const struct input_plugin input_plugin_curl = {
|
||||
|
||||
.open = input_curl_open,
|
||||
.close = input_curl_close,
|
||||
.check = input_curl_check,
|
||||
.tag = input_curl_tag,
|
||||
.buffer = input_curl_buffer,
|
||||
.read = input_curl_read,
|
||||
|
@@ -107,6 +107,14 @@ input_rewind_close(struct input_stream *is)
|
||||
g_free(r);
|
||||
}
|
||||
|
||||
static bool
|
||||
input_rewind_check(struct input_stream *is, GError **error_r)
|
||||
{
|
||||
struct input_rewind *r = (struct input_rewind *)is;
|
||||
|
||||
return input_stream_check(r->input, error_r);
|
||||
}
|
||||
|
||||
static void
|
||||
input_rewind_update(struct input_stream *is)
|
||||
{
|
||||
@@ -221,6 +229,7 @@ input_rewind_seek(struct input_stream *is, goffset offset, int whence,
|
||||
|
||||
static const struct input_plugin rewind_input_plugin = {
|
||||
.close = input_rewind_close,
|
||||
.check = input_rewind_check,
|
||||
.update = input_rewind_update,
|
||||
.tag = input_rewind_tag,
|
||||
.buffer = input_rewind_buffer,
|
||||
|
@@ -320,6 +320,23 @@ input_soup_close(struct input_stream *is)
|
||||
g_free(s);
|
||||
}
|
||||
|
||||
static bool
|
||||
input_soup_check(struct input_stream *is, GError **error_r)
|
||||
{
|
||||
struct input_soup *s = (struct input_soup *)is;
|
||||
|
||||
g_mutex_lock(s->mutex);
|
||||
|
||||
bool success = s->postponed_error == NULL;
|
||||
if (!success) {
|
||||
g_propagate_error(error_r, s->postponed_error);
|
||||
s->postponed_error = NULL;
|
||||
}
|
||||
|
||||
g_mutex_unlock(s->mutex);
|
||||
return success;
|
||||
}
|
||||
|
||||
static int
|
||||
input_soup_buffer(struct input_stream *is, GError **error_r)
|
||||
{
|
||||
@@ -444,6 +461,7 @@ const struct input_plugin input_plugin_soup = {
|
||||
|
||||
.open = input_soup_open,
|
||||
.close = input_soup_close,
|
||||
.check = input_soup_check,
|
||||
.buffer = input_soup_buffer,
|
||||
.read = input_soup_read,
|
||||
.eof = input_soup_eof,
|
||||
|
Reference in New Issue
Block a user