Skip to main content

Capture

Struct Capture 

Source
pub struct Capture {
    engine: Arc<Engine>,
    recording: Arc<Recording>,
    max_capture: Duration,
    segmenter: Option<JoinHandle<()>>,
    finish_tx: Option<Sender<FinishTake>>,
    answer_rx: Option<Receiver<Result<Outcome, Error>>>,
    progress_rx: Option<Receiver<WindowProgress>>,
    cancel: CancelToken,
}
Expand description

One take in flight: the recording it grows, its segmenter, and the channels finish hands on.

Release is tied to the value rather than to a method, so a caller that panics mid-take cannot leave the take’s threads running.

Fields§

§engine: Arc<Engine>§recording: Arc<Recording>§max_capture: Duration§segmenter: Option<JoinHandle<()>>

The take’s segmenter. Taken by finish, which hands it to the ticket; joined by Drop on the abandon path.

§finish_tx: Option<Sender<FinishTake>>

Dropping it aborts the segmenter: the take is over and its queued work should not run on.

§answer_rx: Option<Receiver<Result<Outcome, Error>>>

The take’s aggregate answer, once every segment and the tail have run and the join has been normalized. Taken by finish.

§progress_rx: Option<Receiver<WindowProgress>>

Per-segment progress while the recording is still open. Taken by the host at recording start; the stream outlives the handoff to the ticket because the segmenter owns its sender throughout.

§cancel: CancelToken

This take’s cancel token, shared by every job the segmenter queues. The ticket carries a clone, so abandoning the take after finish aborts its outstanding work.

Implementations§

Source§

impl Capture

Source

pub fn level(&self) -> f32

Loudest input since the last read, in dBFS. The read is take-and-reset - it answers “peak over the window you just polled” and clears, which is what a level meter drawing one bar per window wants; a read that held the all-time peak would freeze such a meter on the first syllable.

Still a lock-free atomic, so it is safe to call from a render loop. The mutating read means two pollers steal windows from each other: one reader is the assumed caller.

Source

pub fn meter(&self) -> CaptureMeter

The shareable polling view of this capture: level and cap truncation, the two reads a recording loop wants. Capture itself is Send but not Sync - it holds channel receivers - so a host that polls a live capture from an async task borrows this handle across awaits instead of the capture.

Source

pub fn take_progress(&mut self) -> Option<Receiver<WindowProgress>>

Take this take’s progress stream, if it has not been taken. Steps arrive as segments settle while the recording is still open, and again once finish has submitted the tail and the total is known.

Source

pub fn finish(self) -> Result<Ticket, Error>

Stop the take and queue what was captured.

Source

pub fn finish_with(self, options: NormalizeOptions) -> Result<Ticket, Error>

Stop recording and queue what was captured, overriding the configured normalizer options for this recording only.

With a take already pipelining, this submits the tail and hands back a ticket over the AGGREGATE: the segmenter waits for every segment already queued, joins the raw texts, and normalizes the join once on the worker. The returned ticket resolves when the whole transcript does.

Source

pub fn cancel(self)

Stop recording and throw the audio away.

Source

pub fn max_capture(&self) -> Duration

The cap this take is bounded by. A host feeding the take itself has to enforce it: a take fed by frames has no loop at all.

Source

pub fn was_truncated(&self) -> bool

Whether the take reached Config::max_capture and stopped itself. A host polling the level reads this so it can submit the take instead of holding a seat whose take is no longer running.

Source

fn stop_recording(&mut self)

Stop the take: the recording’s stop flag is what tells a pusher the take is over. The captured samples stay where they are: the segmenter holds the recording and reads the tail out of it at finish.

Trait Implementations§

Source§

impl Drop for Capture

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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