# DefaultAudioSink

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/DefaultAudioSink.java+class:androidx.media3.exoplayer.audio.DefaultAudioSink)

*** ** * ** ***


```
@UnstableApi
class DefaultAudioSink : AudioSink
```

<br />

*** ** * ** ***

Plays audio data. The implementation delegates to an `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput` and handles playback position smoothing, non-blocking writes and reconfiguration.

If tunneling mode is enabled, care must be taken that audio processors do not output buffers with a different duration than their input, and buffer processors must produce output corresponding to their last input immediately after that input is queued. This means that, for example, speed adjustment is not possible while using tunneling.

## Summary

| ### Nested types |
|---|
| `interface https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink.AudioOffloadSupportProvider` Provides the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOffloadSupport` to convey the level of offload support the sink can provide. |
| `interface https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink.AudioProcessorChain : https://developer.android.com/reference/kotlin/androidx/media3/common/audio/AudioProcessorChain` **This interface is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/AudioProcessorChain`. <br /> |
| `interface https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink.AudioTrackBufferSizeProvider` Provides the buffer size to use when creating an `https://developer.android.com/reference/android/media/AudioTrack.html`. |
| `interface https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink.AudioTrackProvider` **This interface is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioTrackAudioOutputProvider` instead. <br /> |
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink.Builder` A builder to create `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink` instances. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink.DefaultAudioProcessorChain : https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink.AudioProcessorChain` The default audio processor chain, which applies a (possibly empty) chain of user-defined audio processors followed by `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/SilenceSkippingAudioProcessor` and `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SonicAudioProcessor`. |
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(value = ) annotation https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink.OutputMode` Output mode of the audio sink. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#DEFAULT_PLAYBACK_SPEED() = 1.0f` The default playback speed. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#MAX_PITCH() = 8.0f` The maximum allowed pitch factor. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#MAX_PLAYBACK_SPEED() = 8.0f` The maximum allowed playback speed. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#MIN_PITCH() = 0.1f` The minimum allowed pitch factor. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#MIN_PLAYBACK_SPEED() = 0.1f` The minimum allowed playback speed. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#OUTPUT_MODE_OFFLOAD() = 1` The audio sink plays encoded audio in offload. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#OUTPUT_MODE_PASSTHROUGH() = 2` The audio sink plays encoded audio in passthrough. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#OUTPUT_MODE_PCM() = 0` The audio sink plays PCM audio. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#configure(androidx.media3.exoplayer.audio.AudioSink.AudioSinkConfig)(audioSinkConfig: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink.AudioSinkConfig!)` Configures (or reconfigures) the sink. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#disableTunneling()()` Disables tunneling. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#enableTunnelingV21()()` Enables tunneling, if possible. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#flush()()` Flushes the sink, after which it is ready to receive buffers from a new playback position. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioCapabilities?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#getAudioCapabilities()()` Returns the AudioCapabilities of the sink, if supported by the sink implementation. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#getAudioTrackBufferSizeUs()()` Returns the size of the underlying `https://developer.android.com/reference/android/media/AudioTrack.html` buffer in microseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#getCurrentPositionUs(boolean)(sourceEnded: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Returns the playback position in the stream starting at zero, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#CURRENT_POSITION_NOT_SET()` if it is not yet available. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOffloadSupport!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#getFormatOffloadSupport(androidx.media3.common.Format)(format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!)` Returns the level of offload support that the sink can provide for a given `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink.SinkFormatSupport https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#getFormatSupport(androidx.media3.common.Format)(format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!)` Returns the level of support that the sink provides for a given `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#handleBuffer(java.nio.ByteBuffer,long,int)( buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!, presentationTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, encodedAccessUnitCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Attempts to process data from a `https://developer.android.com/reference/java/nio/ByteBuffer.html`, starting from its current position and ending at its limit (exclusive). |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#handleDiscontinuity()()` Signals to the sink that the next buffer may be discontinuous with the previous buffer. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#hasPendingData()()` Returns whether the sink has data pending that has not been consumed yet. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#isEnded()()` Returns whether `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#playToEndOfStream()` has been called and all buffers have been processed. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#pause()()` Pauses playback. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#play()()` Starts or resumes consuming audio if initialized. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#playToEndOfStream()()` Processes any remaining data. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#release()()` Releases the audio sink. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#reset()()` Resets the sink, releasing any resources that it currently holds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#setAudioOutputProvider(androidx.media3.exoplayer.audio.AudioOutputProvider)(audioOutputProvider: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutputProvider!)` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutputProvider` to use as the output path. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#setAudioSessionId(int)(audioSessionId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the audio session id. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#setAuxEffectInfo(androidx.media3.common.AuxEffectInfo)(auxEffectInfo: https://developer.android.com/reference/kotlin/androidx/media3/common/AuxEffectInfo!)` Sets the auxiliary effect. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#setClock(androidx.media3.common.util.Clock)(clock: https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock!)` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock` to use for timing in this audio sink. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#setEncoderPadding(int)(paddingInFrames: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the number of audio frames to trim from the end of PCM audio passed to this sink. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#setListener(androidx.media3.exoplayer.audio.AudioSink.Listener)(listener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink.Listener!)` Sets the listener for sink events, which should be the audio renderer. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 29) https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#setOffloadDelayPadding(int,int)(delayInFrames: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, paddingInFrames: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets offload delay and padding on the `https://developer.android.com/reference/android/media/AudioTrack.html`, if possible. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 29) https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#setOffloadMode(int)(@https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink.OffloadMode offloadMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets audio offload mode, if possible. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#setOutputStreamOffsetUs(long)(outputStreamOffsetUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the offset that is added to the media timestamp before it is passed as ` presentationTimeUs` in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#handleBuffer(java.nio.ByteBuffer,long,int)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#setPlayerId(androidx.media3.exoplayer.analytics.PlayerId)(playerId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId?)` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId` of the player using this audio sink. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#setPreferredDevice(android.media.AudioDeviceInfo)(audioDeviceInfo: https://developer.android.com/reference/android/media/AudioDeviceInfo.html?)` Sets the preferred audio device. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#setVirtualDeviceId(int)(virtualDeviceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the virtual device id. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#setVolume(float)(volume: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Sets the playback volume. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#supportsFormat(androidx.media3.common.Format)(format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!)` Returns whether the sink supports a given `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`. |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/AudioAttributes!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#audioAttributes()` |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackParameters!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#playbackParameters()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink#skipSilenceEnabled()` |

