summaryrefslogtreecommitdiffstats
path: root/filters/filter.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-29 21:04:24 +0100
committerwm4 <wm4@nowhere>2020-02-29 21:49:14 +0100
commitf29623786b871807a663ce922d9afbf0d716a387 (patch)
treed74e2ce26267ba29ff3159357ab9542ea930a763 /filters/filter.c
parentd45d4f86e1c509d95d105df3063ae70ad3d340bb (diff)
downloadmpv-f29623786b871807a663ce922d9afbf0d716a387.tar.bz2
mpv-f29623786b871807a663ce922d9afbf0d716a387.tar.xz
filter: decide how multi-threading is supposed to work
Instead of vague ideas about making different filter graphs on different threads interact directly, this have no direct support. Instead, helpers are required (such as added with the next commit). Document it. Different root filters (i.e. separate filter graphs) are now considered to be part of separate threads, so assert() if they're found to accidentally interact.
Diffstat (limited to 'filters/filter.c')
-rw-r--r--filters/filter.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/filters/filter.c b/filters/filter.c
index 84596b723e..dfe6df953a 100644
--- a/filters/filter.c
+++ b/filters/filter.c
@@ -183,6 +183,8 @@ bool mp_filter_run(struct mp_filter *filter)
r->filtering = true;
+ // Note: some filters may call mp_filter_wakeup() from process on themselves
+ // to queue a wakeup again later. So do not call this in the loop.
flush_async_notifications(r);
while (r->num_pending) {
@@ -311,6 +313,8 @@ static struct mp_pin *find_connected_end(struct mp_pin *p)
// state flags.
static void init_connection(struct mp_pin *p)
{
+ struct filter_runner *runner = p->owner->in->runner;
+
if (p->dir == MP_PIN_IN)
p = p->other;
@@ -321,6 +325,12 @@ static void init_connection(struct mp_pin *p)
assert(!in->user_conn);
assert(!out->user_conn);
+ // This and similar checks enforce the same root filter requirement.
+ if (in->manual_connection)
+ assert(in->manual_connection->in->runner == runner);
+ if (out->manual_connection)
+ assert(out->manual_connection->in->runner == runner);
+
// Logicaly, the ends are always manual connections. A pin chain without
// manual connections at the ends is still disconnected (or if this
// attempted to extend an existing connection, becomes dangling and gets
@@ -339,6 +349,7 @@ static void init_connection(struct mp_pin *p)
assert(!cur->data.type); // unused for in pins
assert(!cur->other->data_requested); // unset for unconnected out pins
assert(!cur->other->data.type); // unset for unconnected out pins
+ assert(cur->owner->in->runner == runner);
cur->within_conn = cur->other->within_conn = true;
cur = cur->other->user_conn;
}