Repository navigation
Description
Unit
libobs/obs.c.h: the route of obs_queue_task(), the thread choice of obs_in_task_thread() and the level checks of obs_set_video_levels(), moved to a new libobs/obs-core-setup-rules-task.c.h as hidden functions on plain values, and ported to rust/obs-core's core_setup_rules module, beside the setup rules obs.c.h already calls.
What moves, declared in obs-core-setup-rules.h without EXPORT:
obs_core_setup_rules_task_step(step, type, value): the route ofobs_queue_task(), one read at a time, the wayobs_core_setup_rules_mix_step()does it. The steps areTYPE(the type only),UI_HANDLER(obs->ui_task_handler != NULL, asked only forOBS_TASK_UI),IN_THREAD(obs_in_task_thread(type), never asked forOBS_TASK_UI) andWAIT. The routes areUI_CALL,UI_NONE,RUN,WAIT_QUEUE,PUSH_GRAPHICS,PUSH_AUDIO,PUSH_DESTROY,DROPandUNKNOWN;obs_core_setup_rules_task_thread(type): which threadobs_in_task_thread()asks about, or -1;obs_core_setup_rules_levels_core(core): whetherobs_set_video_levels()goes on;obs_core_setup_rules_level_ok(level):isfinite(level) && level > 0.f(libobs: obs_set_video_levels accepts 0, negative and NaN white levels #2209).
The four OBS_TASK_* values are copied into the header and _Static_asserted in obs.c.h, as the other constants are.
What stays C, at the same points and under the same conditions: the handler read, the three thread-locals, os_task_queue_inside(), the UI handler call, task(param), the wait event's init, wait and destroy (with the polling fallback), the recursive obs_queue_task(type, task_wait_callback, &info, false), the locks and deque_push_back()s, os_task_queue_queue_task(), every log and the assert(false) in obs_in_task_thread().
Phase and position
Phase 6 style (#444): a behaviour-neutral extraction, then the port. Crate obs-core, module core_setup_rules, after the buffering milliseconds (#3272). Tracking: #4.
Dependencies and existing tests
- No open PR touches
obs.c.h's task code,obs-core-setup-rules.*orcore_setup_rules. - Builds on the landed
core_setup_rulesmodule and itsported-core-setup-rulesgroup. test_task,test_pthread_init_failures,test_core_setup_rules_stepsand the source profiler and audio monitoring tests go throughobs_queue_task()with the four types and see the route's result, but none pins the route table. A newtest_core_setup_rules_task_steps(cmocka, the moved file on its own, ASan and UBSan) lands first: every step for the four types and for -1, 4 andINT_MAX, with each value; the thread for each type;levels_core()for both values;level_ok()for 0, -0, the smallest denormal, 1, 300, 1000,FLT_MAX, both infinities and a NaN.
Notes
Two intentional differences, both fixed in the Rust:
- An unknown task type.
obs_queue_task()with a type outside the four asksobs_in_task_thread(), which hitsassert(false)in a debug build and returns false otherwise. Then, withwait, the inner call queues nothing and the caller waits forever; withoutwait, the task is dropped without a word. After the port, theTYPEstep returnsUNKNOWNfor such a type, whateverwaitis, andobs_queue_task()logs an error naming the type and returns: no task run, no wait, noobs_in_task_thread()call. A directobs_in_task_thread()call with an unknown type still asserts and returns false, as today. obs_set_video_levels()beforeobs_startup(). It takes&obs->videoand readsvideo->graphicswith no core check, so a call with no core dereferences NULL. After the port,levels_core(false)is false, and it logs a warning and returns before it touchesobs->video. With a core but no graphics, the levels are still stored as today.
Debug builds abort today on an unknown type in obs_queue_task(); after the port they log instead (from obs_queue_task() only).
Tier 3 compares every step over type values -2 to 5 plus random ints with both values, and level_ok() over every special float and random bit patterns, exactly (f32::is_finite() && x > 0.0 against isfinite(x) && x > 0.f, -0.0 and NaN included), with a mutation check.
Threads: obs_queue_task() is called from any thread; nothing moved keeps state. Only ints, bools and a float cross.
No upstream issue.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Nov 1, 2026
Claiming: #3397.
obs_queue_task(), the thread choice ofobs_in_task_thread()and the level checks ofobs_set_video_levels()intolibobs/obs-core-setup-rules-task.c.h(hidden, declared inobs-core-setup-rules.h, its own group), behaviour-neutral; every read, call, lock, push and log stays inobs.c.hin its place. Checked with a move harness (gcc and clang, -O0/-O2, ASan/UBSan, planted mutants).test_core_setup_rules_task_stepsagainst the moved C.obs_core::core_setup_rulesTier 1 ontodo!()stubs.libobs.ported-core-setup-rulesgroup. Two intentional differences: an unknown task type is logged and refused instead of hanging a waiting caller, andobs_set_video_levels()with no core warns and returns.level_ok()over special floats and random bits, with a mutation check.port_comparisonbench for the route.One PR; a draft as soon as the RED commit exists, today.
libobs: Move the task queue's route out of obs.c
test: Characterize the task queue's route
obs-core: Test the task queue's route port
obs-core: Port the task queue's route
obs-core: Compare the task queue's route with C
docs: Record the task queue's route port
rdoupe commentedon Nov 1, 2026
Fixed by PR #3405 (merged through the merge queue, merge commit b106053): the route of
obs_queue_task(), the thread choice ofobs_in_task_thread()and the level checks ofobs_set_video_levels()were moved out ofobs.c.hand ported torust/obs-core'score_setup_rulesmodule, with the characterization test, the Tier 1 and Tier 3 tests and the docs.The two intentional differences from the plan landed as written: an unknown task type is now logged and refused instead of hanging a waiting caller, and
obs_set_video_levels()beforeobs_startup()warns and returns instead of dereferencing NULL.What's left: nothing from this unit, so there is no follow-up issue. The C side that stays (the handler read, the thread-locals, the queues, locks and logs) is deliberately left in
obs.c.h, as the issue said. The unit has no line on the tracking issue (#4), so there was no checkbox to tick.obs-core: Port the task queue's route (obs-rust#3405)
libobs: characterize and extract obs_set_video_levels (Refs obs-rust#…