# 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
public final class DefaultAudioSink implements AudioSink
```

<br />

*** ** * ** ***

Plays audio data. The implementation delegates to an `https://developer.android.com/reference/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 |
|---|
| `public interface https://developer.android.com/reference/androidx/media3/exoplayer/audio/DefaultAudioSink.AudioOffloadSupportProvider` Provides the `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioOffloadSupport` to convey the level of offload support the sink can provide. |
| `public interface https://developer.android.com/reference/androidx/media3/exoplayer/audio/DefaultAudioSink.AudioProcessorChain extends https://developer.android.com/reference/androidx/media3/common/audio/AudioProcessorChain` **This interface is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/audio/AudioProcessorChain`. <br /> |
| `public interface https://developer.android.com/reference/androidx/media3/exoplayer/audio/DefaultAudioSink.AudioTrackBufferSizeProvider` Provides the buffer size to use when creating an `https://developer.android.com/reference/android/media/AudioTrack.html`. |
| `public interface https://developer.android.com/reference/androidx/media3/exoplayer/audio/DefaultAudioSink.AudioTrackProvider` **This interface is deprecated.** Use `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioTrackAudioOutputProvider` instead. <br /> |
| `public final class https://developer.android.com/reference/androidx/media3/exoplayer/audio/DefaultAudioSink.Builder` A builder to create `https://developer.android.com/reference/androidx/media3/exoplayer/audio/DefaultAudioSink` instances. |
| `public class https://developer.android.com/reference/androidx/media3/exoplayer/audio/DefaultAudioSink.DefaultAudioProcessorChain implements https://developer.android.com/reference/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/androidx/media3/exoplayer/audio/SilenceSkippingAudioProcessor` and `https://developer.android.com/reference/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/androidx/annotation/IntDef(value = ) public annotation https://developer.android.com/reference/androidx/media3/exoplayer/audio/DefaultAudioSink.OutputMode` Output mode of the audio sink. |

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

| ### Public fields |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/AudioAttributes` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/DefaultAudioSink#audioAttributes()` |
| `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/DefaultAudioSink#playbackParameters()` |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/DefaultAudioSink#skipSilenceEnabled()` |

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

### Inherited Constants

From [androidx.media3.exoplayer.audio.AudioSink](https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioSink) `static final long` `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioSink#CURRENT_POSITION_NOT_SET() = -9223372036854775808`

Returned by `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioSink#getCurrentPositionUs(boolean)` when the position is not set.
`static final int` `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioSink#OFFLOAD_MODE_DISABLED() = 0`

The audio sink will never play in offload mode.
`static final int` `https://developer.android.com/reference/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.
`static final int` `https://developer.android.com/reference/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.
`static final int` `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioSink#SINK_FORMAT_SUPPORTED_DIRECTLY() = 2`

The sink supports the format directly, without the need for internal transcoding.
`static final int` `https://developer.android.com/reference/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.
`static final int` `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioSink#SINK_FORMAT_UNSUPPORTED() = 0`

The sink does not support the format.

### Inherited methods

From [androidx.media3.exoplayer.audio.AudioSink](https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioSink) `void` `[configure](https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioSink#configure(androidx.media3.common.Format,int,int[]))(
https://developer.android.com/reference/androidx/media3/common/Format inputFormat,
int specifiedBufferSize,
@https://developer.android.com/reference/androidx/annotation/Nullable int[] outputChannels
)`

**This method is deprecated.**

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

<br />

## Constants

### DEFAULT_PLAYBACK_SPEED

```
public static final float DEFAULT_PLAYBACK_SPEED = 1.0f
```

The default playback speed.

### MAX_PITCH

```
public static final float MAX_PITCH = 8.0f
```

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

### MAX_PLAYBACK_SPEED

```
public static final float MAX_PLAYBACK_SPEED = 8.0f
```

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

### MIN_PITCH

```
public static final float MIN_PITCH = 0.1f
```

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

### MIN_PLAYBACK_SPEED

```
public static final float MIN_PLAYBACK_SPEED = 0.1f
```

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

### OUTPUT_MODE_OFFLOAD

```
public static final int OUTPUT_MODE_OFFLOAD = 1
```

The audio sink plays encoded audio in offload.

### OUTPUT_MODE_PASSTHROUGH

```
public static final int OUTPUT_MODE_PASSTHROUGH = 2
```

The audio sink plays encoded audio in passthrough.

### OUTPUT_MODE_PCM

```
public static final int OUTPUT_MODE_PCM = 0
```

The audio sink plays PCM audio.

## Public fields

### audioAttributes

```
public AudioAttributes audioAttributes
```

### playbackParameters

```
public PlaybackParameters playbackParameters
```

### skipSilenceEnabled

```
public boolean skipSilenceEnabled
```

## Public methods

### configure

```
public void configure(AudioSink.AudioSinkConfig audioSinkConfig)
```

Configures (or reconfigures) the sink.

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

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

### disableTunneling

```
public void disableTunneling()
```

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

### enableTunnelingV21

```
public void enableTunnelingV21()
```

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

```
public void flush()
```

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/androidx/media3/exoplayer/audio/AudioSink#reset()` is called.

### getAudioAttributes

