aboutsummaryrefslogtreecommitdiffstats
path: root/src/input_stream.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-30 00:58:03 +0100
committerMax Kellermann <max@duempel.org>2009-01-30 00:58:03 +0100
commit32d6d4499e315a5a2f224beaa54faad03ff80a16 (patch)
tree069be90398bd1eb284c60f40731a8c8100afccab /src/input_stream.c
parent82cfce76eb5787f1a24151f6a3840a999ed82659 (diff)
downloadmpd-32d6d4499e315a5a2f224beaa54faad03ff80a16.tar.gz
mpd-32d6d4499e315a5a2f224beaa54faad03ff80a16.tar.xz
mpd-32d6d4499e315a5a2f224beaa54faad03ff80a16.zip
input_stream: make seek(), buffer() optional
Make those two methods optional to implement, and let input_stream.c provide fallbacks. The buffer() method will be removed one day, and there is now only one implementation left (input_curl.c).
Diffstat (limited to '')
-rw-r--r--src/input_stream.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/input_stream.c b/src/input_stream.c
index b25f3bf40..4375db948 100644
--- a/src/input_stream.c
+++ b/src/input_stream.c
@@ -86,6 +86,7 @@ input_stream_open(struct input_stream *is, const char *url)
assert(is->plugin->close != NULL);
assert(is->plugin->read != NULL);
assert(is->plugin->eof != NULL);
+ assert(!is->seekable || is->plugin->seek != NULL);
return true;
}
@@ -97,6 +98,9 @@ input_stream_open(struct input_stream *is, const char *url)
bool
input_stream_seek(struct input_stream *is, off_t offset, int whence)
{
+ if (is->plugin->seek == NULL)
+ return false;
+
return is->plugin->seek(is, offset, whence);
}
@@ -133,5 +137,8 @@ bool input_stream_eof(struct input_stream *is)
int input_stream_buffer(struct input_stream *is)
{
+ if (is->plugin->buffer == NULL)
+ return 0;
+
return is->plugin->buffer(is);
}