Crate wasapi[][src]

Expand description

Wasapi bindings for Rust

The aim of this crate is to provide easy and safe access to the Wasapi API for audio playback and capture.

The presented API is all safe Rust, but structs and functions closely follow the original Windows API.

For details on how to use Wasapi, please see the Windows documentation.

Bindings are generated automatically using the windows crate.

Supported functionality

These things have been implemented so far:

  • Audio playback and capture
  • Shared and exclusive modes
  • Loopback capture
  • Notifications for volume change, device disconnect etc

Examples

  • The playsine example plays a sine wave in shared mode on the default output device.

  • The playsine_events example is similar to playsine but also listens to notifications.

  • The loopback example shows how to simultaneously capture and render sound, with separate threads for capture and render.

Modules

Windows

Structs

AudioCaptureClient

Struct wrapping an IAudioCaptureClient.

AudioClient

Struct wrapping an IAudioClient.

AudioRenderClient

Struct wrapping an IAudioRenderClient.

AudioSessionControl

Struct wrapping an IAudioSessionControl.

Device

Struct wrapping an IMMDevice.

DeviceCollection

Struct wrapping an IMMDeviceCollection.

EventCallbacks

A structure holding the callbacks for notifications

Guid

A globally unique identifier (GUID) used to identify COM and WinRT interfaces.

Handle

Struct wrapping a HANDLE (event handle).

WasapiError

Error returned by the Wasapi crate.

WaveFormat

Struct wrapping a WAVEFORMATEXTENSIBLE format descriptor.

Enums

Direction

Audio direction, playback or capture.

DisconnectReason

Reason for session disconnect

SampleType

Sample type, float or integer

SessionState

States of an AudioSession

ShareMode

Sharemode for device

Functions

get_default_device

Get the default playback or capture device