```
public AudioAttributes getAudioAttributes()
```

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

### getAudioCapabilities

```
public @Nullable AudioCapabilities getAudioCapabilities()
```

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

### getAudioTrackBufferSizeUs

```
public long getAudioTrackBufferSizeUs()
```

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/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

```
public long getCurrentPositionUs(boolean sourceEnded)
```

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

| Parameters |
|---|---|
| `boolean sourceEnded` | Specify `true` if no more input buffers will be provided. |

| Returns |
|---|---|
| `long` | The playback position relative to the start of playback, in microseconds. |

### getFormatOffloadSupport

```
public AudioOffloadSupport getFormatOffloadSupport(Format format)
```

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

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

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

### getFormatSupport

```
@AudioSink.SinkFormatSupport
public int getFormatSupport(Format format)
```

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

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

| Returns |
|---|---|
| `int` | The level of support provided. |

### getPlaybackParameters

```
public PlaybackParameters getPlaybackParameters()
```

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

### getSkipSilenceEnabled

```
public boolean getSkipSilenceEnabled()
```

Returns whether silences are skipped in the audio stream.

### handleBuffer

```
public boolean handleBuffer(
    ByteBuffer buffer,
    long presentationTimeUs,
    int encodedAccessUnitCount
)
```

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/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/androidx/media3/exoplayer/audio/AudioSink#flush()` (or to `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioSink#configure(androidx.media3.exoplayer.audio.AudioSink.AudioSinkConfig)` that causes the sink to be flushed).

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/nio/ByteBuffer.html buffer` | The buffer containing audio data. |
| `long presentationTimeUs` | The presentation timestamp of the buffer in microseconds. |
| `int encodedAccessUnitCount` | 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 |
|---|---|
| `boolean` | Whether the buffer was handled fully. |

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

### handleDiscontinuity

```
public void handleDiscontinuity()
```

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

### hasPendingData

```
public boolean hasPendingData()
```

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

### isEnded

```
public boolean isEnded()
```

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

### pause

```
public void pause()
```

Pauses playback.

### play

```
public void play()
```

Starts or resumes consuming audio if initialized.

### playToEndOfStream

```
public void playToEndOfStream()
```

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

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

### release

```
public void release()
```

Releases the audio sink.

### reset

```
public void reset()
```

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

### setAudioAttributes

```
public void setAudioAttributes(AudioAttributes audioAttributes)
```

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 |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/AudioAttributes audioAttributes` | The attributes for audio playback. |

### setAudioOutputProvider

```
public void setAudioOutputProvider(AudioOutputProvider audioOutputProvider)
```

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

### setAudioSessionId

```
public void setAudioSessionId(int audioSessionId)
```

Sets the audio session id.

### setAuxEffectInfo

```
public void setAuxEffectInfo(AuxEffectInfo auxEffectInfo)
```

Sets the auxiliary effect.

### setClock

```
public void setClock(Clock clock)
```

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

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

### setEncoderPadding

```
public void setEncoderPadding(int paddingInFrames)
```

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/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/androidx/media3/common/Format`. Reset to the configured value on `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioSink#flush()`.

| Parameters |
|---|---|
| `int paddingInFrames` | The number of audio frames to trim from the end of audio. Must be non-negative. |

### setListener

```
public void setListener(AudioSink.Listener listener)
```

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

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

### setOffloadDelayPadding

```
@RequiresApi(value = 29)
public void setOffloadDelayPadding(int delayInFrames, int paddingInFrames)
```

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/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/androidx/media3/common/Format`. Reset to the configured values on `https://developer.android.com/reference/androidx/media3/exoplayer/audio/AudioSink#flush()`.

| Parameters |
|---|---|
| `int delayInFrames` | The number of audio frames to trim from the start of audio. |
| `int paddingInFrames` | The number of audio frames to trim from the end of audio. |

### setOffloadMode

```
@RequiresApi(value = 29)
public void setOffloadMode(@AudioSink.OffloadMode int offloadMode)
```

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

```
public void setOutputStreamOffsetUs(long outputStreamOffsetUs)
```

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

| Parameters |
|---|---|
| `long outputStreamOffsetUs` | The output stream offset in microseconds. |

### setPlaybackParameters

```
public void setPlaybackParameters(PlaybackParameters playbackParameters)
```

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

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

### setPlayerId

```
public void setPlayerId(@Nullable PlayerId playerId)
```

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

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

### setPreferredDevice

```
public void setPreferredDevice(@Nullable AudioDeviceInfo audioDeviceInfo)
```

Sets the preferred audio device.

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

### setSkipSilenceEnabled

```
public void setSkipSilenceEnabled(boolean skipSilenceEnabled)
```

Sets whether silences should be skipped in the audio stream.

### setVirtualDeviceId

```
public void setVirtualDeviceId(int virtualDeviceId)
```

Sets the virtual device id.

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

### setVolume

```
public void setVolume(float volume)
```

Sets the playback volume.

| Parameters |
|---|---|
| `float volume` | Linear output gain to apply to all channels. Should be in the range \[0.0, 1.0\]. |

### supportsFormat

```
public boolean supportsFormat(Format format)
```

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

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

| Returns |
|---|---|
| `boolean` | Whether the sink supports the format. |