Skip to main content

QueueControl

Struct QueueControl 

Source
pub struct QueueControl<S>
where S: HasPool<u8> + HasPool<f32> + Send + Sync + 'static,
{ /* private fields */ }
Expand description

Cloneable queue command capability without beat-grid identity or topology.

Implementations§

Source§

impl<S> QueueControl<S>
where S: HasPool<u8> + HasPool<f32> + Send + Sync + 'static,

Source

pub fn action_at_item_end(&self) -> ActionAtItemEnd

Source

pub fn current(&self) -> Option<TrackEntry>

The currently playing track entry, if any.

Sourced from the navigation cursor (not the player) so the queue reports None after advance_to_next runs off the end of the queue (RepeatMode::Off exhaustion). The player’s own current_index stays parked at the last-played slot — read it via Self::current_index when the call site needs the last-played index even after queue-end.

Source

pub fn current_index(&self) -> Option<usize>

The currently playing track’s queue index (player-reported).

Source

pub fn set_action_at_item_end(&self, action: ActionAtItemEnd)

Source

pub fn set_playback_order(&self, order: PlaybackOrder)

Source

pub fn set_repeat(&self, mode: RepeatMode)

Set repeat mode.

Source

pub fn subscribe<E: EventSet>(&self) -> EventReceiver<E>

Subscribe to the unified event stream: QueueEvent + underlying player / audio / hls / file events.

Source

pub fn track(&self, id: TrackId) -> Option<TrackEntry>

Lookup a track entry by id.

Source

pub fn track_source(&self, id: TrackId) -> Option<TrackSource<S>>

The original TrackSource for id, if still queued. Lets callers rebuild a resource by track identity rather than by queue position.

Source

pub fn attach_observer<O: AudioObserver>(&self, id: TrackId, observer: O)

Attach a bounded decoded-audio observer to id’s decoder.

Attachment is nonblocking and works before, during, or after resource loading. Only one observer is active for a track at a time.

Source

pub fn current_abr_handle(&self) -> Option<AbrHandle>

ABR handle of the currently playing adaptive item, if any.

Returned handle drives runtime variant/bandwidth control — FFI and GUI use it for set_abr_mode / set_preferred_peak_bitrate.

Source

pub fn sample_rate(&self) -> u32

Rate the player’s master bus runs at, and therefore the frame axis used by decoded-audio observers attached to this queue.

Source

pub fn current_variant(&self) -> Option<VariantInfo>

Live variant metadata of the currently playing adaptive item. Pulled from the player’s stashed ABR handle on every call so a renderer can poll for the up-to-date label after every frame without depending on event delivery.

Source

pub fn is_empty(&self) -> bool

Whether the queue is empty.

Source

pub fn playback_order(&self) -> PlaybackOrder

Current traversal order.

Source

pub fn len(&self) -> usize

Number of tracks currently in the queue.

Source

pub fn repeat_mode(&self) -> RepeatMode

Current repeat mode.

Source

pub fn tracks(&self) -> Vec<TrackEntry>

Snapshot of all track entries, in queue order.

Source§

impl<S> QueueControl<S>
where S: HasPool<u8> + HasPool<f32> + Send + Sync + 'static,

Source

pub fn append<T: Into<TrackSource<S>>>( &self, source: T, ) -> Result<TrackId, QueueError>

Append a track. Loading starts immediately in the background. The id is allocated from the global counter via TrackId::allocate; use Self::append_with_id when the caller owns the id (FFI item pre-allocation).

§Errors

Returns QueueError::Play after the resident player is closed.

Source

pub fn append_with_id<T: Into<TrackSource<S>>>( &self, id: TrackId, source: T, ) -> Result<TrackId, QueueError>

Append a track with a caller-supplied id. The id MUST come from TrackId::allocate so it stays inside the process-wide monotonic address space. Used by the FFI layer where the item reserves its id at construction and surfaces it as audioId before insert.

§Errors

Returns QueueError::Play after the resident player is closed.

Source

pub fn clear(&self)

Remove all tracks from the queue. Dropping the records aborts their in-flight loads.

Source

pub fn insert<T: Into<TrackSource<S>>>( &self, source: T, after: Option<TrackId>, ) -> Result<TrackId, QueueError>

Insert a track after the given id, or at the head when after is None. Loading starts immediately.

§Errors

Returns QueueError::UnknownTrackId if after does not match any track.

Source

pub fn insert_with_id<T: Into<TrackSource<S>>>( &self, id: TrackId, source: T, after: Option<TrackId>, ) -> Result<TrackId, QueueError>

