Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libobs/build/libobs.core-source+.h.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#include "libobs/obs-source-deinterlace-seam.c.h"
#include "libobs/obs-source-deinterlace-texture-fields.c.h"
#include "libobs/obs-source-enabled-setter-fields.c.h"
#include "libobs/obs-source-enum-active-fields.c.h"
#include "libobs/obs-source-enum-filters-fields.c.h"
#include "libobs/obs-source-filter-backup-fields.c.h"
#include "libobs/obs-source-filter-count-fields.c.h"
Expand Down
4 changes: 4 additions & 0 deletions libobs/build/libobs.ported-source-enum-active+.h.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Unity group (BUILD.md): original source enum active sources and tree for C reference. */
#include "libobs/build/libobs.pch.h"

#include "libobs/obs-source-enum-active.c.h"
5 changes: 5 additions & 0 deletions libobs/build/ported-source-sets/source-enum-active.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"LIBOBS_PORTED_SOURCES": [
"build/libobs.ported-source-enum-active+.h.c"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obs_source_enum_active_sources
obs_source_enum_active_tree
29 changes: 29 additions & 0 deletions libobs/obs-source-enum-active-fields.c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "libobs/build/libobs.pch.h"

/* What obs_source_enum_active_sources() and obs_source_enum_active_tree()
* read and call on a source (the obs-source shims, #5729): its context
* data, whether its type is a transition and has enum_active_sources, and
* that callback itself. The caller rejects NULL and keeps the source alive. */
bool obs_source_enum_active_has_data(const obs_source_t *source);
bool obs_source_enum_active_has_data(const obs_source_t *source)
{
return source->context.data != NULL;
}

bool obs_source_enum_active_is_transition(const obs_source_t *source);
bool obs_source_enum_active_is_transition(const obs_source_t *source)
{
return source->info.type == OBS_SOURCE_TYPE_TRANSITION;
}

bool obs_source_enum_active_has_callback(const obs_source_t *source);
bool obs_source_enum_active_has_callback(const obs_source_t *source)
{
return source->info.enum_active_sources != NULL;
}

void obs_source_enum_active_call(obs_source_t *source, obs_source_enum_proc_t enum_callback, void *param);
void obs_source_enum_active_call(obs_source_t *source, obs_source_enum_proc_t enum_callback, void *param)
{
source->info.enum_active_sources(source->context.data, enum_callback, param);
}
85 changes: 85 additions & 0 deletions libobs/obs-source-enum-active.c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include "libobs/build/libobs.pch.h"

/* obs_source_enum_active_sources() and obs_source_enum_active_tree(), moved
* verbatim out of obs-source.c.h (#5729). obs-source.c.h's data_valid() and
* struct source_enum_data are file-local there, so this file carries its own
* copies under scoped names; the bodies keep the original names and the file
* also builds in a translation unit of its own. */
struct source_enum_active_data {
obs_source_enum_proc_t enum_callback;
void *param;
obs_source_t *stop_source;
};

static inline bool source_enum_active_data_valid(const struct obs_source *source, const char *f)
{
return obs_source_valid(source, f) && source->context.data;
}

#define source_enum_data source_enum_active_data
#define data_valid source_enum_active_data_valid

static void enum_source_active_tree_callback(obs_source_t *parent, obs_source_t *child, void *param)
{
struct source_enum_data *data = param;
bool is_transition = child->info.type == OBS_SOURCE_TYPE_TRANSITION;

if (is_transition)
obs_transition_enum_sources(child, enum_source_active_tree_callback, param);
if (child->info.enum_active_sources) {
if (child->context.data) {
child->info.enum_active_sources(child->context.data, enum_source_active_tree_callback, data);
}
}

data->enum_callback(parent, child, data->param);
}

void obs_source_enum_active_sources(obs_source_t *source, obs_source_enum_proc_t enum_callback, void *param)
{
bool is_transition;
if (!data_valid(source, "obs_source_enum_active_sources"))
return;

is_transition = source->info.type == OBS_SOURCE_TYPE_TRANSITION;
if (!is_transition && !source->info.enum_active_sources)
return;

source = obs_source_get_ref(source);
if (!data_valid(source, "obs_source_enum_active_sources"))
return;

if (is_transition)
obs_transition_enum_sources(source, enum_callback, param);
if (source->info.enum_active_sources)
source->info.enum_active_sources(source->context.data, enum_callback, param);

obs_source_release(source);
}

void obs_source_enum_active_tree(obs_source_t *source, obs_source_enum_proc_t enum_callback, void *param)
{
struct source_enum_data data = {enum_callback, param};
bool is_transition;

if (!data_valid(source, "obs_source_enum_active_tree"))
return;

is_transition = source->info.type == OBS_SOURCE_TYPE_TRANSITION;
if (!is_transition && !source->info.enum_active_sources)
return;

source = obs_source_get_ref(source);
if (!data_valid(source, "obs_source_enum_active_tree"))
return;

if (source->info.type == OBS_SOURCE_TYPE_TRANSITION)
obs_transition_enum_sources(source, enum_source_active_tree_callback, &data);
if (source->info.enum_active_sources)
source->info.enum_active_sources(source->context.data, enum_source_active_tree_callback, &data);

obs_source_release(source);
}

#undef data_valid
#undef source_enum_data
62 changes: 0 additions & 62 deletions libobs/obs-source.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -2819,68 +2819,6 @@ struct source_enum_data {
obs_source_t *stop_source;
};

static void enum_source_active_tree_callback(obs_source_t *parent, obs_source_t *child, void *param)
{
struct source_enum_data *data = param;
bool is_transition = child->info.type == OBS_SOURCE_TYPE_TRANSITION;

if (is_transition)
obs_transition_enum_sources(child, enum_source_active_tree_callback, param);
if (child->info.enum_active_sources) {
if (child->context.data) {
child->info.enum_active_sources(child->context.data, enum_source_active_tree_callback, data);
}
}

data->enum_callback(parent, child, data->param);
}

void obs_source_enum_active_sources(obs_source_t *source, obs_source_enum_proc_t enum_callback, void *param)
{
bool is_transition;
if (!data_valid(source, "obs_source_enum_active_sources"))
return;

is_transition = source->info.type == OBS_SOURCE_TYPE_TRANSITION;
if (!is_transition && !source->info.enum_active_sources)
return;

source = obs_source_get_ref(source);
if (!data_valid(source, "obs_source_enum_active_sources"))
return;

if (is_transition)
obs_transition_enum_sources(source, enum_callback, param);
if (source->info.enum_active_sources)
source->info.enum_active_sources(source->context.data, enum_callback, param);

obs_source_release(source);
}

void obs_source_enum_active_tree(obs_source_t *source, obs_source_enum_proc_t enum_callback, void *param)
{
struct source_enum_data data = {enum_callback, param};
bool is_transition;

if (!data_valid(source, "obs_source_enum_active_tree"))
return;

is_transition = source->info.type == OBS_SOURCE_TYPE_TRANSITION;
if (!is_transition && !source->info.enum_active_sources)
return;

source = obs_source_get_ref(source);
if (!data_valid(source, "obs_source_enum_active_tree"))
return;

if (source->info.type == OBS_SOURCE_TYPE_TRANSITION)
obs_transition_enum_sources(source, enum_source_active_tree_callback, &data);
if (source->info.enum_active_sources)
source->info.enum_active_sources(source->context.data, enum_source_active_tree_callback, &data);

obs_source_release(source);
}

static void enum_source_full_tree_callback(obs_source_t *parent, obs_source_t *child, void *param)
{
struct source_enum_data *data = param;
Expand Down
1 change: 1 addition & 0 deletions rust/README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions rust/obs-build/tests/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ mod canonical_source_configurable_swap_is_registered;
mod canonical_source_defaults_swap_is_registered;
#[path = "native/registration/canonical_source_draw_swap_is_registered.rs"]
mod canonical_source_draw_swap_is_registered;
#[path = "native/registration/canonical_source_enum_active_swap_is_registered.rs"]
mod canonical_source_enum_active_swap_is_registered;
#[path = "native/registration/canonical_source_enum_filters_swap_is_registered.rs"]
mod canonical_source_enum_filters_swap_is_registered;
#[path = "native/registration/canonical_source_flags_mixers_swap_is_registered.rs"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use super::*;

#[test]
fn canonical_source_enum_active_swap_is_registered() {
use obs_build::validation::graph::{Graph, Source};
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
let mut graph = Graph::load(&root.join("test/cmocka/build/test-graph.json")).unwrap();
let name = "test_source_enum_active";
graph.targets.retain(|key, _| key == name);
graph.tests.retain(|key, _| key == name);
for os in ["OS_LINUX", "OS_MACOS", "OS_WINDOWS"] {
let selected = graph.select(&[(os.into(), true)].into()).unwrap();
// The test compiles no copy of the two calls: it calls the exported
// symbols of the real libobs (Rust in hybrid, the original C in the
// reference).
assert!(
matches!(selected.targets[name].sources.as_slice(), [Source::Path(path)]
if path == "test/cmocka/test_source_enum_active.c")
);
assert!(selected.targets[name].definitions.is_empty());
assert_eq!(selected.tests[name].target, name);
}
let ported =
fs::read_to_string(root.join("libobs/build/ported-source-sets/source-enum-active.json"))
.unwrap();
assert!(ported.contains("build/libobs.ported-source-enum-active+.h.c"));
let group = fs::read_to_string(root.join("libobs/build/libobs.ported-source-enum-active+.h.c"))
.unwrap();
assert!(group.contains("#include \"libobs/obs-source-enum-active.c.h\""));
let hybrid = fs::read_to_string(root.join("libobs/build/libobs.core-source+.h.c")).unwrap();
assert!(!hybrid.contains("#include \"libobs/obs-source-enum-active.c.h\""));
assert!(hybrid.contains("#include \"libobs/obs-source-enum-active-fields.c.h\""));
let exports = fs::read_to_string(
root.join("libobs/cmake/rust-exports.d/obs-source-source_enum_active.txt"),
)
.unwrap();
assert_eq!(
exports.lines().collect::<Vec<_>>(),
[
"obs_source_enum_active_sources",
"obs_source_enum_active_tree",
]
);
}
1 change: 1 addition & 0 deletions rust/obs-c-oracle/oracle.d/source-enum-active.list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source-enum-active.inc|libobs/obs-source-enum-active.c.h|auto
17 changes: 6 additions & 11 deletions rust/obs-c-oracle/oracle/audio_callback_links.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/* Test-only link stand-ins: obs_source_audio_render() and
* obs_source_enum_active_tree() under libobs's own names, for the test
/* Test-only link stand-in: obs_source_audio_render() under libobs's own
* name, for the test
* binaries that link the obs-core shims without libobs.
*
* The audio tick's shim (rust/obs-core/src/ffi/audio_callback.rs) exports
* audio_callback(), whose libobs calls name them. The MSVC, MinGW and macOS
* audio_callback(), whose libobs calls name it. The MSVC, MinGW and macOS
* linkers want every symbol an object names resolved, used or not, so
* obs-tests-core needs a definition; libobs has the real ones.
* obs_source_active() is the real Rust export of obs-source (#5401), whose
* counter adapters oracle/source_showing_active.c compiles, and
* obs_source_removed() is its export too (#5587), whose flag adapter
* oracle/source_removed.c compiles.
* oracle/source_removed.c compiles. obs_source_enum_active_tree() is its
* export too (#5729), whose field adapters oracle/source_enum_active.c
* compiles.
* obs_source_get_ref() and obs_source_release() (oracle/view.c),
* obs_source_get_name() (the obs-missing-files tests),
* audio_output_get_sample_rate() and audio_output_get_channels()
Expand All @@ -29,10 +31,3 @@ void obs_source_audio_render(obs_source_t *source, uint32_t mixers, size_t chann
UNUSED_PARAMETER(sample_rate);
UNUSED_PARAMETER(size);
}

void obs_source_enum_active_tree(obs_source_t *source, obs_source_enum_proc_t enum_callback, void *param)
{
UNUSED_PARAMETER(source);
UNUSED_PARAMETER(enum_callback);
UNUSED_PARAMETER(param);
}
Loading
Loading