Skip to content
Merged
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
4 changes: 2 additions & 2 deletions libobs/build/libobs.core+.h.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "libobs/build/libobs.pch.h"

#include "libobs/obs-audio-info-queries.c.h"
#include "libobs/obs-audio-info-queries-fields.c.h"
#include "libobs/obs-base-effect-fields.c.h"
#include "libobs/obs-context-runtime.c.h"
#include "libobs/obs-core-cmdline-fields.c.h"
Expand Down Expand Up @@ -63,7 +63,7 @@
#include "libobs/obs-ui-task-handler-fields.c.h"
#include "libobs/obs-video-info-query-fields.c.h"
#include "libobs/obs-video-level-queries-fields.c.h"
#include "libobs/obs-video-stats-queries.c.h"
#include "libobs/obs-video-stats-queries-fields.c.h"
#include "libobs/obs-weak-object-expired-fields.c.h"
#include "libobs/obs-weak-object-identity-fields.c.h"
#include "libobs/obs-weak-object-refs-fields.c.h"
Expand Down
5 changes: 5 additions & 0 deletions libobs/build/libobs.ported-audio-info-queries+.h.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* Unity group (BUILD.md): original audio-info queries, C reference only. */

#include "libobs/build/libobs.pch.h"

#include "libobs/obs-audio-info-queries.c.h"
5 changes: 5 additions & 0 deletions libobs/build/libobs.ported-video-stats-queries+.h.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* Unity group (BUILD.md): original video-statistics queries, C reference only. */

#include "libobs/build/libobs.pch.h"

#include "libobs/obs-video-stats-queries.c.h"
5 changes: 5 additions & 0 deletions libobs/build/ported-source-sets/audio-info-queries.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"LIBOBS_PORTED_SOURCES": [
"build/libobs.ported-audio-info-queries+.h.c"
]
}
5 changes: 5 additions & 0 deletions libobs/build/ported-source-sets/video-stats-queries.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"LIBOBS_PORTED_SOURCES": [
"build/libobs.ported-video-stats-queries+.h.c"
]
}
2 changes: 2 additions & 0 deletions libobs/cmake/rust-exports.d/obs-core-audio_info_queries.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obs_get_audio_info
obs_get_audio_info2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
obs_get_active_fps
obs_get_average_frame_time_ns
obs_get_lagged_frames
obs_get_total_frames
obs_get_video_frame_time
35 changes: 35 additions & 0 deletions libobs/obs-audio-info-queries-fields.c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "libobs/build/libobs.pch.h"

/* Private adapters for the Rust obs_get_audio_info() and obs_get_audio_info2()
* (#5363): the current core, one read of each audio field, and the output's
* info through the real audio_output_get_info(). The core layout stays in C;
* the Rust shim checks the core for NULL before it asks for any field. */
const struct obs_core *obs_audio_info_queries_core(void);
const struct obs_core *obs_audio_info_queries_core(void)
{
return obs;
}

audio_t *obs_audio_info_queries_output(const struct obs_core *core);
audio_t *obs_audio_info_queries_output(const struct obs_core *core)
{
return core->audio.audio;
}

const struct audio_output_info *obs_audio_info_queries_output_info(const audio_t *audio);
const struct audio_output_info *obs_audio_info_queries_output_info(const audio_t *audio)
{
return audio_output_get_info(audio);
}

bool obs_audio_info_queries_fixed_buffer(const struct obs_core *core);
bool obs_audio_info_queries_fixed_buffer(const struct obs_core *core)
{
return core->audio.fixed_buffer;
}

int obs_audio_info_queries_max_buffering_ticks(const struct obs_core *core);
int obs_audio_info_queries_max_buffering_ticks(const struct obs_core *core)
{
return core->audio.max_buffering_ticks;
}
42 changes: 42 additions & 0 deletions libobs/obs-video-stats-queries-fields.c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "libobs/build/libobs.pch.h"