Insert a track with a caller-supplied id. See Self::append_with_id for why the id MUST come from TrackId::allocate.

§Errors

Returns QueueError::UnknownTrackId if after does not match any track.

Source

pub fn remove(&self, id: TrackId) -> Result<(), QueueError>

Remove a track from the queue by id.

If the removed track is currently playing:

  • with tracks remaining → switches to the next (or previous if we were at the tail) with an immediate cut.
  • with no tracks remaining → pauses the player.
§Errors

Returns QueueError::UnknownTrackId if id is not in the queue.

Source

pub fn set_tracks<I, T>(&self, sources: I)
where I: IntoIterator<Item = T>, T: Into<TrackSource<S>>,

Replace the entire queue with the given sources.

Source§

impl<S> QueueControl<S>
where S: HasPool<u8> + HasPool<f32> + Send + Sync + 'static,

Source

pub fn bus(&self) -> &EventBus

Underlying event bus used by queue and player events.

Source

pub fn crossfade_settings(&self) -> CrossfadeSettings

Source

pub fn process_notifications(&self)

Drain pending player-side notifications. Called by FFI tick loops after Self::tick.

Source

pub fn reset_eq(&self) -> Result<(), PlayError>

Reset all EQ bands to 0 dB.

§Errors

Forwards PlayError from the underlying player.

Source

pub fn set_crossfade_settings( &self, settings: CrossfadeSettings, ) -> Result<(), PlayError>

Update the profile captured by future transitions.

§Errors

Returns an error when any profile value is invalid.

Source

pub fn set_default_rate(&self, rate: f32)

Set the default playback rate.

Source

pub fn set_eq_gain(&self, band: usize, gain_db: f32) -> Result<(), PlayError>

Set gain for an EQ band.

§Errors

Forwards PlayError from the underlying player.

Source

pub fn set_eq_layout(&self, layout: Vec<EqBandConfig>) -> Result<(), PlayError>

Replace the live player’s EQ band layout.

§Errors

Forwards PlayError from the underlying player.

Source

pub fn set_muted(&self, muted: bool)

Set the mute flag.

Source

pub fn set_rate(&self, rate: f32)

Set the live playback rate (mirrors into the tempo-mode sibling so a running key-locked stretch tracks the move).

Source

pub fn set_volume(&self, volume: f32)

Set the volume (0.0..=1.0).

Source

pub fn is_playing(&self) -> bool

Whether playback is active.

Source

pub fn rate(&self) -> f32

Live engine playback rate (player-reported, 0.0 when paused).

Source

pub fn default_rate(&self) -> f32

Default playback rate.

Source

pub fn volume(&self) -> f32

Current volume (0.0..=1.0).

Source

pub fn is_muted(&self) -> bool

Whether output is muted.

Source

pub fn status(&self) -> PlayerStatus

Live engine playback status.

Source

pub fn engine_load(&self) -> EngineLoadSnapshot

Live audio-engine cost (realtime factor / load / ms).

Source

pub fn eq_band_count(&self) -> usize

Number of EQ bands.

Source

pub fn eq_gain(&self, band: usize) -> Option<f32>

Current gain for an EQ band.

Source

pub fn duration_seconds(&self) -> Option<f64>

Current track duration in seconds.

Source§

impl<S> QueueControl<S>
where S: HasPool<u8> + HasPool<f32> + Send + Sync + 'static,

Source

pub fn notify_audio_route_changed(&self, reason: &str) -> Result<(), QueueError>

Platform audio-route changed while playback may be active.

Recreates the native output stream below the queue without changing queue state, current item, or track loading.

§Errors

Returns QueueError when the underlying player cannot restart the active audio route.

Source

pub fn notify_interruption(&self, kind: InterruptionKind)

The platform interrupted, or released, the audio output.

Recording the fact is all this does: an interruption leaves the native output unscheduled, and restoring it is the route-invalidation path.

Source

pub fn pause(&self)

Pause playback and freeze the queue-visible head position.

Source

pub fn play(&self)

Starts playback, marking a consumed slot or retaining the selection until loading finishes. Reconciliation is serialized with load completion.

Source

pub fn playback_view(&self) -> PlaybackView

Single coherent read of the player’s live playback state.

Pollers (the FFI time thread, snapshot) get position, duration, decoded frontier, and the playing flag from one call instead of several separate accessors. The player-sourced fields come from one PlaybackSnapshot via its From conversion; position is then replaced with this queue’s cached, 0.0-smoothed value.

Source

