[][src]Trait audir::Instance

pub trait Instance {
    type Device: Device;
    type Session;
    unsafe fn properties() -> InstanceProperties;
unsafe fn create(name: &str) -> Self;
unsafe fn enumerate_physical_devices(&self) -> Vec<PhysicalDevice>;
unsafe fn default_physical_input_device(&self) -> Option<PhysicalDevice>;
unsafe fn default_physical_output_device(&self) -> Option<PhysicalDevice>;
unsafe fn physical_device_properties(
        &self,
        physical_device: PhysicalDevice
    ) -> Result<PhysicalDeviceProperties>;
unsafe fn physical_device_supports_format(
        &self,
        physical_device: PhysicalDevice,
        sharing: SharingMode,
        frame_desc: FrameDesc
    ) -> bool;
unsafe fn physical_device_default_concurrent_format(
        &self,
        physical_device: PhysicalDevice
    ) -> Result<FrameDesc>;
unsafe fn create_device(
        &self,
        desc: DeviceDesc,
        channels: Channels,
        callback: StreamCallback
    ) -> Result<Self::Device>;
unsafe fn create_session(&self, sample_rate: usize) -> Result<Self::Session>;
unsafe fn set_event_callback<F>(
        &mut self,
        callback: Option<F>
    ) -> Result<()>
    where
        F: FnMut(Event) + Send + 'static
; }

Associated Types

type Device: Device

type Session

Audio Session

See more details on create_session.

Loading content...

Required methods

unsafe fn properties() -> InstanceProperties

Get instance properties.

unsafe fn create(name: &str) -> Self

Create an instance object.

Validation

  • The instance must outlive all its child objects.

unsafe fn enumerate_physical_devices(&self) -> Vec<PhysicalDevice>

Retrieve a list of physical devices of the current instance.

The list may vary over time when devices get added or removed. Users may track changes manually by registering an event handler.

unsafe fn default_physical_input_device(&self) -> Option<PhysicalDevice>

Get the default physical input device.

unsafe fn default_physical_output_device(&self) -> Option<PhysicalDevice>

Get the default physical output device.

unsafe fn physical_device_properties(
    &self,
    physical_device: PhysicalDevice
) -> Result<PhysicalDeviceProperties>

Get physical device properties.

Validation

  • physical_device must be a valid handle.

unsafe fn physical_device_supports_format(
    &self,
    physical_device: PhysicalDevice,
    sharing: SharingMode,
    frame_desc: FrameDesc
) -> bool

Check format support for a physical device.

Validation

  • physical_device must be a valid handle.

unsafe fn physical_device_default_concurrent_format(
    &self,
    physical_device: PhysicalDevice
) -> Result<FrameDesc>

Get default concurrent mode format.

Returns the default format used for physical devices when used with concurrent sharing mode.

Validation

  • physical_device must be a valid handle.

unsafe fn create_device(
    &self,
    desc: DeviceDesc,
    channels: Channels,
    callback: StreamCallback
) -> Result<Self::Device>

Create a new logical device.

A logical device with an associated stream will be created from a physical device.

Validation

  • physical_device must be a valid handle.
  • If the device properties does not include StreamFlags::INPUT, the input channel mask must be empty.
  • If the device properties does not include StreamFlags::OUTPUT, the output channel mask must be empty.
  • If output channel mask is not empty, the format consisting of sample desc and output channel mask must be supported by this physical device.
  • If input channel mask is not empty, the format consisting of sample desc and input channel mask must be supported by this physical device.

unsafe fn create_session(&self, sample_rate: usize) -> Result<Self::Session>

Create an audio session.

Audio sessions are needed for ensuring realtime properties for audio streaming. Callback based instances have an internal executor with the a properly configured audio session. After creating a session the current executor thread will have realtime properties for the lifetime of the session.

All polling instances will expose a concurrent default format with a sample_rate, which is not equal to DEFAULT_SAMPLE_RATE.

Validation

  • sample_rate must not be DEFAULT_SAMPLE_RATE.

unsafe fn set_event_callback<F>(&mut self, callback: Option<F>) -> Result<()> where
    F: FnMut(Event) + Send + 'static, 

Loading content...

Implementors

impl Instance for Instance[src]

type Device = Device

type Session = ()

Loading content...