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-source+.h.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include "libobs/obs-source-async-rotation-fields.c.h"
#include "libobs/obs-source-audio-active-fields.c.h"
#include "libobs/obs-source-audio-active-setter-fields.c.h"
#include "libobs/obs-source-audio-capture-callbacks.c.h"
#include "libobs/obs-source-audio-capture-callback-fields.c.h"
#include "libobs/obs-source-audio-input-path-seam.c.h"
#include "libobs/obs-source-audio-mixers-fields.c.h"
#include "libobs/obs-source-audio-output-seam.c.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Unity group (BUILD.md): original audio-capture subscription registration. */
#include "libobs/build/libobs.pch.h"

#include "libobs/obs-source-audio-capture-callbacks.c.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"LIBOBS_PORTED_SOURCES": [
"build/libobs.ported-source-audio-capture-callbacks+.h.c"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obs_source_add_audio_capture_callback
obs_source_remove_audio_capture_callback
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obs_source_add_audio_capture_callback_rust
obs_source_remove_audio_capture_callback_rust
5 changes: 5 additions & 0 deletions libobs/obs-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,11 @@ struct obs_source_properties_fields {
struct obs_source_properties_fields obs_source_properties_info_fields(const struct obs_source_info *info);
struct obs_source_properties_fields obs_source_properties_instance_fields(const obs_source_t *source);

/* Audio-capture list address and mutex operations for Rust registration. Non-NULL only. */
extern struct darray *obs_source_audio_capture_callback_fields(obs_source_t *source);
extern void obs_source_audio_capture_callback_lock(obs_source_t *source);
extern void obs_source_audio_capture_callback_unlock(obs_source_t *source);

/* Caption list addresses and mutex operations for Rust registration. Non-NULL only. */
extern struct darray *obs_source_caption_callback_fields(obs_source_t *source);
extern void obs_source_caption_callback_lock(obs_source_t *source);
Expand Down
16 changes: 16 additions & 0 deletions libobs/obs-source-audio-capture-callback-fields.c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "libobs/build/libobs.pch.h"

struct darray *obs_source_audio_capture_callback_fields(obs_source_t *source)
{
return &source->audio_cb_list.da;
}

void obs_source_audio_capture_callback_lock(obs_source_t *source)
{
pthread_mutex_lock(&source->audio_cb_mutex);
}

void obs_source_audio_capture_callback_unlock(obs_source_t *source)
{
pthread_mutex_unlock(&source->audio_cb_mutex);
}
1 change: 1 addition & 0 deletions rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ The private output starting/encoder-demand queries use lazy safe Rust decisions
| `libobs/obs-source-audio-output.c.h` | `obs-source::audio_output`, shims in `obs-source-seam::ffi::source_audio_output` | Swapped in hybrid `libobs` (group `libobs.ported-source-audio-output`); Tier 3 in `obs-source-seam/tests/source_seam/audio_output_parity.rs` | None. |
| `libobs/obs-source-audio-pause-callbacks.c.h` | `obs-source::audio_pause_callbacks`, shims in `obs-source::ffi::source_audio_pause_callbacks` | Swapped in hybrid `libobs` (group `libobs.ported-source-audio-pause-callbacks`). `obs_source_add_audio_pause_callback` and `obs_source_remove_audio_pause_callback`: a NULL source logs `<name>: Null 'source' parameter` at `LOG_DEBUG` and touches nothing; otherwise the source's signal handler is fetched once and the (callback, param) pair is connected to, or disconnected from, `media_pause` then `media_stopped`. The signal handler (`obs-callback`), `obs_source_get_signal_handler()` and the macOS monitor that subscribes stay as they are. `test_source_audio_pause_callbacks` sees the swap through the hybrid libobs. Tier 3 compares the core's ordered call trace with the original C over every NULL source, NULL callback and NULL param combination and proptest sequences, with callback and param forwarding checked by the C recorder. | None. |
| `libobs/obs-source-audio-place.c.h` | `obs-source::audio_place` | Swapped in hybrid `libobs` (group `libobs.ported-source-audio-place`). The source audio placement and action timeline, which every audio packet a source outputs and every tick with queued audio actions go through, as eleven functions on plain values, each asked where the C made the decision: `obs_source_audio_place_started()` and `_older()` (`audio_ts != 0` and `timestamp < audio_ts`: the reset of `source_output_audio_place()` with no `audio_ts` or an older packet, the push-back rule of `source_output_audio_data()` and the action clamp of `apply_audio_actions()`), `_size()`, `_offset()`, `_fits()` and `_pop_back()` (the packet's bytes, `frames * sizeof(float)`; its byte placement, `get_buf_placement()`'s `(size_t)util_mul_div64(timestamp - audio_ts, rate, 1e9) * sizeof(float)`; the drop when the place or the push back would pass `MAX_BUF_SIZE`; the bytes popped off the back of each channel after the place), `_outputs()` (nothing for `OBS_MONITORING_TYPE_MONITOR_ONLY`), `_action_frame()` (`conv_time_to_frames()`, which goes), `_action_stops()` (at `AUDIO_OUTPUT_FRAMES`), `_fill_end()` (how far the previous volume fills) and `_mix_on()` (the mixes the volume array multiplies). They are declared in `obs-source-audio-place.h` without `EXPORT`, so the shims stay hidden. `obs-source.c.h` keeps every read where it was, with the C's `&&` and `||` around the calls: `audio_ts` once or twice for the place's reset, again after `reset_audio_data()` for the placement, in the route only when `push_back` is set, and in the action loop once for the clamp, again when it applies and again for the frame; `monitoring_type` before `audio_ts`; each channel's size after its `deque_place()` and the first channel's before a push back; `audio_mixers` once per mix. It keeps `audio_buf_mutex` and `audio_actions_mutex`, `audio_output_get_channels()`, `get_buf_placement()` with its `audio_output_get_sample_rate()` call (the timestamps are read before it, as when their difference was its argument), `reset_audio_data()`, the deques, the `DEBUG_AUDIO` log, the stores of `last_audio_input_buf_size`, `da_erase()`, `apply_audio_action()`, every `get_source_volume()` call (before the loop and after each applied action, so each action's push-to-talk and push-to-mute state is seen), the volume array and `multiply_vol_data()`. The header mirrors `AUDIO_OUTPUT_FRAMES`, `MAX_BUF_SIZE` and `OBS_MONITORING_TYPE_MONITOR_ONLY`, and `obs-source.c.h` checks them and the enum's size. No pointer crosses. The arithmetic wraps where the C's does; the conversion is `obs-source::transition_render`'s `util_mul_div64()` per host. Kept, characterized, not endorsed: a packet or action less than one sample after `audio_ts` lands on frame 0, on top of the samples there; a packet larger than `MAX_BUF_SIZE` on its own is dropped whole; a push back checks only the first channel's size; an action before `audio_ts` applies at frame 0, and once one is at frame 1024 or later every later action waits, even a due one; a monitoring type outside the enum outputs. Intentional differences, on inputs libobs never passes: `_mix_on()` with a mix of 32 or more says no mix (the C's `int` shift is undefined from 31 on; libobs asks 0 to 5), and on MSVC x64 a frame count past 64 bits (a rate above 1e9 Hz), where the C's `_udiv128()` faults, saturates. `test_source_audio_place_steps` compiles the C into itself, and `test_source_audio_place_steps_rust` runs the same test source against `libobs_rust-static`; `test_async_delay_audio`, `test_audio_sync_offset_change`, `test_audio_clock_drift`, `test_audio_buffering_subsample`, `test_media_sync_offset_restart`, `test_audio_restart_resampler_tail`, `test_source_volume_mix`, `test_source_audio_ranges` and `test_audio_controls` see the swap through the real libobs. Tier 3 compares the oracle, the shims and the core: the header's values, the reset rules, the placement and the action frame over every pair of 30 special timestamps at 16 rates (to `u32::MAX`, and `size_t` rates for the frame), every frame edge to 2048 at eleven rates, the sizes over every pair and triple of 17 special values, every monitoring type from -100,000 to 100,000, the mix rule for every low 16-bit mask under eight high words at every mix to 30, the callers copied onto a stand-in source over 36,864 packet pairs and 21,316 action lists, and full-range proptests. |
| `libobs/obs-source-audio-capture-callbacks.c.h` | `obs-source::audio_capture_callbacks` (shared ordered-pair update in `obs-source::callback_registry`) | Public audio-capture registration swapped in hybrid libobs (group `libobs.ported-source-audio-capture-callbacks`); append order and duplicates, first exact-pair removal, NULL callback/param entries and the exact NULL-source diagnostics preserved. The real private adapter (`obs-source-audio-capture-callback-fields.c.h`) keeps `audio_cb_mutex`, the C darray and its bmem storage; audio delivery and teardown are unchanged. `test_source_audio_capture_callbacks` compiles the C into itself, and `test_audio_capture_callbacks_rust` runs the same source against `libobs_rust-static` through the private `_rust` entries and the real adapter compiled over its recording mutex. Tier 3 compares generated operation sequences, both entry pairs, the diagnostics and real-header layouts against the original C. | None. |
| `libobs/obs-source-audio-render.c.h` | `obs-source::audio_render_plan` | Swapped in hybrid `libobs` (group `libobs.ported-source-audio-render`). The audio render mix plan of `obs_source_audio_render()`, `custom_audio_render()` and `process_audio_source_tick()`, which decide for every audio source on every tick of the mix which mixes are cleared, copied and scaled, as thirteen functions on plain values: `obs_source_audio_render_route()` (pending without an output buffer, or for a custom render without data, 432017b2c and cf0a5e5c9; the custom render; else the tick), `_custom_clear_before()` (a mix in both masks is cleared before the plugin's `audio_render` callback), `_custom_ts()` and `_custom_pending()` (its timestamp when it succeeds, else 0 and pending), `_custom_unmixed()` (no timestamp or no tick mixers: nothing after it), `_custom_in_tick()` and `_custom_clear_after()` (a mix of the tick the source is not on is cleared after it, d6ac45702), `_tick_unset()` and `_tick_short()` (pending with no timestamp or less input than the tick, #130), `_tick_stop()` and `_tick_copy()` (mixes 1 to 5 copy mix 0 when in both masks, else are cleared; a submix source, `OBS_SOURCE_SUBMIX`, does mix 1 only, from bit 0 of its mixers), and `_tick_volume()` and `_tick_clear_main()` (a submix source stops there; any other clears mix 0 unless in both masks, then scales). They are declared in `obs-source-audio-render.h` without `EXPORT`, so the shims stay hidden. The plan is one function per decision, not one call per tick, because `obs-source.c.h` keeps each read where it was: `audio_mixers` (set by other threads without a lock) once per mix before and after the callback, the input size only with a timestamp, `audio_ts` only after a successful callback, and the output buffer, `audio_render` and `context.data` only where the checks before reached them. It keeps `audio_buf_mutex`, `deque_peek_front()`, every memset and memcpy, the plugin callbacks, `audio_submix()` and `apply_audio_volume()`. No pointer crosses; the route goes back as the C enum's value; the callback's `ts` crosses by value also when the callback failed and is not looked at. Kept, characterized, not endorsed: tick mixers past the six mixes (0x40 and up) are not "no mixers", so a custom render's clears look at each mix and its volume runs; a submix source keeps the peeked input in mix 0 even when it is on no mix, and fills mix 1 whatever the tick's mixers. Intentional difference: a mix of 31 or more for the shifting decisions, where the C's `int` shift is undefined, names bit 31 and then no mix (libobs passes a mix below 6). `test_source_audio_render_steps` compiles the C into itself, and `test_source_audio_render_steps_rust` runs the same test source against `libobs_rust-static`; `test_source_volume_mix`, `test_source_audio_ranges`, `test_audio_capture_mix_race`, `test_group_hide_transition_audio` and the transition audio tests see the swap through the real libobs. Tier 3 compares the oracle, the shims and the core: every mask decision over every pair of the low seven mask bits with and without the high ones and every mix up to 30, the submix copy and the stop over any index, the timestamp, pending and size decisions over every pair of 30 special values, the three callers copied onto a stand-in source over every combination of seven flags with every pair of the low seven mask bits and edge timestamps, masks, sizes and channels (the recorded lock, peeks, memsets, memcpys, callbacks and volume, `audio_ts` and `audio_pending`), and full-range proptests. |
| `libobs/obs-source-audio-settings.c.h` | `obs-source::audio_settings`, shims in `obs-source-seam::ffi::source_audio_settings` | Swapped in hybrid `libobs` (group `libobs.ported-source-audio-settings`); Tier 3 in `obs-source-seam/tests/source_seam/audio_settings_parity.rs` | None. |
| `libobs/obs-source-audio-timing.c.h` | `obs-source::audio_timing` | Swapped in hybrid `libobs` (group `libobs.ported-source-audio-timing`). The audio timestamp placement of `source_output_audio_data()`, in two pure steps around `audio_buf_mutex`: `obs_source_audio_timing_pre_lock()` (the direct timestamp check, then reset, jump, smooth with the drift error and the async decoupled re-anchor, or the log, and `next_audio_ts_min`) and `obs_source_audio_timing_under_lock()` (append or place, the reset when the system time jumped and the audio was not continuous, #522, the sync and resampler offsets, `next_audio_sys_ts_min`, and "the sync offset changed, so place", #333), plus `obs_source_audio_timing_buffer_start()` (where `reset_audio_data_at_sys_time()` starts an emptied buffer, #286). They are declared in `obs-source-audio-timing.h` without `EXPORT`, so the shims stay hidden. `obs-source.c.h` keeps the field reads and the stores, in their order (the volatile `timing_set` and `timing_adjust` included), the lock, `handle_ts_jump()`, `audio_resampler_set_compensation_error()`, `conv_frames_to_time()` (it passes the packet's duration, so nothing in the port divides), the deque, the signal, the muting and the log lines. The shims read the struct's input fields and write its output fields one at a time, so the inputs and the padding keep their bytes. Every sum and difference wraps as the C's `uint64_t` does; the drift error is `cast_signed()` and the sync offset `cast_unsigned()`, the C's conversions. The crate depends on no other crate. Kept, characterized, not endorsed: a timestamp ahead of the clock gives a `timing_adjust` near `u64::MAX`; `timestamp + timing_adjust`, the packet's end, a negative sync offset larger than the packet's system time and a resampler offset larger than it wrap; the distance is not modular; a direct timestamp more than 2 s from the expected one is logged, not a jump. Intentional difference: a null struct pointer does nothing (the C dereferences it; libobs passes one on its stack). `test_source_audio_timing_steps` compiles the C into itself, and `test_source_audio_timing_steps_rust` runs the same test source against `libobs_rust-static` (the first `_rust` variant since `test_scene_bounds_place_rust`: the `obs-source` member links on its own); `test_async_delay_audio`, `test_audio_sync_offset_change`, `test_media_sync_offset_restart`, `test_audio_restart_resampler_tail` and `test_audio_clock_drift` see the swap through the real libobs. Tier 3 compares every byte of the step structs (padding included, from a random fill) over the special values with every flag, proptests of each step, and 2-50-packet sequences through a model of the caller, with the written-back state. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ target_link_libraries(reference PRIVATE OBS::libobs)
include("{root}/test/cmocka/tests.d/video_info_query_link_support.cmake")
function(check_support)
get_target_property(adapter_sources video_info_query_link_support SOURCES)
foreach(adapter IN ITEMS encoder-video-tex-active-fields encoder-video-tex-active-mix encoder-get-name output-interleave-name)
foreach(adapter IN ITEMS encoder-video-tex-active-fields encoder-video-tex-active-mix encoder-get-name
output-interleave-name source-audio-capture-callback)
if(NOT "{root}/test/cmocka/${{adapter}}-link-support.c" IN_LIST adapter_sources)
message(FATAL_ERROR "missing real encoder adapter source: ${{adapter}}")
message(FATAL_ERROR "missing real private adapter source: ${{adapter}}")
endif()
endforeach()
foreach(name IN ITEMS standalone with_shared future_consumer reference)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"schema": 1,
"targets": {
"test_audio_capture_callbacks_rust": {
"sources": [
"test/cmocka/test_source_audio_capture_callbacks.c",
"test/cmocka/source-audio-capture-callback-record-support.c",
"libobs/util/base-variadic.c.h",
"test/cmocka/source-identity-getter-link-stubs.c"
],
"definitions": [
"SOURCE_AUDIO_CAPTURE_EXTERNAL",
"obs_source_add_audio_capture_callback=obs_source_add_audio_capture_callback_rust",
"obs_source_remove_audio_capture_callback=obs_source_remove_audio_capture_callback_rust"
],
"libraries": [
"libobs_rust-static",
"OBS::libobs",
"OBS::caption",
"Uthash::Uthash",
"OBS::native-test-cmocka",
{
"name": "OBS::w32-pthreads",
"requires": "OS_WINDOWS"
}
],
"includes": [
".",
"libobs"
],
"requires": "HAVE_LIBOBS_RUST_STATIC"
}
},
"tests": {
"test_audio_capture_callbacks_rust": {
"target": "test_audio_capture_callbacks_rust",
"command": [
"${target}"
],
"requires": "HAVE_LIBOBS_RUST_STATIC"
}
}
}
4 changes: 4 additions & 0 deletions rust/obs-c-oracle/oracle/audio_controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#define obs_fader_db_to_def oracle_obs_fader_db_to_def
#define signal_handler_connect oracle_audio_controls_signal_handler_connect
#define signal_handler_disconnect oracle_audio_controls_signal_handler_disconnect
/* Rust obs-source exports the real registration (#5243); keep these no-op
* stand-ins private to this oracle. */
#define obs_source_add_audio_capture_callback oracle_audio_controls_add_audio_capture_callback
#define obs_source_remove_audio_capture_callback oracle_audio_controls_remove_audio_capture_callback

size_t oracle_obs_audio_info_size(void);
size_t oracle_obs_audio_info_align(void);
Expand Down
Loading
Loading