Skip to main content

Recording

Struct Recording 

Source
pub(crate) struct Recording {
    samples: Mutex<Vec<f32>>,
    peak_bits: AtomicU32,
    stop: AtomicBool,
    truncated: AtomicBool,
}
Expand description

What the recording thread and the handle share.

Fields§

§samples: Mutex<Vec<f32>>§peak_bits: AtomicU32

Loudest absolute sample since the last read, as f32 bits. Atomic so a caller drawing a level meter never blocks the pusher.

§stop: AtomicBool§truncated: AtomicBool

Set when the take stopped itself at the cap rather than because it was asked to.

Implementations§

Source§

impl Recording

Source

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

capacity is the cap in samples. Reserved up front so the buffer never reallocates as a take grows.

Source

pub(crate) fn push(&self, block: &[f32], limit: usize)

Fold one block of audio in, keeping the running peak since the last read.

Mono at the model rate: a device’s channels are downmixed and resampled before they reach this buffer. MUST NOT ALLOCATE: the samples extend the preallocated buffer rather than an intermediate.

Source

fn observe_peak(&self, block: &[f32])

Fold the loudest absolute sample of block into the meter’s accumulator. Peak over the RAW block, not any downmix: a meter should show a channel clipping even when the mean of the channels does not.

Source

pub(crate) fn peak_dbfs(&self) -> f32

Loudest input since the last read, in dBFS. Take-and-reset: the read clears the accumulator, so a poller gets one window per ask.

Source

pub(crate) fn stop(&self)

Source

pub(crate) fn cap_reached(&self)

The take’s cap was reached by WALL CLOCK rather than by samples.

The sample cap fires only while audio is arriving, and a take fed by frames has no callback loop to notice it either: a stream that stops mid-take would hold the seat until teardown, so its host counts the clock and flags it here.

Source

pub(crate) fn stopped(&self) -> bool

Whether the recording has been asked to stop - the cap reached itself, or the host ended the take. What a feeder polls before appending: a stream take’s frame sink, which has no thread to poll it for it.

Source

pub(crate) fn sample_len(&self) -> usize

Samples currently held. The append-only buffer keeps written ranges stable, so a segmenter can cut by offset while the callback keeps appending past them.

Source

pub(crate) fn copy_region(&self, from: usize, to: usize) -> Vec<f32>

Copy [from..to) out without draining. The recording keeps the whole take so finish can hand diagnostics the full capture, and so an offset that raced a stop is a short copy, not a panic. The lock is held for the memcpy only - long enough to be felt in a callback budget if it happened every block, which it does not: this runs once per window boundary, every 30 to 60 seconds.

Source

pub(crate) fn take(&self) -> Vec<f32>

Source

pub(crate) fn was_truncated(&self) -> bool

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
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more