pub struct StreamInfo {Show 18 fields
pub(crate) stream_source: Option<Box<dyn StreamSource>>,
stream_source_generator: Arc<Box<dyn StreamSourceGenerator>>,
pub(crate) muted: Rc<AtomicBool>,
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)>>,
card_index: usize,
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>>§muted: Rc<AtomicBool>§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)>>§card_index: usize§ex: Option<Executor>Implementations§
Source§impl StreamInfo
impl StreamInfo
Sourceasync fn set_up_async_playback_stream(
&mut self,
frame_size: usize,
ex: &Executor,
) -> Result<Box<dyn AsyncPlaybackBufferStream>, Error>
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.
pub(crate) async fn set_up_async_capture_stream( &mut self, frame_size: usize, ex: &Executor, ) -> Result<UnixBufferReader, Error>
pub(crate) async fn create_directionstream_output( &mut self, frame_size: usize, ex: &Executor, ) -> Result<DirectionalStream, Error>
Source§impl StreamInfo
impl StreamInfo
Sourcepub fn builder(
stream_source_generator: Arc<Box<dyn StreamSourceGenerator>>,
card_index: usize,
) -> StreamInfoBuilder
pub fn builder( stream_source_generator: Arc<Box<dyn StreamSourceGenerator>>, card_index: usize, ) -> StreamInfoBuilder
Creates a minimal StreamInfoBuilder. See StreamInfoBuilder::new() for
the description of each parameter.
Sourcepub async fn set_params(&mut self, params: SetParams) -> Result<(), Error>
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:SetParamsfor the pcm stream runtime configuration.
Sourcepub async fn prepare(
&mut self,
ex: &Executor,
tx_send: &UnboundedSender<PcmResponse>,
rx_send: &UnboundedSender<PcmResponse>,
) -> Result<(), Error>
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:Executorto run the pcm worker.tx_send: Sender for sendingPcmResponsefor tx queue. (playback stream)rx_send: Sender for sendingPcmResponsefor rx queue. (capture stream)
Sourcepub async fn start(&mut self) -> Result<(), Error>
pub async fn start(&mut self) -> Result<(), Error>
Starts the stream, putting it into VIRTIO_SND_R_PCM_START state.
Sourcepub async fn stop(&mut self) -> Result<(), Error>
pub async fn stop(&mut self) -> Result<(), Error>
Stops the stream, putting it into VIRTIO_SND_R_PCM_STOP state.
Sourcepub async fn release(&mut self) -> Result<(), Error>
pub async fn release(&mut self) -> Result<(), Error>
Releases the stream, putting it into VIRTIO_SND_R_PCM_RELEASE state.