PipeWire  0.3.15
pw_thread_loop Class Reference

PipeWire threaded loop object. More...

Public Member Functions

SPA_EXPORT struct pw_thread_looppw_thread_loop_new (const char *name, const struct spa_dict *props)
 Create a new pw_thread_loop. More...
 
SPA_EXPORT void pw_thread_loop_destroy (struct pw_thread_loop *loop)
 Destroy a threaded loop. More...
 
SPA_EXPORT int pw_thread_loop_start (struct pw_thread_loop *loop)
 Start the thread to handle loop. More...
 
SPA_EXPORT void pw_thread_loop_stop (struct pw_thread_loop *loop)
 Quit the loop and stop its thread. More...
 
SPA_EXPORT void pw_thread_loop_lock (struct pw_thread_loop *loop)
 Lock the mutex associated with loop. More...
 
SPA_EXPORT void pw_thread_loop_unlock (struct pw_thread_loop *loop)
 Unlock the mutex associated with loop. More...
 
SPA_EXPORT void pw_thread_loop_signal (struct pw_thread_loop *loop, bool wait_for_accept)
 Signal the thread. More...
 
SPA_EXPORT void pw_thread_loop_wait (struct pw_thread_loop *loop)
 Wait for the loop thread to call pw_thread_loop_signal() More...
 
SPA_EXPORT int pw_thread_loop_timed_wait (struct pw_thread_loop *loop, int wait_max_sec)
 Wait for the loop thread to call pw_thread_loop_signal() or time out. More...
 
SPA_EXPORT int pw_thread_loop_get_time (struct pw_thread_loop *loop, struct timespec *abstime, int64_t timeout)
 Get the current time of the loop + timeout. More...
 
SPA_EXPORT int pw_thread_loop_timed_wait_full (struct pw_thread_loop *loop, struct timespec *abstime)
 Wait for the loop thread to call pw_thread_loop_signal() or time out. More...
 
SPA_EXPORT void pw_thread_loop_accept (struct pw_thread_loop *loop)
 Signal the loop thread waiting for accept with pw_thread_loop_signal() More...
 
SPA_EXPORT bool pw_thread_loop_in_thread (struct pw_thread_loop *loop)
 Check if we are inside the thread of the loop. More...
 

Detailed Description

PipeWire threaded loop object.

The threaded loop object runs a pw_loop in a separate thread and ensures proper locking is done.

All of the loop callbacks will be executed with the loop lock held.

See also Threaded Loop

Member Function Documentation

◆ pw_thread_loop_accept()

SPA_EXPORT void pw_thread_loop_accept ( struct pw_thread_loop loop)

Signal the loop thread waiting for accept with pw_thread_loop_signal()

Parameters
loopa pw_thread_loop to signal

◆ pw_thread_loop_destroy()

SPA_EXPORT void pw_thread_loop_destroy ( struct pw_thread_loop loop)

◆ pw_thread_loop_get_time()

SPA_EXPORT int pw_thread_loop_get_time ( struct pw_thread_loop loop,
struct timespec *  abstime,
int64_t  timeout 
)

Get the current time of the loop + timeout.

This can be used in pw_thread_loop_timed_wait_full().

Parameters
loopa pw_thread_loop
abstimethe result struct timesspec
timeoutthe time in nanoseconds to add to tp
Returns
0 on success or a negative errno value on error.

Referenced by pw_thread_loop_timed_wait().

◆ pw_thread_loop_in_thread()

SPA_EXPORT bool pw_thread_loop_in_thread ( struct pw_thread_loop loop)

Check if we are inside the thread of the loop.

Parameters
loopa pw_thread_loop to signal
Returns
true when called inside the thread of loop.

◆ pw_thread_loop_lock()

SPA_EXPORT void pw_thread_loop_lock ( struct pw_thread_loop loop)

Lock the mutex associated with loop.

Parameters
loopa pw_thread_loop

References NAME, and pw_log::pw_log_trace.

◆ pw_thread_loop_new()

SPA_EXPORT struct pw_thread_loop * pw_thread_loop_new ( const char *  name,
const struct spa_dict *  props 
)

Create a new pw_thread_loop.

Parameters
loopthe loop to wrap
namethe name of the thread or NULL
Returns
a newly allocated pw_thread_loop

Make a new pw_thread_loop that will run loop in a thread with name.

After this function you should probably call pw_thread_loop_start() to actually start the thread

◆ pw_thread_loop_signal()

SPA_EXPORT void pw_thread_loop_signal ( struct pw_thread_loop loop,
bool  wait_for_accept 
)

Signal the thread.

Parameters
loopa pw_thread_loop to signal
wait_for_acceptif we need to wait for accept

Signal the thread of loop. If wait_for_accept is true, this function waits until pw_thread_loop_accept() is called.

References NAME, and pw_log::pw_log_trace.

◆ pw_thread_loop_start()

SPA_EXPORT int pw_thread_loop_start ( struct pw_thread_loop loop)

Start the thread to handle loop.

Parameters
loopa pw_thread_loop
Returns
0 on success

◆ pw_thread_loop_stop()

SPA_EXPORT void pw_thread_loop_stop ( struct pw_thread_loop loop)

Quit the loop and stop its thread.

Parameters
loopa pw_thread_loop

References NAME, pw_log::pw_log_debug, and pw_loop_signal_event.

Referenced by pw_thread_loop_destroy().

◆ pw_thread_loop_timed_wait()

SPA_EXPORT int pw_thread_loop_timed_wait ( struct pw_thread_loop loop,
int  wait_max_sec 
)

Wait for the loop thread to call pw_thread_loop_signal() or time out.

Parameters
loopa pw_thread_loop to signal
wait_max_secthe maximum number of seconds to wait for a pw_thread_loop_signal()
Returns
0 on success or ETIMEDOUT on timeout or a negative errno value.

References pw_thread_loop_get_time(), and pw_thread_loop_timed_wait_full().

◆ pw_thread_loop_timed_wait_full()

SPA_EXPORT int pw_thread_loop_timed_wait_full ( struct pw_thread_loop loop,
struct timespec *  abstime 
)

Wait for the loop thread to call pw_thread_loop_signal() or time out.

Parameters
loopa pw_thread_loop to signal
abstimethe absolute time to wait for a pw_thread_loop_signal()
Returns
0 on success or -ETIMEDOUT on timeout or a negative error value

Referenced by pw_thread_loop_timed_wait().

◆ pw_thread_loop_unlock()

SPA_EXPORT void pw_thread_loop_unlock ( struct pw_thread_loop loop)

Unlock the mutex associated with loop.

Parameters
loopa pw_thread_loop

References NAME, and pw_log::pw_log_trace.

◆ pw_thread_loop_wait()

SPA_EXPORT void pw_thread_loop_wait ( struct pw_thread_loop loop)

Wait for the loop thread to call pw_thread_loop_signal()

Parameters
loopa pw_thread_loop to signal

References NAME, and pw_log::pw_log_trace.


The documentation for this class was generated from the following files: