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
2 changes: 1 addition & 1 deletion libobs/build/libobs.core+.h.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "libobs/build/libobs.pch.h"

#include "libobs/obs-audio-info-queries-fields.c.h"
#include "libobs/obs-audio-monitoring-device.c.h"
#include "libobs/obs-audio-monitoring-device-fields.c.h"
#include "libobs/obs-base-effect-fields.c.h"
#include "libobs/obs-context-profiler-name-store.c.h"
#include "libobs/obs-context-runtime.c.h"
Expand Down
4 changes: 4 additions & 0 deletions libobs/build/libobs.ported-audio-monitoring-device+.h.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Unity group (BUILD.md): original monitoring device setter and reset, C reference only. */
#include "libobs/build/libobs.pch.h"

#include "libobs/obs-audio-monitoring-device.c.h"
5 changes: 5 additions & 0 deletions libobs/build/ported-source-sets/audio-monitoring-device.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"LIBOBS_PORTED_SOURCES": [
"build/libobs.ported-audio-monitoring-device+.h.c"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obs_reset_audio_monitoring
obs_set_audio_monitoring_device
77 changes: 77 additions & 0 deletions libobs/obs-audio-monitoring-device-fields.c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include "libobs/build/libobs.pch.h"

/* Private adapters for the Rust obs_set_audio_monitoring_device() and
* obs_reset_audio_monitoring() (#5491). The monitoring fields, their mutex
* and bmem copies, the monitor list and audio_monitor_reset(), the source
* enumeration and the Audio Output Capture notice stay in C; Rust decides
* which runs, and in what order. */

_Static_assert(OBS_CORE_SETUP_RULES_DO_NOT_SELF_MONITOR == OBS_SOURCE_DO_NOT_SELF_MONITOR,
"OBS_SOURCE_DO_NOT_SELF_MONITOR");

bool obs_audio_monitoring_device_available(void);
bool obs_audio_monitoring_device_available(void)
{
return obs_audio_monitoring_available();
}

void obs_audio_monitoring_device_lock(void);
void obs_audio_monitoring_device_lock(void)
{
pthread_mutex_lock(&obs->audio.monitoring_mutex);
}

void obs_audio_monitoring_device_unlock(void);
void obs_audio_monitoring_device_unlock(void)
{
pthread_mutex_unlock(&obs->audio.monitoring_mutex);
}

int obs_audio_monitoring_device_compare(const char *id);
int obs_audio_monitoring_device_compare(const char *id)
{
return strcmp(id, obs->audio.monitoring_device_id);
}

void obs_audio_monitoring_device_store(const char *name, const char *id);
void obs_audio_monitoring_device_store(const char *name, const char *id)
{
bfree(obs->audio.monitoring_device_name);
bfree(obs->audio.monitoring_device_id);

obs->audio.monitoring_device_name = bstrdup(name);
obs->audio.monitoring_device_id = bstrdup(id);
}

size_t obs_audio_monitoring_device_monitor_count(void);
size_t obs_audio_monitoring_device_monitor_count(void)
{
return obs->audio.monitors.num;
}

void obs_audio_monitoring_device_reset_monitor(size_t index);
void obs_audio_monitoring_device_reset_monitor(size_t index)
{
audio_monitor_reset(obs->audio.monitors.array[index]);
}

void obs_audio_monitoring_device_enum_sources(bool (*visit)(void *, obs_source_t *), void *param);
void obs_audio_monitoring_device_enum_sources(bool (*visit)(void *, obs_source_t *), void *param)
{
obs_enum_sources(visit, param);
}

uint32_t obs_audio_monitoring_device_output_flags(const obs_source_t *source);
uint32_t obs_audio_monitoring_device_output_flags(const obs_source_t *source)
{
return source->info.output_flags;
}

void obs_audio_monitoring_device_notify(obs_source_t *source);
void obs_audio_monitoring_device_notify(obs_source_t *source)
{
obs_data_t *settings = obs_source_get_settings(source);
const char *device_id = obs_data_get_string(settings, "device_id");
obs_source_audio_output_capture_device_changed(source, device_id);
obs_data_release(settings);
}
1 change: 1 addition & 0 deletions rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ The private output starting/encoder-demand queries use lazy safe Rust decisions
| `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-reset-audio2.c.h` | `obs-core::reset_audio2` | `obs_reset_audio2` swapped in hybrid `libobs` (#5486; group `libobs.ported-reset-audio2` keeps the original for the C reference, reaching the static `obs_init_audio`/`obs_free_audio` of `obs.c.h` through the adapters, `obs-reset-audio2-reference-steps.c.h`). In order: with no core it returns false before anything else (`core_setup_rules::audio_refused`, #3363); with an audio output it asks `audio_output_active()` once and refuses an active one with nothing changed and nothing logged; otherwise it frees the audio (`obs_free_audio()`), and a NULL info returns true there. With an info it reads the info after the free, stores `max_buffering_ticks` (`buffer_ticks` of a set `max_buffering_ms`, else `buffer_default_ticks`, the `uint32_t` cast to `int`) and then `fixed_buffer`, logs the separator and the "audio settings reset" message at `LOG_INFO` with the original's format strings (rate cast to `int`, layout, the stored ticks back in milliseconds through `buffer_ms`, "fixed" or "dynamically increasing"), and returns `obs_init_audio()` on the "Audio", float planar info at the rate and layout given with `audio_callback`. The core pointer, the output, the free, the two fields and the open stay C behind private adapters (`obs-reset-audio2-fields.c.h`, core group); the decisions, the ticks and the message are Rust. Tier 1 mirrors every case of unchanged `test_reset_audio2` plus the step order, the open's result and the buffering and message edges; Tier 3 runs the original and the shim on one recording fixture core (result, every step in order: the handle asked about, the free, the info passed to `obs_init_audio()` with the fields stored when it is called, each `blog` level, format, `%d` and `%s`; the output and fields after) over every gate path, the C test's cases and edges and proptest setups, with six mutants. Unchanged Tier 2 runs both actual libraries. A dead core or unreadable info is outside the contract. No intentional differences beyond `buffer_ms`'s zero-rate rule (#3272); Tier 4 does not apply. |
| `libobs/obs-audio-monitoring-device.c.h` | `obs-core::audio_monitoring_device` | `obs_set_audio_monitoring_device` and `obs_reset_audio_monitoring` swapped in hybrid `libobs` (#5491; group `libobs.ported-audio-monitoring-device` keeps the original for the C reference). Setting refuses a NULL name, a NULL id, an empty name and an empty id, asked in that order through `core_setup_rules::monitor_missing` before anything else is touched, then refuses when monitoring is unavailable. Under `monitoring_mutex` an id equal to the stored one (`monitor_same` of the `strcmp`) unlocks and answers true with nothing changed; otherwise the stored name and id are freed and replaced by `bstrdup` copies, the mutex is released, every live monitor is reset (`obs_reset_audio_monitoring`, which asks for availability again), and each source `obs_enum_sources` hands over whose output flags pass `aoc_check` (`OBS_SOURCE_DO_NOT_SELF_MONITOR`) is told through `obs_source_audio_output_capture_device_changed` with its own `device_id` setting. Resetting does nothing when monitoring is unavailable, otherwise resets each live monitor once under `monitoring_mutex`, reading the count again before each step. The fields, the mutex, the copies, the monitor list, `audio_monitor_reset`, the enumeration and the notice stay in C behind private adapters (`obs-audio-monitoring-device-fields.c.h`, in the core group). Tier 1 mirrors every case of unchanged `test_set_audio_monitoring_device` and the refusals of `test_monitoring_device` over a model core, plus the full step order; Tier 3 runs the original and the shims on one recording real-header core over fixed and proptest names, ids, stored ids, availability, monitor counts and source sets (result, every core read, lock, compare, free, copy, reset, enumeration and per-source settings read, notice and release, the stored strings) with ten mutants. Unchanged Tier 2 (`test_set_audio_monitoring_device`, `test_core_setup_rules_steps`, `test_pulse_monitor_reset`) runs both actual libraries. An uninitialized core and a NULL stored id are outside the contract (the original dereferences both). 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. |
| `libobs/obs-win-crash-report.c.h` | `obs-core::win_crash_report` | Swapped in hybrid `libobs` (group `libobs.ported-win-crash-report`, in the Windows ported sources). Nine pure functions on integers, declared in `obs-win-crash-report.h` without `EXPORT` and hidden; they take no Windows type, so the file, its C test and its oracle build on every OS: `obs_win_crash_report_contains` (`enum_all_modules()`'s and `enum_module()`'s `base <= addr < base + size`, the end a wrapping `uint64_t`), `_is_crashed`, `_in_pass` and `_other_process` (`write_thread_trace()`'s id against `GetCurrentThreadId()`, the crashed thread in the first pass and every other in the second, and the owner against `GetCurrentProcessId()`), `_names_symbol` (`walk_stack()`'s line with the symbol unless `SYMFLAG_EXPORT`, 0x200, `_Static_assert`ed against `dbghelp.h`; the flags still read only after a successful lookup), `_mask_address` and `_mask_param` (a 32-bit build's masks: 36 bits on the stack and PC, 32 on the parameters), `_name_prefix` (`get_thread_name()`'s leading space for a non-empty name) and `_pass_on` (`exception_handler()`'s two early returns: a debugger, or re-entered, reading `*inside` only without a debugger). Each check of `write_thread_trace()` is its own function, so `GetCurrentProcessId()` is still called only for a thread in its pass. `obs-win-crash-handler.c.h` keeps every DbgHelp, toolhelp and thread call, `os_wcs_to_utf8()`, `strlwr()`, `strrchr()`, every `dstr` call and format string, `bcrash()` and both static flags. The core runs inside the unhandled exception filter: no allocation, indexing or panic path, and a per-thread counting allocator in the core test binary checks that no shim or core rule allocates. No intentional differences; characterized, not endorsed and kept: a module whose end wraps past 2^64, or lands on it, holds nothing; the stack and PC masks keep 36 bits where the parameters keep 32; the crashed thread's id under another process is left out of both passes. `test_win_crash_report_steps` compiles the C into itself on every OS; it has no `_rust` variant, as for `test_nix_system_info_steps`. `test_win_crash_sym_info` (Windows) compiles it with the handler. Tier 3 compares every result exactly over every combination of edge bases, sizes and addresses at each module's edges, every pair of edge thread ids, `write_thread_traces()`'s two passes over every snapshot of up to three threads, every flag of the low 16 bits under four high patterns and every pair of bits, both masks around every power of two, name lengths 0 to 4096, the filter with NULL for the flag under a debugger, and proptests over all of it; nothing is skipped on any host. |
Expand Down
Loading
Loading