Struct devices::virtio::snd::common_backend::stream_info::StreamInfo
source · pub struct StreamInfo {Show 17 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)>>,
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>>
§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
:SetParams
for 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
:Executor
to run the pcm worker.tx_send
: Sender for sendingPcmResponse
for tx queue. (playback stream)rx_send
: Sender for sendingPcmResponse
for 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.
async fn release_worker(&mut self)
pub fn snapshot(&self) -> StreamInfoSnapshot
pub fn restore(&mut self, state: &StreamInfoSnapshot)
Trait Implementations§
source§impl Debug for StreamInfo
impl Debug for StreamInfo
source§impl Drop for StreamInfo
impl Drop for StreamInfo
source§impl From<StreamInfoBuilder> for StreamInfo
impl From<StreamInfoBuilder> for StreamInfo
source§fn from(builder: StreamInfoBuilder) -> Self
fn from(builder: StreamInfoBuilder) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for StreamInfo
impl !Send for StreamInfo
impl !Sync for StreamInfo
impl Unpin for StreamInfo
impl !UnwindSafe for StreamInfo
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.