input_stream: add method _cheap_seeking()

Move code from the Vorbis decoder plugin.
This commit is contained in:
Max Kellermann
2013-01-07 23:23:58 +01:00
parent acb45caa42
commit 960b9a9664
4 changed files with 17 additions and 3 deletions

View File

@@ -139,9 +139,7 @@ vorbis_is_open(struct vorbis_input_stream *vis, OggVorbis_File *vf,
{
vis->decoder = decoder;
vis->input_stream = input_stream;
vis->seekable = input_stream->seekable &&
(input_stream->uri == NULL ||
!uri_has_scheme(input_stream->uri));
vis->seekable = input_stream_cheap_seeking(input_stream);
int ret = ov_open_callbacks(vis, vf, NULL, 0, vorbis_is_callbacks);
if (ret < 0) {

View File

@@ -22,6 +22,7 @@
#include "input_registry.h"
#include "input_plugin.h"
#include "input/rewind_input_plugin.h"
#include "uri.h"
#include <glib.h>
#include <assert.h>
@@ -114,6 +115,12 @@ input_stream_lock_wait_ready(struct input_stream *is)
g_mutex_unlock(is->mutex);
}
bool
input_stream_cheap_seeking(const struct input_stream *is)
{
return is->seekable && (is->uri == NULL || !uri_has_scheme(is->uri));
}
bool
input_stream_seek(struct input_stream *is, goffset offset, int whence,
GError **error_r)

View File

@@ -167,6 +167,13 @@ gcc_nonnull(1)
void
input_stream_lock_wait_ready(struct input_stream *is);
/**
* Determines whether seeking is cheap. This is true for local files.
*/
gcc_pure gcc_nonnull(1)
bool
input_stream_cheap_seeking(const struct input_stream *is);
/**
* Seeks to the specified position in the stream. This will most
* likely fail if the "seekable" flag is false.