diff options
author | Max Kellermann <max@duempel.org> | 2013-01-07 23:23:58 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-07 23:25:08 +0100 |
commit | 960b9a966450f4870a14c81170e3b625f9c13a8a (patch) | |
tree | 1066a84c6825aea6f61bf9db8fdf4e54c8f66144 | |
parent | acb45caa4205d6e07c46b14079a7ffe0a2141d3d (diff) | |
download | mpd-960b9a966450f4870a14c81170e3b625f9c13a8a.tar.gz mpd-960b9a966450f4870a14c81170e3b625f9c13a8a.tar.xz mpd-960b9a966450f4870a14c81170e3b625f9c13a8a.zip |
input_stream: add method _cheap_seeking()
Move code from the Vorbis decoder plugin.
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | src/decoder/VorbisDecoderPlugin.cxx | 4 | ||||
-rw-r--r-- | src/input_stream.c | 7 | ||||
-rw-r--r-- | src/input_stream.h | 7 |
4 files changed, 17 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am index b63f7a81b..351978440 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1063,6 +1063,7 @@ test_run_input_SOURCES = test/run_input.c \ src/io_thread.c src/io_thread.h \ src/conf.c src/tokenizer.c src/utils.c src/string_util.c\ src/Tag.cxx src/TagNames.c src/TagPool.cxx src/TagSave.cxx \ + src/uri.c \ src/fd_util.c test_dump_text_file_LDADD = \ @@ -1075,6 +1076,7 @@ test_dump_text_file_SOURCES = test/dump_text_file.c \ src/conf.c src/tokenizer.c src/utils.c src/string_util.c\ src/Tag.cxx src/TagNames.c src/TagPool.cxx \ src/text_input_stream.c src/fifo_buffer.c \ + src/uri.c \ src/fd_util.c test_dump_playlist_LDADD = \ diff --git a/src/decoder/VorbisDecoderPlugin.cxx b/src/decoder/VorbisDecoderPlugin.cxx index 910655361..01a558def 100644 --- a/src/decoder/VorbisDecoderPlugin.cxx +++ b/src/decoder/VorbisDecoderPlugin.cxx @@ -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) { diff --git a/src/input_stream.c b/src/input_stream.c index e445dca6c..c82788f39 100644 --- a/src/input_stream.c +++ b/src/input_stream.c @@ -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> @@ -115,6 +116,12 @@ input_stream_lock_wait_ready(struct input_stream *is) } 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) { diff --git a/src/input_stream.h b/src/input_stream.h index 3a29625af..d5b1dae2e 100644 --- a/src/input_stream.h +++ b/src/input_stream.h @@ -168,6 +168,13 @@ 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. * |