pub fn set_session_ducking( &self, mode: SessionDuckingMode, ) -> Result<(), QueueError>

Lower or restore the whole session output under a competing sound, such as a call or a navigation prompt.

§Errors

Returns QueueError when the session rejects the change.

Source

pub fn position_seconds(&self) -> Option<f64>

Latest monotonic playback position for the current track in seconds. Updated on every Self::tick; skips transient 0.0 samples the engine produces on pause/resume so downstream UIs see stable values.

Source

pub fn seek(&self, seconds: f64) -> Result<SeekOutcome, QueueError>

Seek within the currently-playing track.

Seek-hang detection is not handled here: the audio pipeline’s own #[hang_watchdog] instrumentation (e.g. Audio::read, Stream::read, decode_next_chunk) already panics with a stacktrace and context dump when no progress is observed. Adding a second Queue-level watchdog would just duplicate those panics.

Returns the typed SeekOutcome — either Landed with the requested target (the actual landed position is reconciled by the worker after applying the seek; this call returns the optimistic outcome) or PastEof if the target is beyond the known track duration.

§Errors

Returns QueueError::Play if the player reports a seek failure.

Source

pub fn tick(&self) -> Result<(), QueueError>

Periodic tick: drives PlayerImpl::tick and drains queued engine events to act on ItemDidPlayToEnd (filtered) and forward CurrentItemChanged as QueueEvent::CurrentTrackChanged.

§Errors

Forwards PlayError from PlayerImpl::tick.

Source§

impl<S> QueueControl<S>
where S: HasPool<u8> + HasPool<f32> + Send + Sync + 'static,

Source

pub fn select( &self, id: TrackId, transition: Transition, ) -> Result<(), QueueError>

Select a track by id, applying the given Transition. If the track is still loading or pending, both the id and the transition are stashed and applied when loading finishes.

§Errors

Returns QueueError::UnknownTrackId if id is not in the queue, QueueError::NotReady if the track is in a terminal failed state, or QueueError::Play if the underlying select_item call fails.

Source§

impl<S> QueueControl<S>
where S: HasPool<u8> + HasPool<f32> + Send + Sync + 'static,

Source

pub fn next( &self, transition: Transition, ) -> Result<Option<TrackId>, QueueError>

Advance to the next track per navigation rules. Returns the newly selected id, or None when the queue has ended (and RepeatMode::Off is active).

§Errors

Returns a queue or player error when the successor cannot be selected.

Source

pub fn previous( &self, transition: Transition, ) -> Result<Option<TrackId>, QueueError>

Go back to the previous track. Returns the newly selected id, or None at index 0.

§Errors

Returns a queue or player error when the predecessor cannot be selected.

Source§

impl<S> QueueControl<S>
where S: HasPool<u8> + HasPool<f32> + Send + Sync + 'static,

Source

pub fn close(&self) -> Result<(), PlayError>

Close the resident player, then irreversibly cancel queue-owned work.

§Errors

Returns the player detach failure without cancelling the queue token; the player control gate is reopened so the owner can retry.

Source

pub fn is_closed(&self) -> bool

Trait Implementations§

Source§

impl<S> Clone for QueueControl<S>
where S: HasPool<u8> + HasPool<f32> + Send + Sync + 'static,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<S> Deref for QueueControl<S>
where S: HasPool<u8> + HasPool<f32> + Send + Sync + 'static,

Source§

type Target = QueueRuntime<S>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<S> !RefUnwindSafe for QueueControl<S>

§

impl<S> !UnwindSafe for QueueControl<S>

§

impl<S> Freeze for QueueControl<S>
where PlayerControl<S>: Freeze, Arc<QueueRuntime<S>>: Freeze,

§

impl<S> Send for QueueControl<S>
where PlayerControl<S>: Send, Arc<QueueRuntime<S>>: Send,

§

impl<S> Sync for QueueControl<S>
where PlayerControl<S>: Sync, Arc<QueueRuntime<S>>: Sync,

§

impl<S> Unpin for QueueControl<S>
where PlayerControl<S>: Unpin, Arc<QueueRuntime<S>>: Unpin,

§

impl<S> UnsafeUnpin for QueueControl<S>
where PlayerControl<S>: UnsafeUnpin, Arc<QueueRuntime<S>>: UnsafeUnpin,

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

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HangDump for T

Source§

fn dump_json(&self) -> String

Source§

fn label(&self) -> Option<&str>

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

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

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

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

Source§

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

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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

impl<T> WithSubscriber for T

Source§

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

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

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