AudioCapabilities


@UnstableApi
class AudioCapabilities


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

Summary

Constants

const AudioCapabilities!

The minimum audio capabilities supported by all devices.

Public constructors

AudioCapabilities(
    supportedEncodings: IntArray<Int>?,
    maxChannelCount: Int
)

This function is deprecated.

Use getCapabilities instead.

Public functions

Boolean
equals(other: Any?)
java-static AudioCapabilities!

This function is deprecated.

Use getCapabilities instead.

java-static AudioCapabilities!
getCapabilities(
    context: Context!,
    audioAttributes: AudioAttributes!,
    routedDevice: AudioDeviceInfo?
)

This function is deprecated.

Use <> instead.

java-static AudioCapabilities!
getCapabilities(
    context: Context!,
    audioAttributes: AudioAttributes!,
    routedDevice: AudioDeviceInfo?,
    spatializerChannelMasks: (Mutable)List<Int!>!
)

Returns the current audio capabilities.

Pair<Int!, Int!>?

This function is deprecated.

Use getEncodingAndChannelConfigForPassthrough instead.

Pair<Int!, Int!>?
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
Boolean

This function 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!

Public properties

Int

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

ImmutableList<Int!>!

Returns the channel masks supported by the android.media.Spatializer, if enabled/available.

ImmutableList<Int!>!

Returns the best guess at the speaker layout channel masks for the current device.

Constants

DEFAULT_AUDIO_CAPABILITIES

const val DEFAULT_AUDIO_CAPABILITIES: AudioCapabilities!

The minimum audio capabilities supported by all devices.

Public constructors

AudioCapabilities

AudioCapabilities(
    supportedEncodings: IntArray<Int>?,
    maxChannelCount: Int
)

Public functions

equals

fun equals(other: Any?): Boolean

getCapabilities

java-static fun getCapabilities(context: Context!): AudioCapabilities!

getCapabilities

java-static fun getCapabilities(
    context: Context!,
    audioAttributes: AudioAttributes!,
    routedDevice: AudioDeviceInfo?
): AudioCapabilities!

getCapabilities

java-static fun getCapabilities(
    context: Context!,
    audioAttributes: AudioAttributes!,
    routedDevice: AudioDeviceInfo?,
    spatializerChannelMasks: (Mutable)List<Int!>!
): AudioCapabilities!

Returns the current audio capabilities.

Parameters
context: Context!

A context for obtaining the current audio capabilities.

audioAttributes: AudioAttributes!

The AudioAttributes to obtain capabilities for.

routedDevice: AudioDeviceInfo?

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

spatializerChannelMasks: (Mutable)List<Int!>!

The channel masks supported by the android.media.Spatializer, if enabled/available.

Returns
AudioCapabilities!

The current audio capabilities for the device.

getEncodingAndChannelConfigForPassthrough

fun getEncodingAndChannelConfigForPassthrough(format: Format!): Pair<Int!, Int!>?

getEncodingAndChannelConfigForPassthrough

fun getEncodingAndChannelConfigForPassthrough(
    format: Format!,
    audioAttributes: AudioAttributes!
): Pair<Int!, Int!>?

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
Pair<Int!, Int!>?

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

hashCode

fun hashCode(): Int

isPassthroughPlaybackSupported

fun isPassthroughPlaybackSupported(format: Format!): Boolean

isPassthroughPlaybackSupported

fun isPassthroughPlaybackSupported(
    format: Format!,
    audioAttributes: AudioAttributes!
): Boolean

Returns whether the device can do passthrough playback for format.

supportsEncoding

fun supportsEncoding(@C.Encoding encoding: Int): Boolean

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

Parameters
@C.Encoding encoding: Int

One of C.Encoding's ENCODING_* constants.

Value is one of the following:

  • Format.NO_VALUE

Returns
Boolean

Whether this device supports playback the specified audio encoding.

toString

fun toString(): String!

Public properties

maxChannelCount

val maxChannelCount: Int

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

spatializerChannelMasks

val spatializerChannelMasks: ImmutableList<Int!>!

Returns the channel masks supported by the android.media.Spatializer, if enabled/available.

This is only non-empty if the Spatialize is ready for use.

speakerLayoutChannelMasks

val speakerLayoutChannelMasks: ImmutableList<Int!>!

Returns the best guess at the speaker layout channel masks for the current device.

These are ordered from highest channel count to lowest, also meaning from more likely to represent the complete physical layout to subsets. For example, a device with an actual 5.1 layout might also report 3.1 and stereo.

The subsequent channel masks are useful when decoders might not be compatible with any arbitrary channel mask.