pub struct VirtIOSound<H: Hal, T: Transport> { /* private fields */ }
Expand description
Audio driver based on virtio v1.2.
Supports synchronous blocking and asynchronous non-blocking audio playback.
Currently, only audio playback functionality has been implemented.
Implementations§
Source§impl<H: Hal, T: Transport> VirtIOSound<H, T>
impl<H: Hal, T: Transport> VirtIOSound<H, T>
Sourcepub fn ack_interrupt(&mut self) -> bool
pub fn ack_interrupt(&mut self) -> bool
Acknowledge interrupt.
Sourcepub fn enable_interrupts(&mut self, enable: bool)
pub fn enable_interrupts(&mut self, enable: bool)
Enables interrupts from the device.
Sourcepub fn jack_remap(
&mut self,
jack_id: u32,
association: u32,
sequence: u32,
) -> Result
pub fn jack_remap( &mut self, jack_id: u32, association: u32, sequence: u32, ) -> Result
If the VIRTIO_SND_JACK_F_REMAP feature bit is set in the jack information, then the driver can send a control request to change the association and/or sequence number for the specified jack ID.
§Arguments
jack_id
- A u32 int which is in the range of [0, jacks)
Sourcepub fn pcm_set_params(
&mut self,
stream_id: u32,
buffer_bytes: u32,
period_bytes: u32,
features: PcmFeatures,
channels: u8,
format: PcmFormat,
rate: PcmRate,
) -> Result
pub fn pcm_set_params( &mut self, stream_id: u32, buffer_bytes: u32, period_bytes: u32, features: PcmFeatures, channels: u8, format: PcmFormat, rate: PcmRate, ) -> Result
Set selected stream parameters for the specified stream ID.
Sourcepub fn pcm_prepare(&mut self, stream_id: u32) -> Result
pub fn pcm_prepare(&mut self, stream_id: u32) -> Result
Prepare a stream with specified stream ID.
Sourcepub fn pcm_release(&mut self, stream_id: u32) -> Result
pub fn pcm_release(&mut self, stream_id: u32) -> Result
Release a stream with specified stream ID.
Sourcepub fn pcm_xfer(&mut self, stream_id: u32, frames: &[u8]) -> Result
pub fn pcm_xfer(&mut self, stream_id: u32, frames: &[u8]) -> Result
Transfer PCM frame to device, based on the stream type(OUTPUT/INPUT).
Currently supports only output stream.
This is a blocking method that will not return until the audio playback is complete.
Sourcepub fn pcm_xfer_nb(&mut self, stream_id: u32, frames: &[u8]) -> Result<u16>
pub fn pcm_xfer_nb(&mut self, stream_id: u32, frames: &[u8]) -> Result<u16>
Transfer PCM frame to device, based on the stream type(OUTPUT/INPUT).
Currently supports only output stream.
This is a non-blocking method that returns a token.
The length of the frames
must be equal to the buffer size set for the stream corresponding to the stream_id
.
Sourcepub fn pcm_xfer_ok(&mut self, token: u16) -> Result
pub fn pcm_xfer_ok(&mut self, token: u16) -> Result
The PCM frame transmission corresponding to the given token has been completed.
Sourcepub fn output_streams(&mut self) -> Result<Vec<u32>>
pub fn output_streams(&mut self) -> Result<Vec<u32>>
Get all output streams.
Sourcepub fn input_streams(&mut self) -> Result<Vec<u32>>
pub fn input_streams(&mut self) -> Result<Vec<u32>>
Get all input streams.
Sourcepub fn rates_supported(&mut self, stream_id: u32) -> Result<PcmRates>
pub fn rates_supported(&mut self, stream_id: u32) -> Result<PcmRates>
Get the rates that a stream supports.
Sourcepub fn formats_supported(&mut self, stream_id: u32) -> Result<PcmFormats>
pub fn formats_supported(&mut self, stream_id: u32) -> Result<PcmFormats>
Get the formats that a stream supports.
Sourcepub fn channel_range_supported(
&mut self,
stream_id: u32,
) -> Result<RangeInclusive<u8>>
pub fn channel_range_supported( &mut self, stream_id: u32, ) -> Result<RangeInclusive<u8>>
Get channel range that a stream supports.
Sourcepub fn features_supported(&mut self, stream_id: u32) -> Result<PcmFeatures>
pub fn features_supported(&mut self, stream_id: u32) -> Result<PcmFeatures>
Get features that a stream supports.
Sourcepub fn latest_notification(&mut self) -> Result<Option<Notification>>
pub fn latest_notification(&mut self) -> Result<Option<Notification>>
Get the latest notification.