PipeWire 1.5.0
Loading...
Searching...
No Matches
spa_loop_methods Struct Reference

Register sources and work items to an event loop. More...

#include <spa/support/loop.h>

Data Fields

uint32_t version
 
int(* add_source )(void *object, struct spa_source *source)
 Add a source to the loop.
 
int(* update_source )(void *object, struct spa_source *source)
 Update the source io mask.
 
int(* remove_source )(void *object, struct spa_source *source)
 Remove a source from the loop.
 
int(* invoke )(void *object, spa_invoke_func_t func, uint32_t seq, const void *data, size_t size, bool block, void *user_data)
 Invoke a function in the context of this loop.
 
int(* locked )(void *object, spa_invoke_func_t func, uint32_t seq, const void *data, size_t size, void *user_data)
 Call a function with the loop lock acquired May be called from any thread and multiple threads at the same time.
 

Detailed Description

Register sources and work items to an event loop.

Field Documentation

◆ version

uint32_t spa_loop_methods::version

◆ add_source

int(* spa_loop_methods::add_source) (void *object, struct spa_source *source)

Add a source to the loop.

Must be called from the loop's own thread.

Parameters
[in]objectThe callbacks data.
[in]sourceThe source.
Returns
0 on success, negative errno-style value on failure.

◆ update_source

int(* spa_loop_methods::update_source) (void *object, struct spa_source *source)

Update the source io mask.

Must be called from the loop's own thread.

Parameters
[in]objectThe callbacks data.
[in]sourceThe source.
Returns
0 on success, negative errno-style value on failure.

◆ remove_source

int(* spa_loop_methods::remove_source) (void *object, struct spa_source *source)

Remove a source from the loop.

Must be called from the loop's own thread.

Parameters
[in]objectThe callbacks data.
[in]sourceThe source.
Returns
0 on success, negative errno-style value on failure.

◆ invoke

int(* spa_loop_methods::invoke) (void *object, spa_invoke_func_t func, uint32_t seq, const void *data, size_t size, bool block, void *user_data)

Invoke a function in the context of this loop.

May be called from any thread and multiple threads at the same time.

If called from the loop's thread, all callbacks previously queued with invoke() will be run synchronously, which might cause unexpected reentrancy problems.

Parameters
[in]objectThe callbacks data.
funcThe function to be invoked.
seqAn opaque sequence number. This will be made available to func.
[in]dataData that will be copied into the internal ring buffer and made available to func. Because this data is copied, it is okay to pass a pointer to a local variable, but do not pass a pointer to an object that has identity.
sizeThe size of data to copy.
blockIf \true, do not return until func has been called. Otherwise, returns immediately. Passing \true can cause a deadlock when the calling thread is holding the loop context lock. A blocking invoke should never be done from a realtime thread. Also beware of blocking invokes between 2 threads as you can easily end up in a deadly embrace.
user_dataAn opaque pointer passed to func.
Returns
-EPIPE if the internal ring buffer filled up, if block is \false, 0 if seq was SPA_ID_INVALID or seq with the ASYNC flag set or the return value of func otherwise.

◆ locked

int(* spa_loop_methods::locked) (void *object, spa_invoke_func_t func, uint32_t seq, const void *data, size_t size, void *user_data)

Call a function with the loop lock acquired May be called from any thread and multiple threads at the same time.

Parameters
[in]objectThe callbacks data.
funcThe function to be called.
seqAn opaque sequence number. This will be made available to func.
[in]dataData that will be passed to func.
sizeThe size of data.
user_dataAn opaque pointer passed to func.
Returns
the return value of func.

The documentation for this struct was generated from the following file: