Skip to main content

DeliveryRing

Struct DeliveryRing 

Source
pub(crate) struct DeliveryRing {
    pub(crate) q: Mutex<Option<VecDeque<(Vec<u8>, u64)>>>,
    pub(crate) cv: Condvar,
    pub(crate) dropped: AtomicU64,
    pub(crate) capacity: usize,
}
Expand description

Bounded, drop-oldest hand-off from the capture thread to the Python delivery thread, so a slow or GIL-blocked callback can never stall the PulseAudio pump.

The capture thread pushes encoded (frame, pts) pairs; the delivery thread blocks in pop. Stale audio is worthless, so overflow past capacity (a few frames of slack) discards the OLDEST frame and bumps dropped. close empties the queue to None and wakes the consumer so it exits.

Fields§

§q: Mutex<Option<VecDeque<(Vec<u8>, u64)>>>§cv: Condvar§dropped: AtomicU64§capacity: usize

Implementations§

Source§

impl DeliveryRing

Source

pub(crate) fn new(capacity: usize) -> Self

Create an open ring pre-sized to capacity frames.

Source

pub(crate) fn push(&self, data: Vec<u8>, pts: u64)

Enqueue one encoded frame, dropping the oldest (and bumping dropped) if the ring is at capacity, then wake the consumer. A no-op once closed.

Source

pub(crate) fn pop(&self) -> Option<(Vec<u8>, u64)>

Block until a frame is available and return it, or return None once the ring is closed and drained — the delivery thread’s loop condition.

Source

pub(crate) fn close(&self)

Close the ring: drop any queued frames and wake every waiter so pop returns None. Called during capture teardown to join the delivery thread.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.
§

impl<T> Ungil for T
where T: Send,