pub struct DeviceEnumerator { /* private fields */ }Expand description
Struct wrapping an IMMDeviceEnumerator
Implementations§
Source§impl DeviceEnumerator
impl DeviceEnumerator
Sourcepub fn new() -> Result<DeviceEnumerator, WasapiError>
pub fn new() -> Result<DeviceEnumerator, WasapiError>
Create a new DeviceEnumerator
Sourcepub fn get_device_collection(
&self,
direction: &Direction,
) -> Result<DeviceCollection, WasapiError>
pub fn get_device_collection( &self, direction: &Direction, ) -> Result<DeviceCollection, WasapiError>
Get an [IMMDeviceCollection] of all active playback or capture devices
Sourcepub fn get_default_device(
&self,
direction: &Direction,
) -> Result<Device, WasapiError>
pub fn get_default_device( &self, direction: &Direction, ) -> Result<Device, WasapiError>
Get the default playback or capture device for the console role
Sourcepub fn get_default_device_for_role(
&self,
direction: &Direction,
role: &Role,
) -> Result<Device, WasapiError>
pub fn get_default_device_for_role( &self, direction: &Direction, role: &Role, ) -> Result<Device, WasapiError>
Get the default playback or capture device for a specific role
Sourcepub fn get_device(&self, device_id: &str) -> Result<Device, WasapiError>
pub fn get_device(&self, device_id: &str) -> Result<Device, WasapiError>
Get the device of a given Id. The Id can be obtained by calling Device::get_id()
Sourcepub fn register_notification_callback(
&self,
callbacks: DeviceEventCallbacks,
) -> Result<DeviceEventRegistration, WasapiError>
pub fn register_notification_callback( &self, callbacks: DeviceEventCallbacks, ) -> Result<DeviceEventRegistration, WasapiError>
Register to receive notifications when audio endpoint devices are added or removed, when the state or properties of a device change, or when a different device becomes the default. Returns a DeviceEventRegistration struct. The notifications are unregistered when this struct is dropped. Make sure to store the DeviceEventRegistration in a variable that remains in scope for as long as the event notifications are needed.
The function takes ownership of the provided DeviceEventCallbacks.
The callbacks are called from a thread owned by the Windows audio system. They should return quickly, and must not call back into the DeviceEnumerator that they were registered on.