summaryrefslogtreecommitdiffstats
path: root/stream/stream_memory.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-09-29 00:45:41 +0200
committerwm4 <wm4@nowhere>2019-09-29 00:46:54 +0200
commit2bb5ab07b7ee09fb7ae0e90a74c1e8e5adcc3d59 (patch)
treece765b9b553e40890faba658243191542b8f5068 /stream/stream_memory.c
parenta7158ceec00f14e680a885722cfe23761b4662d3 (diff)
downloadmpv-2bb5ab07b7ee09fb7ae0e90a74c1e8e5adcc3d59.tar.bz2
mpv-2bb5ab07b7ee09fb7ae0e90a74c1e8e5adcc3d59.tar.xz
stream: rearrange open functions
Add yet another variant of the stream open function. This time, make it so that it's possible to add new open parameters in an extendable way, which should put an end to having to change this every other year. Effectively get rid of the overly special stream_create_instance() function and use the new one instead, which requires changes in stream_concat.c and stream_memory.c. The function is still in private in stream.c, but I preferred to make the mentioned users go through the new function for orthogonality. The error handling (mostly logging) was adjusted accordingly. This should not have any functional changes. (To preempt any excuses, I didn't actually test stream_concat and stream_memory.)
Diffstat (limited to 'stream/stream_memory.c')
-rw-r--r--stream/stream_memory.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/stream/stream_memory.c b/stream/stream_memory.c
index 107fa80d19..3db4e0bb54 100644
--- a/stream/stream_memory.c
+++ b/stream/stream_memory.c
@@ -50,7 +50,7 @@ static int control(stream_t *s, int cmd, void *arg)
return STREAM_UNSUPPORTED;
}
-static int open2(stream_t *stream, void *arg)
+static int open2(stream_t *stream, struct stream_open_args *args)
{
stream->fill_buffer = fill_buffer;
stream->seek = seek;
@@ -67,8 +67,8 @@ static int open2(stream_t *stream, void *arg)
if (!use_hex)
bstr_eatstart0(&data, "memory://");
- if (arg)
- data = *(bstr *)arg;
+ if (args->special_arg)
+ data = *(bstr *)args->special_arg;
p->data = bstrdup(stream, data);
@@ -90,10 +90,16 @@ struct stream *stream_memory_open(struct mpv_global *global, void *data, int len
{
assert(len >= 0);
+ struct stream_open_args sargs = {
+ .global = global,
+ .url = "memory://",
+ .flags = STREAM_READ | STREAM_SILENT,
+ .sinfo = &stream_info_memory,
+ .special_arg = &(bstr){data, len},
+ };
+
struct stream *s = NULL;
- stream_create_instance(&stream_info_memory, "memory://",
- STREAM_READ | STREAM_SILENT, NULL, global,
- &(bstr){data, len}, &s);
+ stream_create_with_args(&sargs, &s);
MP_HANDLE_OOM(s);
return s;
}