### Inherited Constants

From [androidx.media3.exoplayer.audio.AudioSink](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink) `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#CURRENT_POSITION_NOT_SET() = -9223372036854775808`

Returned by `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#getCurrentPositionUs(boolean)` when the position is not set.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#OFFLOAD_MODE_DISABLED() = 0`

The audio sink will never play in offload mode.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#OFFLOAD_MODE_ENABLED_GAPLESS_NOT_REQUIRED() = 2`

The audio sink will prefer offload playback even if this might result in silence gaps between tracks.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#OFFLOAD_MODE_ENABLED_GAPLESS_REQUIRED() = 1`

The audio sink will prefer offload playback except in the case where both the track is gapless and the device does support gapless offload playback.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#SINK_FORMAT_SUPPORTED_DIRECTLY() = 2`

The sink supports the format directly, without the need for internal transcoding.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#SINK_FORMAT_SUPPORTED_WITH_TRANSCODING() = 1`

The sink supports the format, but needs to transcode it internally to do so.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#SINK_FORMAT_UNSUPPORTED() = 0`

The sink does not support the format.

### Inherited functions

From [androidx.media3.exoplayer.audio.AudioSink](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[configure](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#configure(androidx.media3.common.Format,int,int[]))(
inputFormat: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!,
specifiedBufferSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html,
outputChannels: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>?
)`

**This function is deprecated.**

Call and implement `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#configure(androidx.media3.exoplayer.audio.AudioSink.AudioSinkConfig)` instead.

<br />

## Constants

### DEFAULT_PLAYBACK_SPEED

```
const val DEFAULT_PLAYBACK_SPEED = 1.0f: Float
```

The default playback speed.

### MAX_PITCH

```
const val MAX_PITCH = 8.0f: Float
```

The maximum allowed pitch factor. Higher values will be constrained to fall in range unless the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput` supports other values.

### MAX_PLAYBACK_SPEED

```
const val MAX_PLAYBACK_SPEED = 8.0f: Float
```

The maximum allowed playback speed. Higher values will be constrained to fall in range unless the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput` supports other values.

### MIN_PITCH

```
const val MIN_PITCH = 0.1f: Float
```

The minimum allowed pitch factor. Lower values will be constrained to fall in range unless the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput` supports other values.

### MIN_PLAYBACK_SPEED

```
const val MIN_PLAYBACK_SPEED = 0.1f: Float
```

The minimum allowed playback speed. Lower values will be constrained to fall in range unless the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput` supports other values.

### OUTPUT_MODE_OFFLOAD

```
const val OUTPUT_MODE_OFFLOAD = 1: Int
```

The audio sink plays encoded audio in offload.

### OUTPUT_MODE_PASSTHROUGH

```
const val OUTPUT_MODE_PASSTHROUGH = 2: Int
```

The audio sink plays encoded audio in passthrough.

### OUTPUT_MODE_PCM

```
const val OUTPUT_MODE_PCM = 0: Int
```

The audio sink plays PCM audio.

## Public functions

### configure

```
fun configure(audioSinkConfig: AudioSink.AudioSinkConfig!): Unit
```

Configures (or reconfigures) the sink.

| Parameters |
|---|---|
| `audioSinkConfig: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink.AudioSinkConfig!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink.AudioSinkConfig`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink.ConfigurationException` | If an error occurs configuring the sink. |

### disableTunneling

```
fun disableTunneling(): Unit
```

Disables tunneling. If tunneling was previously enabled then the sink is reset and any audio session id is cleared.

### enableTunnelingV21

```
fun enableTunnelingV21(): Unit
```

Enables tunneling, if possible. The sink is reset if tunneling was previously disabled. Enabling tunneling is only possible if the sink is based on a platform `https://developer.android.com/reference/android/media/AudioTrack.html`.

### flush

```
fun flush(): Unit
```

Flushes the sink, after which it is ready to receive buffers from a new playback position.

The audio session may remain active until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#reset()` is called.

### getAudioCapabilities

```
fun getAudioCapabilities(): AudioCapabilities?
```

Returns the AudioCapabilities of the sink, if supported by the sink implementation.

### getAudioTrackBufferSizeUs

```
fun getAudioTrackBufferSizeUs(): Long
```

Returns the size of the underlying `https://developer.android.com/reference/android/media/AudioTrack.html` buffer in microseconds. If unsupported or the `https://developer.android.com/reference/android/media/AudioTrack.html` is not initialized then return `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()`.

If the `https://developer.android.com/reference/android/media/AudioTrack.html` is configured with a compressed encoding, then the returned duration is an estimated minimum based on the encoding's maximum encoded byte rate.

### getCurrentPositionUs

```
fun getCurrentPositionUs(sourceEnded: Boolean): Long
```

Returns the playback position in the stream starting at zero, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#CURRENT_POSITION_NOT_SET()` if it is not yet available.

| Parameters |
|---|---|
| `sourceEnded: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Specify `true` if no more input buffers will be provided. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The playback position relative to the start of playback, in microseconds. |

### getFormatOffloadSupport

```
fun getFormatOffloadSupport(format: Format!): AudioOffloadSupport!
```

Returns the level of offload support that the sink can provide for a given `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`.

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOffloadSupport!` | The level of support provided. |

### getFormatSupport

```
@AudioSink.SinkFormatSupport
fun getFormatSupport(format: Format!): Int
```

Returns the level of support that the sink provides for a given `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`.

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The level of support provided. |

### handleBuffer

```
fun handleBuffer(
    buffer: ByteBuffer!,
    presentationTimeUs: Long,
    encodedAccessUnitCount: Int
): Boolean
```

Attempts to process data from a `https://developer.android.com/reference/java/nio/ByteBuffer.html`, starting from its current position and ending at its limit (exclusive). The position of the `https://developer.android.com/reference/java/nio/ByteBuffer.html` is advanced by the number of bytes that were handled. `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink.Listener#onPositionDiscontinuity()` will be called if `presentationTimeUs` is discontinuous with the last buffer handled since the last reset.

Returns whether the data was handled in full. If the data was not handled in full then the same `https://developer.android.com/reference/java/nio/ByteBuffer.html` must be provided to subsequent calls until it has been fully consumed, except in the case of an intervening call to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#flush()` (or to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#configure(androidx.media3.exoplayer.audio.AudioSink.AudioSinkConfig)` that causes the sink to be flushed).

| Parameters |
|---|---|
| `buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!` | The buffer containing audio data. |
| `presentationTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The presentation timestamp of the buffer in microseconds. |
| `encodedAccessUnitCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of encoded access units in the buffer, or 1 if the buffer contains PCM audio. This allows batching multiple encoded access units in one buffer. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the buffer was handled fully. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink.InitializationException` | If an error occurs initializing the sink. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink.WriteException` | If an error occurs writing the audio data. |

### handleDiscontinuity

```
fun handleDiscontinuity(): Unit
```

Signals to the sink that the next buffer may be discontinuous with the previous buffer.

### hasPendingData

```
fun hasPendingData(): Boolean
```

Returns whether the sink has data pending that has not been consumed yet.

### isEnded

```
fun isEnded(): Boolean
```

Returns whether `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#playToEndOfStream()` has been called and all buffers have been processed.

### pause

```
fun pause(): Unit
```

Pauses playback.

### play

```
fun play(): Unit
```

Starts or resumes consuming audio if initialized.

### playToEndOfStream

```
fun playToEndOfStream(): Unit
```

Processes any remaining data. `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#isEnded()` will return `true` when no data remains.

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink.WriteException` | If an error occurs draining data to the sink. |

### release

```
fun release(): Unit
```

Releases the audio sink.

### reset

```
fun reset(): Unit
```

Resets the sink, releasing any resources that it currently holds.

### setAudioOutputProvider

```
fun setAudioOutputProvider(audioOutputProvider: AudioOutputProvider!): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutputProvider` to use as the output path.

### setAudioSessionId

```
fun setAudioSessionId(audioSessionId: Int): Unit
```

Sets the audio session id.

### setAuxEffectInfo

```
fun setAuxEffectInfo(auxEffectInfo: AuxEffectInfo!): Unit
```

Sets the auxiliary effect.

### setClock

```
fun setClock(clock: Clock!): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock` to use for timing in this audio sink.

| Parameters |
|---|---|
| `clock: https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock`. |

### setEncoderPadding

```
fun setEncoderPadding(paddingInFrames: Int): Unit
```

Sets the number of audio frames to trim from the end of PCM audio passed to this sink.

Applies to the most recently `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#configure(androidx.media3.exoplayer.audio.AudioSink.AudioSinkConfig)` input if it is PCM, and overrides any padding configured via the `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`. Reset to the configured value on `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#flush()`.

| Parameters |
|---|---|
| `paddingInFrames: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of audio frames to trim from the end of audio. Must be non-negative. |

### setListener

```
fun setListener(listener: AudioSink.Listener!): Unit
```

Sets the listener for sink events, which should be the audio renderer.

| Parameters |
|---|---|
| `listener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink.Listener!` | The listener for sink events, which should be the audio renderer. |

### setOffloadDelayPadding

```
@RequiresApi(value = 29)
fun setOffloadDelayPadding(delayInFrames: Int, paddingInFrames: Int): Unit
```

Sets offload delay and padding on the `https://developer.android.com/reference/android/media/AudioTrack.html`, if possible.

Setting the offload delay and padding is only possible if the sink is based on a platform `https://developer.android.com/reference/android/media/AudioTrack.html` in offload mode, and requires platform API version 29 onwards.

Applies to the most recently `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#configure(androidx.media3.exoplayer.audio.AudioSink.AudioSinkConfig)` input if it is not PCM, and overrides any delay and padding configured via the `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`. Reset to the configured values on `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#flush()`.

| Parameters |
|---|---|
| `delayInFrames: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of audio frames to trim from the start of audio. |
| `paddingInFrames: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of audio frames to trim from the end of audio. |

### setOffloadMode

```
@RequiresApi(value = 29)
fun setOffloadMode(@AudioSink.OffloadMode offloadMode: Int): Unit
```

Sets audio offload mode, if possible. Enabling offload is only possible if the sink is based on a platform `https://developer.android.com/reference/android/media/AudioTrack.html`, and requires platform API version 29 onwards.

### setOutputStreamOffsetUs

```
fun setOutputStreamOffsetUs(outputStreamOffsetUs: Long): Unit
```

Sets the offset that is added to the media timestamp before it is passed as `
presentationTimeUs` in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink#handleBuffer(java.nio.ByteBuffer,long,int)`.

| Parameters |
|---|---|
| `outputStreamOffsetUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The output stream offset in microseconds. |

### setPlayerId

```
fun setPlayerId(playerId: PlayerId?): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId` of the player using this audio sink.

| Parameters |
|---|---|
| `playerId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId?` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId`, or null to clear a previously set id. |

### setPreferredDevice

```
fun setPreferredDevice(audioDeviceInfo: AudioDeviceInfo?): Unit
```

Sets the preferred audio device.

| Parameters |
|---|---|
| `audioDeviceInfo: https://developer.android.com/reference/android/media/AudioDeviceInfo.html?` | The preferred `https://developer.android.com/reference/android/media/AudioDeviceInfo.html`, or null to restore the default. |

### setVirtualDeviceId

```
fun setVirtualDeviceId(virtualDeviceId: Int): Unit
```

Sets the virtual device id.

| Parameters |
|---|---|
| `virtualDeviceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/android/companion/virtual/VirtualDevice.html#getDeviceId()`, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if unspecified. |

### setVolume

```
fun setVolume(volume: Float): Unit
```

Sets the playback volume.

| Parameters |
|---|---|
| `volume: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Linear output gain to apply to all channels. Should be in the range \[0.0, 1.0\]. |

### supportsFormat

```
fun supportsFormat(format: Format!): Boolean
```

Returns whether the sink supports a given `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`.

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the sink supports the format. |

## Public properties

### audioAttributes

```
var audioAttributes: AudioAttributes!
```

### playbackParameters

```
var playbackParameters: PlaybackParameters!
```

### skipSilenceEnabled

```
var skipSilenceEnabled: Boolean
```