Struct PlaybackParking

Source
pub(crate) struct PlaybackParking {
    pub(crate) state: Mutex<PlaybackParkingState>,
    pub(crate) timeout: Duration,
}
Expand description

Keeps the AAudio stream of a dropped playback stream open for a short while, so the next playback stream with the same parameters reuses it instead of opening a new one.

Guest XRUN recovery (STOP, RELEASE, PREPARE, START) would otherwise close and reopen the host stream. Each open blocks the executor that all streams of the card share, and each open or close makes several host services log. The parked stream is left started, so XRUN recovery doesn’t toggle the host’s playback state. If it stays unfed for long, AudioFlinger may pause the host track, and the next write restarts it.

A guest that stops and restarts playback with the same parameters (e.g. to seek) also reuses the stream, so audio still buffered in it, at most about two periods, plays before the new audio. Flushing would need a pause, which would toggle the host’s playback state again.

Capture streams are never parked: they must close so the host releases the microphone, and each capture start asks for permission again.

Fields§

§state: Mutex<PlaybackParkingState>§timeout: Duration

How long a stream stays parked. Only tests change it.

Implementations§

Source§

impl PlaybackParking

Source

pub(crate) fn lock(&self) -> MutexGuard<'_, PlaybackParkingState>

Source

pub(crate) fn take( &self, params: PlaybackParams, ) -> Option<ParkedPlaybackStream>

Takes the parked stream if it was opened with params and AAudio still reports it as started. Any other parked stream is closed.

Source

pub(crate) fn park(self: &Arc<Self>, stream: ParkedPlaybackStream)

Parks stream and makes sure a thread closes it if it isn’t taken within timeout.

Trait Implementations§

Source§

impl Default for PlaybackParking

Source§

fn default() -> Self

Returns the “default value” for a type. 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
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.