/* Private adapters for the Rust video-statistics queries (#5364): the current
* core's stats, and its five obs_video_stats_* readers, which are static
* inline in obs-video-stats.h. Each reader keeps its one lock/read/unlock
* (#175); the stats layout and mutex stay in C. A live core is required, as
* in the original: the address is formed without a NULL check. */
struct obs_video_stats *obs_video_stats_queries_stats(void);
struct obs_video_stats *obs_video_stats_queries_stats(void)
{
return &obs->video.stats;
}

uint64_t obs_video_stats_queries_frame_time(struct obs_video_stats *stats);
uint64_t obs_video_stats_queries_frame_time(struct obs_video_stats *stats)
{
return obs_video_stats_frame_time(stats);
}

double obs_video_stats_queries_fps(struct obs_video_stats *stats);
double obs_video_stats_queries_fps(struct obs_video_stats *stats)
{
return obs_video_stats_fps(stats);
}

uint64_t obs_video_stats_queries_avg_frame_time_ns(struct obs_video_stats *stats);
uint64_t obs_video_stats_queries_avg_frame_time_ns(struct obs_video_stats *stats)
{
return obs_video_stats_avg_frame_time_ns(stats);
}

uint32_t obs_video_stats_queries_total_frames(struct obs_video_stats *stats);
uint32_t obs_video_stats_queries_total_frames(struct obs_video_stats *stats)
{
return obs_video_stats_total_frames(stats);
}

