Class AudioDevice

    Definition

    Namespace:
    Tizen.Multimedia
    Assembly:
    Tizen.Multimedia.dll

    Represents an audio device in the system, providing functionality to query and manipulate its properties. The AudioDevice class allows developers to interact with audio devices by retrieving detailed information such as the device's ID, name, type, I/O direction, and its current running state. Furthermore, it provides methods for getting and setting sample formats and rates, managing resampling options, and restricting stream types to media-only, facilitating optimized audio handling for diverse applications.

    public class AudioDevice
    Inheritance
    object
    AudioDevice

    Properties

    View Source

    Id

    Gets the unique identifier of the audio device. This ID serves as a reference to identify the device within the system and is crucial for performing operations on specific devices.

    Declaration
    public int Id { get; }
    Property Value
    Type Description
    int

    The id of the device.

    View Source

    IoDirection

    Gets the input/output (I/O) direction of the audio device. This property indicates whether the device is designed for input (recording) or output (playback), allowing developers to manage device usage appropriately in their applications.

    Declaration
    public AudioDeviceIoDirection IoDirection { get; }
    Property Value
    Type Description
    AudioDeviceIoDirection

    The IO direction of the device.

    View Source

    IsRunning

    Gets a value indicating whether the audio device is currently running. This property checks the operational state of the device and returns true if the device is active and processing audio, or false if it is idle or inactive.

    Declaration
    public bool IsRunning { get; }
    Property Value
    Type Description
    bool

    true if the audio stream of device is running actually; otherwise, false.

    View Source

    Name

    Gets the name of the audio device. This property provides a human-readable identifier for the device, which can be used in user interfaces or logs to display information about the current audio output/input device.

    Declaration
    public string Name { get; }
    Property Value
    Type Description
    string

    The name of the device.

    View Source

    Type

    Gets the type of the audio device. This property returns an enumerated value of type AudioDeviceType that indicates the specific category of the device, such as speakers, microphones, or headphones, which helps in distinguishing between different device functionalities.

    Declaration
    public AudioDeviceType Type { get; }
    Property Value
    Type Description
    AudioDeviceType

    The AudioDeviceType of the device.

    Methods

    View Source

    Equals(object)

    Compares the current instance of AudioDevice with another object for equality. This method checks if the specified object is an instance of AudioDevice and compares their unique identifiers to determine if they represent the same audio device.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    A object to compare.

    Returns
    Type Description
    bool

    true if the two devices are equal; otherwise, false.

    Overrides
    object.Equals(object)
    View Source

    GetAvoidResampling()

    Gets the current state of the 'avoid resampling' property for the audio device. This method returns whether the device is currently configured to avoid resampling audio data, allowing developers to assess the current settings related to audio processing quality.

    Declaration
    public bool GetAvoidResampling()
    Returns
    Type Description
    bool

    The 'avoid resampling' property of the device.

    Remarks

    This device should be UsbAudio type and Output direction. This property is not enabled as default. With this enabled, this device will use the first stream's original sample format and rate without resampling if supported.

    Exceptions
    Type Condition
    System.InvalidOperationException

    This device is not valid or is disconnected.

    View Source

    GetHashCode()

    Retrieves the hash code for the current instance of AudioDevice. This method generates a hash code based on the unique identifier of the audio device, which can be useful for storing instances in hash-based collections such as dictionaries or hash sets.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    The hash code for this instance of AudioDevice.

    Overrides
    object.GetHashCode()
    View Source

    GetMediaStreamOnly()

    Retrieves the current restriction status of the audio device regarding media streams. This method checks whether the device is currently configured to accept only media streams, returning a boolean value that indicates the state of the restriction.

    Declaration
    public bool GetMediaStreamOnly()
    Returns
    Type Description
    bool

    The 'media stream only' property of the device.

    Remarks

    This device should be UsbAudio type and Output direction. This property is not enabled as default. With this enabled, no other stream types except Media are not allowed to this device.

    Exceptions
    Type Condition
    System.InvalidOperationException

    This device is not valid or is disconnected.

    View Source

    GetSampleFormat()

    Gets the current sample format used by the audio device. This method retrieves the current AudioSampleFormat the device is operating with, allowing applications to verify or adjust to the active format being utilized for audio streams.

    Declaration
    public AudioSampleFormat GetSampleFormat()
    Returns
    Type Description
    AudioSampleFormat

    The AudioSampleFormat of the device.

    Remarks

    This device should be UsbAudio type and Output direction.

    Exceptions
    Type Condition
    System.InvalidOperationException

    This device is not valid or is disconnected.

    View Source

    GetSampleRate()

    Gets the current sample rate of the audio device. This method retrieves the sample rate currently in use for audio processing, allowing applications to ensure they are operating with the correct audio quality settings.

    Declaration
    public uint GetSampleRate()
    Returns
    Type Description
    uint

    The sample rate of the device.

    Remarks

    This device should be UsbAudio type and Output direction.

    Exceptions
    Type Condition
    System.InvalidOperationException

    This device is not valid or is disconnected.

    View Source

    GetSupportedSampleFormats()

    Retrieves a collection of audio sample formats supported by the device. This method returns an enumerable list of AudioSampleFormat values indicating the different audio formats the device can handle, enabling applications to select a compatible format for audio processing.

    Declaration
    public IEnumerable<AudioSampleFormat> GetSupportedSampleFormats()
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<T><AudioSampleFormat>

    An IEnumerable<AudioSampleFormat> that contains supported sample formats.

    Remarks

    This device should be UsbAudio type and Output direction.

    Exceptions
    Type Condition
    System.InvalidOperationException

    This device is not valid or is disconnected.

    View Source

    GetSupportedSampleRates()

    Retrieves the sample rates that the audio device supports. This method returns an enumerable list of supported sample rates, allowing developers to select an appropriate rate for audio processing based on the capabilities of the device.

    Declaration
    public IEnumerable<uint> GetSupportedSampleRates()
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<T><uint>

    An IEnumerable<uint> that contains supported sample rates.

    Remarks

    This device should be UsbAudio type and Output direction.

    Exceptions
    Type Condition
    System.InvalidOperationException

    This device is not valid or is disconnected.

    View Source

    SetAvoidResampling(bool)

    Sets the 'avoid resampling' property for the audio device. This property controls whether the device should avoid resampling audio data during playback. Enabling this feature can help preserve audio quality by preventing alterations to audio that may happen during playback.

    Declaration
    public void SetAvoidResampling(bool enable)
    Parameters
    Type Name Description
    bool enable

    The 'avoid resampling' value to set to the device.

    Remarks

    This device should be UsbAudio type and Output direction. This property is not enabled as default. With this enabled, this device will use the first stream's original sample format and rate without resampling if supported.

    Exceptions
    Type Condition
    System.InvalidOperationException

    This device is not valid or is disconnected.

    View Source

    SetMediaStreamOnly(bool)

    Sets a restriction on the audio device to allow only media streams. This method configures the device to accept only audio streams of type Media. When enabled, the device will reject any other stream types, ensuring that it is exclusively used for media playback.

    Declaration
    public void SetMediaStreamOnly(bool enable)
    Parameters
    Type Name Description
    bool enable

    The 'media stream only' value to set to the device.

    Remarks

    This device should be UsbAudio type and Output direction. This property is not enabled as default. With this enabled, no other stream types except Media are not allowed to this device.

    Exceptions
    Type Condition
    System.InvalidOperationException

    This device is not valid or is disconnected.

    View Source

    SetSampleFormat(AudioSampleFormat)

    Sets the sample format for the audio device. This method allows developers to specify a desired AudioSampleFormat for audio playback or recording.

    Declaration
    public void SetSampleFormat(AudioSampleFormat format)
    Parameters
    Type Name Description
    AudioSampleFormat format

    The AudioSampleFormat to set to the device.

    Remarks

    This device should be UsbAudio type and Output direction.

    Exceptions
    Type Condition
    System.InvalidOperationException

    This device is not valid or is disconnected.

    View Source

    SetSampleRate(uint)

    Sets the sample rate for the audio device. This method allows you to specify a desired sample rate (in Hz) for audio playback or recording. Choosing an appropriate sample rate is important for maintaining audio quality and ensuring compatibility with audio data formats.

    Declaration
    public void SetSampleRate(uint rate)
    Parameters
    Type Name Description
    uint rate

    The sample rate to set to the device.

    Remarks

    This device should be UsbAudio type and Output direction.

    Exceptions
    Type Condition
    System.InvalidOperationException

    This device is not valid or is disconnected.

    View Source

    ToString()

    Returns a string representation of the current instance. This method provides a formatted string that includes key properties of the audio device, such as its unique identifier, name, type, I/O direction, and running state. This representation can be useful for logging, debugging, or displaying device information in user interfaces.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string that represents the current object.

    Overrides
    object.ToString()
    • View Source
    Back to top Copyright © 2016-2024 Samsung
    Generated by DocFX