AudioCapabilities


@UnstableApi
public final class AudioCapabilities


Represents the set of audio formats that a device is capable of playing.

Summary

Constants

static final AudioCapabilities

The minimum audio capabilities supported by all devices.

Public fields

final int

Public constructors

AudioCapabilities(
    @Nullable int[] supportedEncodings,
    int maxChannelCount
)

This method is deprecated.

Use getCapabilities instead.

Public methods

boolean
static AudioCapabilities

This method is deprecated.

Use getCapabilities instead.

static AudioCapabilities
getCapabilities(
    Context context,
    AudioAttributes audioAttributes,
    @Nullable AudioDeviceInfo routedDevice
)

Returns the current audio capabilities.

@Nullable Pair<IntegerInteger>

This method is deprecated.

Use getEncodingAndChannelConfigForPassthrough instead.

@Nullable Pair<IntegerInteger>
getEncodingAndChannelConfigForPassthrough(
    Format format,
    AudioAttributes audioAttributes
)

Returns the encoding and channel config to use when configuring an AudioTrack in passthrough mode for the specified Format and AudioAttributes.

int

Returns the maximum number of channels the device can play at the same time.

int
boolean

This method is deprecated.

Use isPassthroughPlaybackSupported instead.

boolean
isPassthroughPlaybackSupported(
    Format format,
    AudioAttributes audioAttributes
)

Returns whether the device can do passthrough playback for format.

boolean

Returns whether this device supports playback of the specified audio encoding.

String

Constants

DEFAULT_AUDIO_CAPABILITIES

public static final AudioCapabilities DEFAULT_AUDIO_CAPABILITIES

The minimum audio capabilities supported by all devices.

Public fields

maxChannelCount

public final int maxChannelCount

Public constructors

AudioCapabilities

public AudioCapabilities(
    @Nullable int[] supportedEncodings,
    int maxChannelCount
)

Public methods

equals

public boolean equals(@Nullable Object other)

getCapabilities

public static AudioCapabilities getCapabilities(Context context)

getCapabilities

public static AudioCapabilities getCapabilities(
    Context context,
    AudioAttributes audioAttributes,
    @Nullable AudioDeviceInfo routedDevice
)

Returns the current audio capabilities.

Parameters
Context context

A context for obtaining the current audio capabilities.

AudioAttributes audioAttributes

The AudioAttributes to obtain capabilities for.

@Nullable AudioDeviceInfo routedDevice

The AudioDeviceInfo audio will be routed to if known, or null to assume the default route.

Returns
AudioCapabilities

The current audio capabilities for the device.

getEncodingAndChannelConfigForPassthrough

public @Nullable Pair<IntegerIntegergetEncodingAndChannelConfigForPassthrough(Format format)

getEncodingAndChannelConfigForPassthrough

public @Nullable Pair<IntegerIntegergetEncodingAndChannelConfigForPassthrough(
    Format format,
    AudioAttributes audioAttributes
)

Returns the encoding and channel config to use when configuring an AudioTrack in passthrough mode for the specified Format and AudioAttributes. Returns null if passthrough of the format is unsupported.

Parameters
Format format

The Format.

AudioAttributes audioAttributes

The AudioAttributes.

Returns
@Nullable Pair<IntegerInteger>

The encoding and channel config to use, or null if passthrough of the format is unsupported.

getMaxChannelCount

public int getMaxChannelCount()

Returns the maximum number of channels the device can play at the same time.

hashCode

public int hashCode()

isPassthroughPlaybackSupported

public boolean isPassthroughPlaybackSupported(Format format)

isPassthroughPlaybackSupported

public boolean isPassthroughPlaybackSupported(
    Format format,
    AudioAttributes audioAttributes
)

Returns whether the device can do passthrough playback for format.

supportsEncoding

public boolean supportsEncoding(@C.Encoding int encoding)

Returns whether this device supports playback of the specified audio encoding.

Parameters
@C.Encoding int encoding

One of C.Encoding's ENCODING_* constants.

Returns
boolean

Whether this device supports playback the specified audio encoding.

toString

public String toString()