# ForwardingAudioSink

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

*** ** * ** ***


```
@UnstableApi
class ForwardingAudioSink : AudioSink
```

<br />

Known direct subclasses [CapturingAudioSink](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/CapturingAudioSink), [OggFileAudioBufferSink](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/OggFileAudioBufferSink)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/CapturingAudioSink` | An `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink` forwarding to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/DefaultAudioSink` that captures configuration, discontinuity and buffer events. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/OggFileAudioBufferSink` | A sink for audio buffers that writes output audio as .ogg files with a given path prefix. |

*** ** * ** ***

An overridable `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink` implementation forwarding all methods to another sink.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioSink#ForwardingAudioSink(androidx.media3.exoplayer.audio.AudioSink)(sink: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink!)` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioSink#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/ForwardingAudioSink#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 /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioSink#disableTunneling()()` Disables tunneling. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioSink#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/ForwardingAudioSink#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/common/AudioAttributes?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioSink#getAudioAttributes()()` Returns the audio attributes used for audio playback, or `null` if the sink does not use audio attributes. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioCapabilities?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackParameters!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioSink#getPlaybackParameters()()` Returns the active `https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackParameters`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioSink#getSkipSilenceEnabled()()` Returns whether silences are skipped in the audio stream. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#pause()()` Pauses playback. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#setAudioAttributes(androidx.media3.common.AudioAttributes)(audioAttributes: https://developer.android.com/reference/kotlin/androidx/media3/common/AudioAttributes!)` Sets attributes for audio playback. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#setPlaybackParameters(androidx.media3.common.PlaybackParameters)(playbackParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackParameters!)` Attempts to set the playback parameters. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#setSkipSilenceEnabled(boolean)(skipSilenceEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether silences should be skipped in the audio stream. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioSink#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/ForwardingAudioSink#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/ForwardingAudioSink#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`. |

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

## Public constructors

### ForwardingAudioSink

```
ForwardingAudioSink(sink: AudioSink!)
```

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

### configure

```
fun configure(
    inputFormat: Format!,
    specifiedBufferSize: Int,
    outputChannels: IntArray<Int>?
): Unit
```

> [!CAUTION]
> **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.

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioSink.ConfigurationException` |   |

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

### getAudioAttributes

```
fun getAudioAttributes(): AudioAttributes?
```

Returns the audio attributes used for audio playback, or `null` if the sink does not use audio attributes.

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

### getPlaybackParameters

```
fun getPlaybackParameters(): PlaybackParameters!
```

Returns the active `https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackParameters`.

### getSkipSilenceEnabled

```
fun getSkipSilenceEnabled(): Boolean
```

Returns whether silences are skipped in the audio stream.

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

### setAudioAttributes

```
fun setAudioAttributes(audioAttributes: AudioAttributes!): Unit
```

Sets attributes for audio playback. If the attributes have changed and if the sink is not configured for use with tunneling, then it is reset and the audio session id is cleared.

If the sink is configured for use with tunneling then the audio attributes are ignored. The sink is not reset and the audio session id is not cleared. The passed attributes will be used if the sink is later re-configured into non-tunneled mode.

| Parameters |
|---|---|
| `audioAttributes: https://developer.android.com/reference/kotlin/androidx/media3/common/AudioAttributes!` | The attributes for audio playback. |

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

### setPlaybackParameters

```
fun setPlaybackParameters(playbackParameters: PlaybackParameters!): Unit
```

Attempts to set the playback parameters. The audio sink may override these parameters if they are not supported.

| Parameters |
|---|---|
| `playbackParameters: https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackParameters!` | The new playback parameters to attempt to set. |

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

### setSkipSilenceEnabled

```
fun setSkipSilenceEnabled(skipSilenceEnabled: Boolean): Unit
```

Sets whether silences should be skipped in the audio stream.

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