uint32_t obs_video_stats_queries_lagged_frames(struct obs_video_stats *stats);
uint32_t obs_video_stats_queries_lagged_frames(struct obs_video_stats *stats)
{
return obs_video_stats_lagged_frames(stats);
}
2 changes: 2 additions & 0 deletions rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,11 @@ The private output starting/encoder-demand queries use lazy safe Rust decisions
| `libobs/obs-nix-system-info.c.h` | `obs-core::nix_system_info` | Swapped in hybrid `libobs` (group `libobs.ported-nix-system-info`, in the Linux ported sources, which FreeBSD and OpenBSD build too). Eleven pure functions on lines and sizes, declared in `obs-nix-system-info.h` without `EXPORT` and hidden: `obs_nix_system_info_is_name`, `_is_physical_id` and `_is_speed` (`log_processor_info()`'s `strncmp()` key checks, by the key's length, so `model names` matches), `_value` (a pointer after the first `:`, or `NULL` without one or at the end of the line), `_physical_id` (`atoi()` as glibc defines it: `(int)strtol()`), `_prints` (a line that starts with `\n` and a physical id other than the last printed), `_is_dmesg_cpu` and `_dmesg_speed` (FreeBSD's `CPU: ` line: after the last `(`, its length up to the first `-` in `*len`, untouched on `NULL`), `_total_mb`, `_free_mb` and `_physmem_mb` (wrapping `uint64_t` products over 1024 twice, and OpenBSD's `int64_t` truncated toward zero). Each key check is its own function, so the three checks of a cpuinfo line and each `continue` stay where they were. `obs-nix.c.h` keeps `fopen()`, `getline()`, `fclose()`, `free()`, every `dstr` copy, cut and depad, `sysinfo()` and `sysctl()`, the flatpak, desktop and data file pointer checks, and every `blog()` (the distribution, Flatpak and desktop rules are `obs-nix-log-rules.c.h`'s row). No intentional differences (`atoi()` past `int` is undefined in C; the core follows glibc); characterized, not endorsed and kept: arm64 logs no CPU name or speed (its physical id stays -1, the starting last id), a block that ends before a `model name` or `cpu MHz` line logs them as `NULL`, the last line of a file with no newline loses a byte to the newline cut, `physical id : x` reads as 0, a `dmesg.boot` speed with no `-` runs to the end of the line, and the memory products wrap above 16 EiB. `test_nix_system_info_steps` compiles the C into itself; it has no `_rust` variant, as for `test_canvas_rules_steps`. Tier 3 compares every result exactly over every line of up to three pieces of the cpuinfo and `dmesg.boot` alphabet, every byte after each key, the host's `/proc/cpuinfo`, `atoi()` from -70,000 to 70,000 and around the ends of `int`, the memory sizes over the edges of every field, both callers' loops over saved and generated files, and proptests over all of it; out-of-range `atoi()` is compared on Linux only. |
| `libobs/obs-enum-scenes.c.h` | `obs-core::enum_scenes` | Legacy main-canvas scene enumerator (#4802). Forwards the borrowed current canvas, callback identity and opaque parameter exactly once to the existing canvas enumerator, preserving traversal, stopping and ownership. Tier 1 mirrors unchanged C characterization; original-C Tier 3 checks real adapter layout, callback effects and object bytes; Tier 2 exercises both actual libraries. Uninitialized/dead core/canvas, invalid callback/parameter and overflowing references are C UB, excluded; no intentional differences. |
| `libobs/obs-video-level-queries.c.h` | `obs-core::video_level_queries` | Video SDR white and HDR nominal peak level queries (#5187). A real private C adapter returns the current core, which safe Rust checks for NULL before a second adapter reads the graphics pointer and both stored levels. Without a core or graphics the queries return exactly 300.0 and 1000.0; otherwise each stored level's exact bits, with no validation, clamping or arithmetic (signed zeros, infinities and NaN payloads verbatim). Tier 1 mirrors the unchanged `test_video_level_queries`, which now links the Rust export and the real adapter; original-C Tier 3 checks real adapter layout, the three core states over edge and random bit patterns, unchanged core bytes and global pointer. `test_no_core_getters` and `test_video_levels_range` keep actual-library coverage. Dead core and concurrent level writes are excluded; signaling NaNs are left out of the random cases (32-bit x86 float returns may quiet them in both). No intentional differences. |
| `libobs/obs-video-stats-queries.c.h` | `obs-core::video_stats_queries` | The five public video-statistics queries swapped in hybrid `libobs` (#5364; group `libobs.ported-video-stats-queries` keeps the original for the C reference): `obs_get_video_frame_time`, `obs_get_active_fps`, `obs_get_average_frame_time_ns`, `obs_get_total_frames` and `obs_get_lagged_frames`. Each is one call of its own `obs_video_stats_*` reader on the current core's `video.stats` (one lock, read and unlock, the synchronization of #175), returned unchanged; never one combined snapshot, and no no-core defaults (a live core is required, as in C). The stats layout and mutex stay in C behind private adapters (`obs-video-stats-queries-fields.c.h`, which call the header's static inline readers; also a shared Rust-static support member). The unchanged `test_video_stats_queries` keeps testing the extracted C source and `test_video_stats_race` the readers; the real library's frame counters keep their actual-library callers. Tier 1 mirrors every assertion over a mutex-guarded host (one locked read of its own field per query, mutex free after each); Tier 3 runs the original and the shim on one real-header core (exact result bits with the FPS as any non-signaling binary64 pattern, mutex free after every query, unchanged values and current core pointer, the adapter's address) with mutants. No intentional differences; Tier 4 does not apply. |
| `libobs/obs-get-audio.c.h` | `obs-core::get_audio` | Borrowed current core audio output (#4808). Exact pointer forwarding, including null before setup/after disable, without ownership or activation changes. Safe Tier 1 mirrors the C characterization; original-C Tier 3 checks current-field changes, pointer identity, unchanged bytes and real adapter layout. Unchanged Tier 2 covers real output lifecycles. Initialized core required; no intentional differences. |
| `libobs/obs-get-output-source.c.h` | `obs-core::get_output_source` | Legacy main-canvas channel getter (#4756). Forwards the borrowed current canvas and unchanged channel exactly once to the existing getter and returns its acquired source unchanged. Tier 1 mirrors the C characterization; original-C Tier 3 checks return identity, reference effects, full-width forwarding and real adapter layout; unchanged Tier 2 exercises both actual libraries. Uninitialized core, dead canvas/source and overflowing refcounts are original C UB, excluded; no intentional differences. |
| `libobs/obs-set-locale.c.h` | `obs-core::set_locale` | Locale replacement and ordered module notifications through private field adapters. Frees old bmem storage before copying, stores the owned copy before callbacks, forwards the original pointer including NULL, and reads each next link after dispatch. Safe Tier 1 mirrors unchanged `test_set_locale`; Tier 3 compares the original C with the actual Rust FFI over bounded locale/list cases, including callback-time link changes. The common reference-only group covers every host; the native test fixture manifest remains unchanged. No intentional behavior differences; Tier 4 does not apply. |
| `libobs/obs-audio-info-queries.c.h` | `obs-core::audio_info_queries` | `obs_get_audio_info` and `obs_get_audio_info2` swapped in hybrid `libobs` (#5363; group `libobs.ported-audio-info-queries` keeps the original for the C reference). A NULL core answers false before any read (#2566, #3363). `obs_get_audio_info` checks its output, then the core's audio output, then reads the output's rate and speakers through the real `audio_output_get_info()`. `obs_get_audio_info2` runs the info read into a local first, then checks its own output and the audio output again, and stores the rate, the speakers, `fixed_buffer` and `obs_core_setup_rules_buffer_ms(max_buffering_ticks, rate)` cast straight to `uint32_t`. Nothing is written on failure; the caller's struct is written field by field. The core layout stays in C behind private adapters (`obs-audio-info-queries-fields.c.h`, also a shared Rust-static support member). The unchanged `test_audio_info_queries` keeps testing the extracted C source; `test_get_audio` and `test_core_setup_rules_steps` run the real library. Tier 1 mirrors every assertion plus the full read order; Tier 3 runs the original and the shim on one real-header core filled with any byte (result, output bytes, info call log, core bytes, current core pointer, real-header layouts) with mutants. The audio-controls oracle's `obs_get_audio_info` stand-in is dropped: obs-core's export answers false there without a current core. No intentional differences; Tier 4 does not apply. |
| `libobs/obs-module-load-all.c.h` | `obs-core::module_load_all` | The deprecated `obs_load_all_modules`/`obs_load_all_modules2` stay intentional no-ops: no startup, module discovery, loading, allocation, logging or state change, and the optional failure info (count, pointer array, strings) is never dereferenced. Tier 1 mirrors unchanged `test_module_load_all`; Tier 3 compares the original C over random caller counts and NULL. No intentional differences; Tier 4 does not apply. |
| `libobs/obs-set-output-source.c.h` | `obs-core::set_output_source` | Legacy main-canvas channel setter (#4709). Forwards the borrowed current canvas and unchanged channel/source exactly once to the existing canvas setter, preserving bounds, mutable local/global signals and all reference effects. Tier 1 mirrors the C characterization, callback-only original-C Tier 3 checks real adapter layout and unchanged object bytes, and unchanged Tier 2 runs both actual libraries. Uninitialized core and dead canvas/source are original C UB, excluded; no intentional differences. |
| `libobs/obs-get-main-canvas.c.h` | `obs-core::get_main_canvas` | Main-canvas acquired getter (#4780). A real private C adapter borrows the current field and supplies the existing canvas reference operation; safe Rust delegates exactly once and preserves its returned identity and ownership effects. Tier 1 mirrors unchanged `test_get_main_canvas`, Tier 3 includes the original C wrapper and real adapter with exact layout and complete fixture-byte comparisons, and Tier 2 replays both actual libraries. Uninitialized core, dead canvases and overflowing counts are excluded; no intentional differences or Tier 4 surface. |
Expand Down
9 changes: 2 additions & 7 deletions rust/obs-c-oracle/oracle/audio_controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* stubs them. libobs supplies them when this file is not linked. The signal
* calls are stubbed under oracle_* names: obs-callback exports the real
* signal_handler_* symbols, and a test that links both would define them
* twice. */
* twice. obs_get_audio_info is obs-core's export (#5363), which answers false
* here: no current core is installed outside its own parity probe. */

#include <stddef.h>

Expand Down Expand Up @@ -114,12 +115,6 @@ void obs_source_remove_audio_capture_callback(obs_source_t *source, obs_source_a
UNUSED_PARAMETER(param);
}

bool obs_get_audio_info(struct obs_audio_info *oai)
{
UNUSED_PARAMETER(oai);
return false;
}

void signal_handler_connect(signal_handler_t *handler, const char *signal, signal_callback_t callback, void *data)
{
UNUSED_PARAMETER(handler);
Expand Down
Loading
Loading