pub struct StreamInfo {
Show 16 fields pub(crate) stream_source: Option<Box<dyn StreamSource>>, stream_source_generator: Arc<Box<dyn StreamSourceGenerator>>, pub(crate) channels: u8, pub(crate) format: SampleFormat, pub(crate) frame_rate: u32, buffer_bytes: usize, pub(crate) period_bytes: usize, direction: u8, pub state: u32, pub(crate) effects: Vec<StreamEffect>, pub just_reset: bool, pub status_mutex: Rc<RwLock<WorkerStatus>>, pub sender: Option<UnboundedSender<DescriptorChain>>, worker_future: Option<Box<dyn Future<Output = Result<(), Error>> + Unpin>>, release_signal: Option<Rc<(RwLock<bool>, Condvar)>>, ex: Option<Executor>,
}
Expand description

StreamInfo represents a virtio snd stream.

To create a StreamInfo, see StreamInfo::builder() and StreamInfoBuilder::build().

Fields§

§stream_source: Option<Box<dyn StreamSource>>§stream_source_generator: Arc<Box<dyn StreamSourceGenerator>>§channels: u8§format: SampleFormat§frame_rate: u32§buffer_bytes: usize§period_bytes: usize§direction: u8§state: u32§effects: Vec<StreamEffect>§just_reset: bool§status_mutex: Rc<RwLock<WorkerStatus>>§sender: Option<UnboundedSender<DescriptorChain>>§worker_future: Option<Box<dyn Future<Output = Result<(), Error>> + Unpin>>§release_signal: Option<Rc<(RwLock<bool>, Condvar)>>§ex: Option<Executor>

Implementations§

source§

impl StreamInfo

source

async fn set_up_async_playback_stream( &mut self, frame_size: usize, ex: &Executor ) -> Result<Box<dyn AsyncPlaybackBufferStream>, Error>

(*) buffer_size in audio_streams API indicates the buffer size in bytes that the stream consumes (or transmits) each time (next_playback/capture_buffer). period_bytes in virtio-snd device (or ALSA) indicates the device transmits (or consumes) for each PCM message. Therefore, buffer_size in audio_streams == period_bytes in virtio-snd.

source

pub(crate) async fn set_up_async_capture_stream( &mut self, frame_size: usize, ex: &Executor ) -> Result<UnixBufferReader, Error>

source

pub(crate) async fn create_directionstream_output( &mut self, frame_size: usize, ex: &Executor ) -> Result<DirectionalStream, Error>

source§

impl StreamInfo

source

pub fn builder( stream_source_generator: Arc<Box<dyn StreamSourceGenerator>> ) -> StreamInfoBuilder

Creates a minimal StreamInfoBuilder. See StreamInfoBuilder::new() for the description of each parameter.

source

pub async fn set_params(&mut self, params: SetParams) -> Result<(), Error>

Sets parameters of the stream, putting it into VIRTIO_SND_R_PCM_SET_PARAMS state.

  • params: SetParams for the pcm stream runtime configuration.
source

pub async fn prepare( &mut self, ex: &Executor, tx_send: &UnboundedSender<PcmResponse>, rx_send: &UnboundedSender<PcmResponse> ) -> Result<(), Error>

Prepares the stream, putting it into VIRTIO_SND_R_PCM_PREPARE state.

  • ex: Executor to run the pcm worker.
  • tx_send: Sender for sending PcmResponse for tx queue. (playback stream)
  • rx_send: Sender for sending PcmResponse for rx queue. (capture stream)
source

pub async fn start(&mut self) -> Result<(), Error>

Starts the stream, putting it into VIRTIO_SND_R_PCM_START state.

source

pub async fn stop(&mut self) -> Result<(), Error>

Stops the stream, putting it into VIRTIO_SND_R_PCM_STOP state.

source

pub async fn release(&mut self) -> Result<(), Error>

Releases the stream, putting it into VIRTIO_SND_R_PCM_RELEASE state.

source

async fn release_worker(&mut self)

source

pub fn snapshot(&self) -> StreamInfoSnapshot

source

pub fn restore(&mut self, state: &StreamInfoSnapshot)

Trait Implementations§

source§

impl Debug for StreamInfo

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for StreamInfo

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl From<StreamInfoBuilder> for StreamInfo

source§

fn from(builder: StreamInfoBuilder) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V