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

source

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.

source

pub fn num_jacks(&self) -> u32

Get the number of jacks

source

pub fn num_streams(&self) -> u32

Get the number of pcm streams

source

pub fn num_chmaps(&self) -> u32

Get the number of channel maps

source

pub fn jack_info(&self, idx: u32) -> Option<virtio_snd_jack_info>

Get the configuration information on a jack

source

pub fn stream_info(&self, idx: u32) -> Option<virtio_snd_pcm_info>

Get the configuration information on a pcm stream

source

pub fn chmap_info(&self, idx: u32) -> Option<virtio_snd_chmap_info>

Get the configuration information on a channel map

source

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.

source

pub fn stop_bg_thread(&self) -> Result<(), Error>

Stops the background thread.

source

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

source

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.

source

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.

source

pub fn set_stream_parameters( &mut self, stream_id: u32, params: VioSStreamParams ) -> Result<(), Error>

Configures a stream with the given parameters.

source

pub fn set_stream_parameters_raw( &mut self, raw_params: virtio_snd_pcm_set_params ) -> Result<(), Error>

Configures a stream with the given parameters.

source

pub fn prepare_stream(&self, stream_id: u32) -> Result<(), Error>

Send the PREPARE_STREAM command to the server.

source

pub fn release_stream(&self, stream_id: u32) -> Result<(), Error>

Send the RELEASE_STREAM command to the server.

source

pub fn start_stream(&self, stream_id: u32) -> Result<(), Error>

Send the START_STREAM command to the server.

source

pub fn stop_stream(&self, stream_id: u32) -> Result<(), Error>

Send the STOP_STREAM command to the server.

source

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.

source

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.

source

pub fn keep_rds(&self) -> Vec<RawDescriptor>

Get a list of file descriptors used by the implementation.

source

fn common_stream_op(&self, stream_id: u32, op: u32) -> Result<(), Error>

source

fn request_and_cache_info(&mut self) -> Result<(), Error>

source

fn request_info<T: AsBytes + FromBytes + Default + Copy + Clone>( &self, req_code: u32, count: usize ) -> Result<Vec<T>, Error>

source

fn request_and_cache_jacks_info(&mut self) -> Result<(), Error>

source

fn request_and_cache_streams_info(&mut self) -> Result<(), Error>

source

fn request_and_cache_chmaps_info(&mut self) -> Result<(), Error>

source

pub fn snapshot(&self) -> VioSClientSnapshot

source

pub fn restore(&mut self, data: VioSClientSnapshot) -> Result<()>

source

pub fn restore_stream( &mut self, stream_id: u32, state: StreamState ) -> Result<(), Error>

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

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

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>) -> Rc<dyn Any>

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.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

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

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where 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 T
where 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 T
where 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 T
where V: MultiLane<T>,

§

fn vzip(self) -> V