pub struct DeviceService { /* private fields */ }Expand description
Service for managing audio device enumeration and lookup.
DeviceService wraps a CPAL [Host] and provides convenient methods to:
- List available input and output devices
- Look up devices by their ID
- Convert device information into
AudioDeviceDtofor frontend consumption
Implementations§
Source§impl DeviceService
impl DeviceService
Sourcepub fn get_input_devices(&self) -> Vec<AudioDeviceDto>
pub fn get_input_devices(&self) -> Vec<AudioDeviceDto>
Retrieves a list of all available input devices.
Queries the CPAL host for input devices, converts them to AudioDeviceDto,
and returns them. If device enumeration fails, an empty list is returned
and an error is added to the logs.
§Returns
A Vec of AudioDeviceDto representing available input devices.
Sourcepub fn get_output_devices(&self) -> Vec<AudioDeviceDto>
pub fn get_output_devices(&self) -> Vec<AudioDeviceDto>
Retrieves a list of all available output devices.
Queries the CPAL host for output devices, converts them to AudioDeviceDto,
and returns them. If device enumeration fails, an empty list is returned
and an error is printed to stderr.
§Returns
A Vec of AudioDeviceDto representing available output devices.
Sourcepub fn find_input_device_by_id(&self, id: &str) -> Option<Device>
pub fn find_input_device_by_id(&self, id: &str) -> Option<Device>
Finds an input device by its string ID.
Searches through the host’s input devices for one whose debug-formatted ID matches the given string.
§Arguments
id- The device ID string to search for (debug-formatted CPAL device ID).
§Returns
Some(device) if a matching input device is found, None otherwise.
Sourcepub fn find_output_device_by_id(&self, id: &str) -> Option<Device>
pub fn find_output_device_by_id(&self, id: &str) -> Option<Device>
Finds an output device by its string ID.
Searches through the host’s output devices for one whose debug-formatted ID matches the given string.
§Arguments
id- The device ID string to search for (debug-formatted CPAL device ID).
§Returns
Some(device) if a matching output device is found, None otherwise.