Struct devices::virtio::snd::vios_backend::shm_vios::VioSClient
source · pub struct VioSClient {Show 15 fields
config: VioSConfig,
jacks: Vec<virtio_snd_jack_info>,
streams: Vec<virtio_snd_pcm_info>,
chmaps: Vec<virtio_snd_chmap_info>,
control_socket: Mutex<UnixSeqpacket>,
event_socket: UnixSeqpacket,
tx: IoBufferQueue,
rx: IoBufferQueue,
events: Arc<Mutex<VecDeque<virtio_snd_event>>>,
event_notifier: Event,
tx_subscribers: Arc<Mutex<HashMap<usize, Sender<BufferReleaseMsg>>>>,
rx_subscribers: Arc<Mutex<HashMap<usize, Sender<BufferReleaseMsg>>>>,
recv_thread_state: Arc<Mutex<ThreadFlags>>,
recv_thread: Mutex<Option<WorkerThread<Result<(), Error>>>>,
params: HashMap<u32, virtio_snd_pcm_set_params>,
}
Expand description
The client for the VioS backend
Uses a protocol equivalent to virtio-snd over a shared memory file and a unix socket for notifications. It’s thread safe, it can be encapsulated in an Arc smart pointer and shared between threads.
Fields§
§config: VioSConfig
§jacks: Vec<virtio_snd_jack_info>
§streams: Vec<virtio_snd_pcm_info>
§chmaps: Vec<virtio_snd_chmap_info>
§control_socket: Mutex<UnixSeqpacket>
§event_socket: UnixSeqpacket
§tx: IoBufferQueue
§rx: IoBufferQueue
§events: Arc<Mutex<VecDeque<virtio_snd_event>>>
§event_notifier: Event
§tx_subscribers: Arc<Mutex<HashMap<usize, Sender<BufferReleaseMsg>>>>
§rx_subscribers: Arc<Mutex<HashMap<usize, Sender<BufferReleaseMsg>>>>
§recv_thread_state: Arc<Mutex<ThreadFlags>>
§recv_thread: Mutex<Option<WorkerThread<Result<(), Error>>>>
§params: HashMap<u32, virtio_snd_pcm_set_params>
Implementations§
source§impl VioSClient
impl VioSClient
sourcepub fn try_new<P: AsRef<Path>>(server: P) -> Result<VioSClient, Error>
pub fn try_new<P: AsRef<Path>>(server: P) -> Result<VioSClient, Error>
Create a new client given the path to the audio server’s socket.
sourcepub fn num_streams(&self) -> u32
pub fn num_streams(&self) -> u32
Get the number of pcm streams
sourcepub fn num_chmaps(&self) -> u32
pub fn num_chmaps(&self) -> u32
Get the number of channel maps
sourcepub fn jack_info(&self, idx: u32) -> Option<virtio_snd_jack_info>
pub fn jack_info(&self, idx: u32) -> Option<virtio_snd_jack_info>
Get the configuration information on a jack
sourcepub fn stream_info(&self, idx: u32) -> Option<virtio_snd_pcm_info>
pub fn stream_info(&self, idx: u32) -> Option<virtio_snd_pcm_info>
Get the configuration information on a pcm stream
sourcepub fn chmap_info(&self, idx: u32) -> Option<virtio_snd_chmap_info>
pub fn chmap_info(&self, idx: u32) -> Option<virtio_snd_chmap_info>
Get the configuration information on a channel map
sourcepub fn start_bg_thread(&self) -> Result<(), Error>
pub fn start_bg_thread(&self) -> Result<(), Error>
Starts the background thread that receives release messages from the server. If the thread was already started this function does nothing. This thread must be started prior to attempting any stream IO operation or the calling thread would block.
sourcepub fn stop_bg_thread(&self) -> Result<(), Error>
pub fn stop_bg_thread(&self) -> Result<(), Error>
Stops the background thread.
sourcepub fn get_event_notifier(&self) -> Result<Event, Error>
pub fn get_event_notifier(&self) -> Result<Event, Error>
Gets an Event object that will trigger every time an event is received from the server
sourcepub fn pop_event(&self) -> Option<virtio_snd_event>
pub fn pop_event(&self) -> Option<virtio_snd_event>
Retrieves one event. Callers should have received a notification through the event notifier before calling this function.
sourcepub fn remap_jack(
&self,
jack_id: u32,
association: u32,
sequence: u32
) -> Result<(), Error>
pub fn remap_jack( &self, jack_id: u32, association: u32, sequence: u32 ) -> Result<(), Error>
Remap a jack. This should only be called if the jack announces support for the operation through the features field in the corresponding virtio_snd_jack_info struct.
sourcepub fn set_stream_parameters(
&mut self,
stream_id: u32,
params: VioSStreamParams
) -> Result<(), Error>
pub fn set_stream_parameters( &mut self, stream_id: u32, params: VioSStreamParams ) -> Result<(), Error>
Configures a stream with the given parameters.
sourcepub fn set_stream_parameters_raw(
&mut self,
raw_params: virtio_snd_pcm_set_params
) -> Result<(), Error>
pub fn set_stream_parameters_raw( &mut self, raw_params: virtio_snd_pcm_set_params ) -> Result<(), Error>
Configures a stream with the given parameters.
sourcepub fn prepare_stream(&self, stream_id: u32) -> Result<(), Error>
pub fn prepare_stream(&self, stream_id: u32) -> Result<(), Error>
Send the PREPARE_STREAM command to the server.
sourcepub fn release_stream(&self, stream_id: u32) -> Result<(), Error>
pub fn release_stream(&self, stream_id: u32) -> Result<(), Error>
Send the RELEASE_STREAM command to the server.
sourcepub fn start_stream(&self, stream_id: u32) -> Result<(), Error>
pub fn start_stream(&self, stream_id: u32) -> Result<(), Error>
Send the START_STREAM command to the server.
sourcepub fn stop_stream(&self, stream_id: u32) -> Result<(), Error>
pub fn stop_stream(&self, stream_id: u32) -> Result<(), Error>
Send the STOP_STREAM command to the server.
sourcepub fn inject_audio_data<R, Cb: FnOnce(VolatileSlice<'_>) -> R>(
&self,
stream_id: u32,
size: usize,
callback: Cb
) -> Result<(u32, R), Error>
pub fn inject_audio_data<R, Cb: FnOnce(VolatileSlice<'_>) -> R>( &self, stream_id: u32, size: usize, callback: Cb ) -> Result<(u32, R), Error>
Send audio frames to the server. Blocks the calling thread until the server acknowledges the data.
sourcepub fn request_audio_data<R, Cb: FnOnce(&VolatileSlice<'_>) -> R>(
&self,
stream_id: u32,
size: usize,
callback: Cb
) -> Result<(u32, R), Error>
pub fn request_audio_data<R, Cb: FnOnce(&VolatileSlice<'_>) -> R>( &self, stream_id: u32, size: usize, callback: Cb ) -> Result<(u32, R), Error>
Request audio frames from the server. It blocks until the data is available.
sourcepub fn keep_rds(&self) -> Vec<RawDescriptor>
pub fn keep_rds(&self) -> Vec<RawDescriptor>
Get a list of file descriptors used by the implementation.
fn common_stream_op(&self, stream_id: u32, op: u32) -> Result<(), Error>
fn request_and_cache_info(&mut self) -> Result<(), Error>
fn request_info<T: AsBytes + FromBytes + Default + Copy + Clone>( &self, req_code: u32, count: usize ) -> Result<Vec<T>, Error>
fn request_and_cache_jacks_info(&mut self) -> Result<(), Error>
fn request_and_cache_streams_info(&mut self) -> Result<(), Error>
fn request_and_cache_chmaps_info(&mut self) -> Result<(), Error>
pub fn snapshot(&self) -> VioSClientSnapshot
pub fn restore(&mut self, data: VioSClientSnapshot) -> Result<()>
pub fn restore_stream( &mut self, stream_id: u32, state: StreamState ) -> Result<(), Error>
Auto Trait Implementations§
impl RefUnwindSafe for VioSClient
impl Send for VioSClient
impl Sync for VioSClient
impl Unpin for VioSClient
impl UnwindSafe for VioSClient
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.