Monado OpenXR Runtime
Loading...
Searching...
No Matches
b_timing_source.c File Reference

Base timing source implementation. More...

#include "util/u_misc.h"
#include "os/os_threading.h"
#include "b_timing_source.h"
Include dependency graph for b_timing_source.c:

Data Structures

struct  b_timing_source
 

Macros

#define B_TIMING_SOURCE_MAX_SINKS   4
 

Functions

static struct b_timing_sourcefrom_source (struct t_timing_event_source *ttes)
 t_timing_event_source implementation
 
static int b_timing_source_add_sink (struct t_timing_event_source *ttes, struct t_timing_event_sink *sink)
 
static void b_timing_source_remove_sink (struct t_timing_event_source *ttes, struct t_timing_event_sink *sink)
 
static struct b_timing_sourcefrom_sink (struct t_timing_event_sink *sink)
 t_timing_event_sink implementation
 
static void b_timing_source_push_timing_event (struct t_timing_event_sink *sink, const struct t_timing_event *event)
 Fan out event to every registered downstream sink.
 
static struct b_timing_sourcefrom_node (struct xrt_frame_node *node)
 xrt_frame_node implementation
 
static void b_timing_source_break_apart (struct xrt_frame_node *node)
 
static void b_timing_source_destroy (struct xrt_frame_node *node)
 
xrt_result_t b_timing_source_create (struct xrt_frame_context *xfctx, struct t_timing_event_sink **out_sink, struct t_timing_event_source **out_source)
 

Detailed Description

Base timing source implementation.

Author
Beyley Cardellio ep1cm.nosp@m.1n10.nosp@m.n123@.nosp@m.gmai.nosp@m.l.com

Function Documentation

◆ b_timing_source_push_timing_event()

static void b_timing_source_push_timing_event ( struct t_timing_event_sink sink,
const struct t_timing_event event 
)
static

Fan out event to every registered downstream sink.

The mutex must be held for the entire fan-out, including while calling each downstream push_timing_event. Timing sinks unregister themselves on destruction via remove_sink; without the lock held across the callbacks, a sink can be destroyed and freed on another thread while we still hold (or call through) its pointer. Clever alternatives like copying the sink list and unlocking before dispatch do not help: the copied pointers can still become use-after-free once the owning object is destroyed.

Because the mutex is non-recursive, downstream callbacks must not call add_sink / remove_sink on this same b_timing_source (that would deadlock). Sink registration is expected at setup / teardown time, not from inside event delivery.

References ARRAY_SIZE, from_sink(), and t_timing_event_sink::t_timing_event_sink_push_timing_event().

◆ from_node()

static struct b_timing_source * from_node ( struct xrt_frame_node node)
static

xrt_frame_node implementation

References container_of.

◆ from_sink()

static struct b_timing_source * from_sink ( struct t_timing_event_sink sink)
static

t_timing_event_sink implementation

References container_of.

Referenced by b_timing_source_push_timing_event().

◆ from_source()

static struct b_timing_source * from_source ( struct t_timing_event_source ttes)
static

t_timing_event_source implementation

References container_of.