input_plugin: add method update()
Update the struct attributes, important for facades like the "rewind" plugin. To replace buffer().
This commit is contained in:
parent
8c6e8a6eb8
commit
ad37c88f80
@ -105,6 +105,15 @@ input_rewind_close(struct input_stream *is)
|
|||||||
g_free(r);
|
g_free(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
input_rewind_update(struct input_stream *is)
|
||||||
|
{
|
||||||
|
struct input_rewind *r = (struct input_rewind *)is;
|
||||||
|
|
||||||
|
if (!reading_from_buffer(r))
|
||||||
|
copy_attributes(r);
|
||||||
|
}
|
||||||
|
|
||||||
static struct tag *
|
static struct tag *
|
||||||
input_rewind_tag(struct input_stream *is)
|
input_rewind_tag(struct input_stream *is)
|
||||||
{
|
{
|
||||||
@ -210,6 +219,7 @@ input_rewind_seek(struct input_stream *is, goffset offset, int whence,
|
|||||||
|
|
||||||
static const struct input_plugin rewind_input_plugin = {
|
static const struct input_plugin rewind_input_plugin = {
|
||||||
.close = input_rewind_close,
|
.close = input_rewind_close,
|
||||||
|
.update = input_rewind_update,
|
||||||
.tag = input_rewind_tag,
|
.tag = input_rewind_tag,
|
||||||
.buffer = input_rewind_buffer,
|
.buffer = input_rewind_buffer,
|
||||||
.read = input_rewind_read,
|
.read = input_rewind_read,
|
||||||
|
@ -51,6 +51,12 @@ struct input_plugin {
|
|||||||
struct input_stream *(*open)(const char *uri, GError **error_r);
|
struct input_stream *(*open)(const char *uri, GError **error_r);
|
||||||
void (*close)(struct input_stream *is);
|
void (*close)(struct input_stream *is);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the public attributes. Call before access. Can be
|
||||||
|
* NULL if the plugin always keeps its attributes up to date.
|
||||||
|
*/
|
||||||
|
void (*update)(struct input_stream *is);
|
||||||
|
|
||||||
struct tag *(*tag)(struct input_stream *is);
|
struct tag *(*tag)(struct input_stream *is);
|
||||||
int (*buffer)(struct input_stream *is, GError **error_r);
|
int (*buffer)(struct input_stream *is, GError **error_r);
|
||||||
size_t (*read)(struct input_stream *is, void *ptr, size_t size,
|
size_t (*read)(struct input_stream *is, void *ptr, size_t size,
|
||||||
|
@ -67,6 +67,16 @@ input_stream_open(const char *url, GError **error_r)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
input_stream_update(struct input_stream *is)
|
||||||
|
{
|
||||||
|
assert(is != NULL);
|
||||||
|
assert(is->plugin != NULL);
|
||||||
|
|
||||||
|
if (is->plugin->update != NULL)
|
||||||
|
is->plugin->update(is);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
input_stream_seek(struct input_stream *is, goffset offset, int whence,
|
input_stream_seek(struct input_stream *is, goffset offset, int whence,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
|
@ -86,6 +86,13 @@ input_stream_open(const char *uri, GError **error_r);
|
|||||||
void
|
void
|
||||||
input_stream_close(struct input_stream *is);
|
input_stream_close(struct input_stream *is);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the public attributes. Call before accessing attributes
|
||||||
|
* such as "ready" or "offset".
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
input_stream_update(struct input_stream *is);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seeks to the specified position in the stream. This will most
|
* Seeks to the specified position in the stream. This will most
|
||||||
* likely fail if the "seekable" flag is false.
|
* likely fail if the "seekable" flag is false.
|
||||||
|
Loading…
Reference in New Issue
Block a user