pub struct ThreadLoop { /* private fields */ }
Expand description

A wrapper around the pipewire threaded loop interface. ThreadLoops are a higher level of abstraction around the loop interface. A ThreadLoop can be used to spawn a new thread that runs the wrapped loop.

Implementations§

source§

impl ThreadLoop

source

pub unsafe fn new( name: Option<&str>, properties: Option<&DictRef> ) -> Result<Self, Error>

Initialize Pipewire and create a new ThreadLoop with the given name and optional properties.

§Safety

TODO

source

pub unsafe fn new_cstr( name: Option<&CStr>, properties: Option<&DictRef> ) -> Result<Self, Error>

Initialize Pipewire and create a new ThreadLoop with the given name as Cstr

§Safety

TODO

source

pub fn downgrade(&self) -> WeakThreadLoop

source

pub fn as_raw_ptr(&self) -> *mut pw_thread_loop

source

pub fn loop_(&self) -> &LoopRef

source

pub fn lock(&self) -> ThreadLoopLockGuard<'_>

Lock the Loop

This ensures that the loop thread will not access objects associated with the loop while the lock is held, lock() can be used multiple times from the same thread.

The lock needs to be held whenever you call any PipeWire function that uses an object associated with this loop. Make sure to not hold on to the lock more than necessary though, as the threaded loop stops while the lock is held.

source

pub fn start(&self)

Start the ThreadLoop

source

pub fn stop(&self)

Stop the ThreadLoop

Stopping the ThreadLoop must be called without the lock

source

pub fn signal(&self, signal: bool)

Signal all threads waiting with wait()

source

pub fn wait(&self)

Release the lock and wait

Release the lock and wait until some thread calls signal()

source

pub fn timed_wait(&self, wait_max_sec: Duration)

Release the lock and wait a maximum of wait_max_sec seconds until some thread calls signal() or time out

source

pub fn get_time(&self, timeout: i64) -> TimeSpec

Get a timespec suitable for timed_wait_full()

source

pub fn timed_wait_full(&self, abstime: TimeSpec)

Release the lock and wait up to abs seconds until some thread calls signal(). Use get_time() to get a suitable timespec

source

pub fn accept(&self)

Signal all threads executing signal() with wait_for_accept

source

pub fn in_thread(&self)

Check if inside the thread

Trait Implementations§

source§

impl AsRef<LoopRef> for ThreadLoop

source§

fn as_ref(&self) -> &LoopRef

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for ThreadLoop

source§

fn clone(&self) -> ThreadLoop

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ThreadLoop

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl IsLoopRc for ThreadLoop

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.