Parrot.Media.AudioDevices (Parrot Platform v0.0.1-alpha.3)
Manages audio device discovery and selection for PortAudio integration.
This module provides functions to list available audio devices, get default devices, and validate device IDs for use with Membrane's PortAudio plugin.
Example
iex> Parrot.Media.AudioDevices.list_devices()
{:ok, [
%{id: 0, name: "Built-in Microphone", type: :input, channels: 2},
%{id: 1, name: "Built-in Output", type: :output, channels: 2}
]}
iex> Parrot.Media.AudioDevices.get_default_input()
{:ok, 0}
Summary
Functions
Gets the default input device ID.
Gets the default output device ID.
Gets device information by ID.
Lists all available audio devices.
Prints available audio devices to console.
Validates if a device ID exists and matches the expected type.
Types
@type device_info() :: %{ id: non_neg_integer(), name: String.t(), type: :input | :output, channels: non_neg_integer() }
Functions
@spec get_default_input() :: {:ok, non_neg_integer()} | {:error, term()}
Gets the default input device ID.
Since device enumeration is not available, this returns the typical
default input device ID. You may need to adjust this based on your
system configuration. Use print_devices/0 to see actual device IDs.
@spec get_default_output() :: {:ok, non_neg_integer()} | {:error, term()}
Gets the default output device ID.
Since device enumeration is not available, this returns the typical
default output device ID. You may need to adjust this based on your
system configuration. Use print_devices/0 to see actual device IDs.
@spec get_device_info(non_neg_integer()) :: {:ok, device_info()} | {:error, term()}
Gets device information by ID.
Since device enumeration is not available, this returns a stub response.
Use print_devices/0 to see actual device information.
@spec list_devices() :: {:ok, [device_info()]} | {:error, term()}
Lists all available audio devices.
NOTE: The current version of membrane_portaudio_plugin doesn't provide
programmatic access to device enumeration. Use print_devices/0 to
see available devices in the console.
Returns a stub response for compatibility.
@spec print_devices() :: :ok
Prints available audio devices to console.
This calls Membrane.PortAudio.print_devices() which outputs device information to stdout.
@spec validate_device(non_neg_integer(), :input | :output) :: :ok | {:error, term()}
Validates if a device ID exists and matches the expected type.
Since device enumeration is not available, this performs basic validation
based on common device ID patterns. Use print_devices/0 to verify actual
device IDs and types on your system.
Parameters
device_id- The device ID to validateexpected_type- Either:inputor:output
Returns
:okif the device ID is in a reasonable range{:error, reason}otherwise