libobs: Do not allow incompatible filters on sources
Fixes a potential issue where copying filters from one source to another might add filters from the old source that are not compatible with the new source.
This commit is contained in:
parent
c7395b05ec
commit
eb7fb990b7
@ -1886,6 +1886,18 @@ obs_source_t *obs_filter_get_target(const obs_source_t *filter)
|
||||
filter->filter_target : NULL;
|
||||
}
|
||||
|
||||
static bool filter_compatible(obs_source_t *source, obs_source_t *filter)
|
||||
{
|
||||
uint32_t s_caps = source->info.output_flags;
|
||||
uint32_t f_caps = filter->info.output_flags;
|
||||
|
||||
if ((f_caps & OBS_SOURCE_AUDIO) != 0 &&
|
||||
(f_caps & OBS_SOURCE_VIDEO) == 0)
|
||||
f_caps &= ~OBS_SOURCE_ASYNC;
|
||||
|
||||
return (s_caps & f_caps) == f_caps;
|
||||
}
|
||||
|
||||
void obs_source_filter_add(obs_source_t *source, obs_source_t *filter)
|
||||
{
|
||||
struct calldata cd;
|
||||
@ -1905,6 +1917,11 @@ void obs_source_filter_add(obs_source_t *source, obs_source_t *filter)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!filter_compatible(source, filter)) {
|
||||
pthread_mutex_unlock(&source->filter_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
obs_source_addref(filter);
|
||||
|
||||
filter->filter_parent = source;
|
||||
|
Loading…
x
Reference in New Issue
Block a user