# AudioCapabilities

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/audio/AudioCapabilities.java+class:androidx.media3.exoplayer.audio.AudioCapabilities)

*** ** * ** ***


```
@UnstableApi
public final class AudioCapabilities
```

<br />

*** ** * ** ***

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

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#DEFAULT_AUDIO_CAPABILITIES()` The minimum audio capabilities supported by all devices. |

| ### Public fields |
|---|---|
| `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#maxChannelCount()` |
| `final https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/java/lang/Integer.html>` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#spatializerChannelMasks()` |
| `final https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/java/lang/Integer.html>` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#speakerLayoutChannelMasks()` |

| ### Public constructors |
|---|
| `[AudioCapabilities](https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#AudioCapabilities(int[],int))( @https://developer.android.com/reference/androidx/annotation/Nullable int[] supportedEncodings, int maxChannelCount )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getCapabilities(android.content.Context,androidx.media3.common.AudioAttributes,android.media.AudioDeviceInfo)` instead. <br /> |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html other)` |
| `static https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities` | `[getCapabilities](https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getCapabilities(android.content.Context))(https://developer.android.com/reference/android/content/Context.html context)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getCapabilities(android.content.Context,androidx.media3.common.AudioAttributes,android.media.AudioDeviceInfo)` instead. <br /> |
| `static https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities` | `[getCapabilities](https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getCapabilities(android.content.Context,androidx.media3.common.AudioAttributes,android.media.AudioDeviceInfo))( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/androidx/media3/common/AudioAttributes audioAttributes, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/media/AudioDeviceInfo.html routedDevice )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getCapabilities(android.content.Context,androidx.media3.common.AudioAttributes,android.media.AudioDeviceInfo,java.util.List<java.lang.Integer>)` instead. <br /> |
| `static https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getCapabilities(android.content.Context,androidx.media3.common.AudioAttributes,android.media.AudioDeviceInfo,java.util.List<java.lang.Integer>)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/androidx/media3/common/AudioAttributes audioAttributes, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/media/AudioDeviceInfo.html routedDevice, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/Integer.html> spatializerChannelMasks )` Returns the current audio capabilities. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/util/Pair.html<https://developer.android.com/reference/java/lang/Integer.html, https://developer.android.com/reference/java/lang/Integer.html>` | `[getEncodingAndChannelConfigForPassthrough](https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getEncodingAndChannelConfigForPassthrough(androidx.media3.common.Format))(https://developer.android.com/reference/androidx/media3/common/Format format)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getEncodingAndChannelConfigForPassthrough(androidx.media3.common.Format,androidx.media3.common.AudioAttributes)` instead. <br /> |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/util/Pair.html<https://developer.android.com/reference/java/lang/Integer.html, https://developer.android.com/reference/java/lang/Integer.html>` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getEncodingAndChannelConfigForPassthrough(androidx.media3.common.Format,androidx.media3.common.AudioAttributes)( https://developer.android.com/reference/androidx/media3/common/Format format, https://developer.android.com/reference/androidx/media3/common/AudioAttributes audioAttributes )` Returns the encoding and channel config to use when configuring an `https://developer.android.com/reference/android/media/AudioTrack.html` in passthrough mode for the specified `https://developer.android.com/reference/androidx/media3/common/Format` and `https://developer.android.com/reference/androidx/media3/common/AudioAttributes`. |
| `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getMaxChannelCount()()` Returns the maximum number of channels the device can play at the same time. |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/java/lang/Integer.html>` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getSpatializerChannelMasks()()` Returns the channel masks supported by the `https://developer.android.com/reference/android/media/Spatializer.html`, if enabled/available. |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/java/lang/Integer.html>` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getSpeakerLayoutChannelMasks()()` Returns the best guess at the speaker layout channel masks for the current device. |
| `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#hashCode()()` |
| `boolean` | `[isPassthroughPlaybackSupported](https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#isPassthroughPlaybackSupported(androidx.media3.common.Format))(https://developer.android.com/reference/androidx/media3/common/Format format)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#isPassthroughPlaybackSupported(androidx.media3.common.Format,androidx.media3.common.AudioAttributes)` instead. <br /> |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#isPassthroughPlaybackSupported(androidx.media3.common.Format,androidx.media3.common.AudioAttributes)( https://developer.android.com/reference/androidx/media3/common/Format format, https://developer.android.com/reference/androidx/media3/common/AudioAttributes audioAttributes )` Returns whether the device can do passthrough playback for `format`. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#supportsEncoding(int)(@https://developer.android.com/reference/androidx/media3/common/C.Encoding int encoding)` Returns whether this device supports playback of the specified audio `encoding`. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#toString()()` |

## 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
```

### spatializerChannelMasks

```
public final ImmutableList<Integer> spatializerChannelMasks
```

### speakerLayoutChannelMasks

```
public final ImmutableList<Integer> speakerLayoutChannelMasks
```

## Public constructors

### AudioCapabilities

```
public [AudioCapabilities](https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#AudioCapabilities(int[],int))(
    @Nullable int[] supportedEncodings,
    int maxChannelCount
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getCapabilities(android.content.Context,androidx.media3.common.AudioAttributes,android.media.AudioDeviceInfo)` instead.

## Public methods

### equals

```
public boolean equals(@Nullable Object other)
```

### getCapabilities

```
public static AudioCapabilities [getCapabilities](https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getCapabilities(android.content.Context))(Context context)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getCapabilities(android.content.Context,androidx.media3.common.AudioAttributes,android.media.AudioDeviceInfo)` instead.

### getCapabilities

```
public static AudioCapabilities [getCapabilities](https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getCapabilities(android.content.Context,androidx.media3.common.AudioAttributes,android.media.AudioDeviceInfo))(
    Context context,
    AudioAttributes audioAttributes,
    @Nullable AudioDeviceInfo routedDevice
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getCapabilities(android.content.Context,androidx.media3.common.AudioAttributes,android.media.AudioDeviceInfo,java.util.List<java.lang.Integer>)` instead.

### getCapabilities

```
public static AudioCapabilities getCapabilities(
    Context context,
    AudioAttributes audioAttributes,
    @Nullable AudioDeviceInfo routedDevice,
    List<Integer> spatializerChannelMasks
)
```

Returns the current audio capabilities.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | A context for obtaining the current audio capabilities. |
| `https://developer.android.com/reference/androidx/media3/common/AudioAttributes audioAttributes` | The `https://developer.android.com/reference/androidx/media3/common/AudioAttributes` to obtain capabilities for. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/media/AudioDeviceInfo.html routedDevice` | The `https://developer.android.com/reference/android/media/AudioDeviceInfo.html` audio will be routed to if known, or null to assume the default route. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/Integer.html> spatializerChannelMasks` | The channel masks supported by the `https://developer.android.com/reference/android/media/Spatializer.html`, if enabled/available. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities` | The current audio capabilities for the device. |

### getEncodingAndChannelConfigForPassthrough

```
public @Nullable Pair<Integer, Integer> [getEncodingAndChannelConfigForPassthrough](https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getEncodingAndChannelConfigForPassthrough(androidx.media3.common.Format))(Format format)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#getEncodingAndChannelConfigForPassthrough(androidx.media3.common.Format,androidx.media3.common.AudioAttributes)` instead.

### getEncodingAndChannelConfigForPassthrough

```
public @Nullable Pair<Integer, Integer> getEncodingAndChannelConfigForPassthrough(
    Format format,
    AudioAttributes audioAttributes
)
```

Returns the encoding and channel config to use when configuring an `https://developer.android.com/reference/android/media/AudioTrack.html` in passthrough mode for the specified `https://developer.android.com/reference/androidx/media3/common/Format` and `https://developer.android.com/reference/androidx/media3/common/AudioAttributes`. Returns `
null` if passthrough of the format is unsupported.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The `https://developer.android.com/reference/androidx/media3/common/Format`. |
| `https://developer.android.com/reference/androidx/media3/common/AudioAttributes audioAttributes` | The `https://developer.android.com/reference/androidx/media3/common/AudioAttributes`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/util/Pair.html<https://developer.android.com/reference/java/lang/Integer.html, https://developer.android.com/reference/java/lang/Integer.html>` | 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.

### getSpatializerChannelMasks

```
public ImmutableList<Integer> getSpatializerChannelMasks()
```

Returns the channel masks supported by the `https://developer.android.com/reference/android/media/Spatializer.html`, if enabled/available.

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

### getSpeakerLayoutChannelMasks

```
public ImmutableList<Integer> getSpeakerLayoutChannelMasks()
```

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.

### hashCode

```
public int hashCode()
```

### isPassthroughPlaybackSupported

```
public boolean [isPassthroughPlaybackSupported](https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#isPassthroughPlaybackSupported(androidx.media3.common.Format))(Format format)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioCapabilities#isPassthroughPlaybackSupported(androidx.media3.common.Format,androidx.media3.common.AudioAttributes)` instead.

### 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 |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.Encoding int encoding` | One of `https://developer.android.com/reference/androidx/media3/common/C.Encoding`'s `ENCODING_*` constants. Value is one of the following: - `Format.NO_VALUE` <br /> |

| Returns |
|---|---|
| `boolean` | Whether this device supports playback the specified audio `encoding`. |

### toString

```
public String toString()
```