# ForwardingAudioOutput

# ForwardingAudioOutput

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/exoplayer/audio/ForwardingAudioOutput "View this page in Java")

<br />

```
class ForwardingAudioOutput : AudioOutput
```

<br />

*** ** * ** ***

A forwarding base class that delegates all calls to the provided[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput).

## Summary

|                                                                                                                                                                                                                    ### Public constructors                                                                                                                                                                                                                     |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ForwardingAudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#ForwardingAudioOutput(androidx.media3.exoplayer.audio.AudioOutput))`(audioOutput: `[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput)`!)` Creates the forwarding[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput). |

|                                               ### Public functions                                                |
|-------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [addListener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#addListener(androidx.media3.exoplayer.audio.AudioOutput.Listener))`(listener: `[AudioOutput.Listener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput.Listener)`!)` Adds a[Listener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput.Listener)for audio output events.                                                                         |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [attachAuxEffect](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#attachAuxEffect(int))`(effectId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Attaches an auxiliary effect to the output.                                                                                                                                                                                                                                                                     |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [flush](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#flush())`()` Flushes the audio data from the output.                                                                                                                                                                                                                                                                                                                                                                                       |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                       | [getAudioSessionId](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#getAudioSessionId())`()` Returns the audio session ID or[AUDIO_SESSION_ID_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#AUDIO_SESSION_ID_UNSET())if unknown.                                                                                                                                                                                                                                  |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                     | [getBufferSizeInFrames](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#getBufferSizeInFrames())`()` Returns the buffer size in frames of the underlying[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput).                                                                                                                                                                                                                                 |
| [PlaybackParameters](https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackParameters)`!` | [getPlaybackParameters](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#getPlaybackParameters())`()` Returns the playback parameters.                                                                                                                                                                                                                                                                                                                                                              |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                     | [getPositionUs](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#getPositionUs())`()` Returns the current playout timestamp in microseconds.                                                                                                                                                                                                                                                                                                                                                        |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                       | [getSampleRate](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#getSampleRate())`()` Returns the sample rate of the underlying[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput).                                                                                                                                                                                                                                                           |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                               | [isOffloadedPlayback](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#isOffloadedPlayback())`()` Returns whether this output is playing back in offload mode.                                                                                                                                                                                                                                                                                                                                      |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                               | [isStalled](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#isStalled())`()` Returns whether the audio output is stalled.                                                                                                                                                                                                                                                                                                                                                                          |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [pause](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#pause())`()` Pauses playback.                                                                                                                                                                                                                                                                                                                                                                                                              |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [play](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#play())`()` Starts or resumes playing audio.                                                                                                                                                                                                                                                                                                                                                                                                |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [release](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#release())`()` Releases the[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput).                                                                                                                                                                                                                                                                                                    |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [removeListener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#removeListener(androidx.media3.exoplayer.audio.AudioOutput.Listener))`(listener: `[AudioOutput.Listener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput.Listener)`!)` Removes a[Listener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput.Listener)for audio output events.                                                                |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [setAuxEffectSendLevel](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#setAuxEffectSendLevel(float))`(level: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Sets the send level for the auxiliary effect.                                                                                                                                                                                                                                                    |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [setOffloadDelayPadding](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#setOffloadDelayPadding(int,int))`(delayInFrames: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, paddingInFrames: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets the offload delay and padding.                                                                                                                                                      |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [setOffloadEndOfStream](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#setOffloadEndOfStream())`()` Notifies the output that this is the end of the stream.                                                                                                                                                                                                                                                                                                                                       |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [setPlaybackParameters](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#setPlaybackParameters(androidx.media3.common.PlaybackParameters))`(playbackParams: `[PlaybackParameters](https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackParameters)`!)` Sets the playback parameters.                                                                                                                                                                                       |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | `@`[UnstableApi](https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi) [setPlayerId](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#setPlayerId(androidx.media3.exoplayer.analytics.PlayerId))`(playerId: `[PlayerId](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId)`!)` Sets the[PlayerId](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId)on the audio output.      |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [setPreferredDevice](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#setPreferredDevice(android.media.AudioDeviceInfo))`(preferredDevice: `[AudioDeviceInfo](https://developer.android.com/reference/android/media/AudioDeviceInfo.html)`?)` Sets the preferred audio device for routing, or null for no preference.                                                                                                                                                                               |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [setVolume](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#setVolume(float))`(volume: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Sets the volume of the[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput).                                                                                                                                                                                        |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                     | [stop](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#stop())`()` Signal that the last buffer has been written and playback should stop after playing out all remaining buffers                                                                                                                                                                                                                                                                                                                   |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                               | [write](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/ForwardingAudioOutput#write(java.nio.ByteBuffer,int,long))`(` ` buffer: `[ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html)`!,` ` encodedAccessUnitCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` presentationTimeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) `)` Writes audio data to the audio output for playback with a presentation timestamp. |

## Public constructors

### ForwardingAudioOutput

```
ForwardingAudioOutput(audioOutput: AudioOutput!)
```

Creates the forwarding[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput).  

|                                                         Parameters                                                          |
|-----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| `audioOutput: `[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput)`!` | The wrapped[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput). |

## Public functions

### addListener

```
fun addListener(listener: AudioOutput.Listener!): Unit
```

Adds a[Listener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput.Listener)for audio output events.  

### attachAuxEffect

```
fun attachAuxEffect(effectId: Int): Unit
```

Attaches an auxiliary effect to the output.  

### flush

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

Flushes the audio data from the output.  

### getAudioSessionId

```
fun getAudioSessionId(): Int
```

Returns the audio session ID or[AUDIO_SESSION_ID_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#AUDIO_SESSION_ID_UNSET())if unknown.  

### getBufferSizeInFrames

```
fun getBufferSizeInFrames(): Long
```

Returns the buffer size in frames of the underlying[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput).  

### getPlaybackParameters

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

Returns the playback parameters.  

### getPositionUs

```
fun getPositionUs(): Long
```

Returns the current playout timestamp in microseconds.  

### getSampleRate

```
fun getSampleRate(): Int
```

Returns the sample rate of the underlying[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput).  

### isOffloadedPlayback

```
fun isOffloadedPlayback(): Boolean
```

Returns whether this output is playing back in offload mode.  

### isStalled

```
fun isStalled(): Boolean
```

Returns whether the audio output is stalled.  

### pause

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

Pauses playback.  

### play

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

Starts or resumes playing audio.  

### release

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

Releases the[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput).  

### removeListener

```
fun removeListener(listener: AudioOutput.Listener!): Unit
```

Removes a[Listener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput.Listener)for audio output events.  

### setAuxEffectSendLevel

```
fun setAuxEffectSendLevel(level: Float): Unit
```

Sets the send level for the auxiliary effect.  

### setOffloadDelayPadding

```
fun setOffloadDelayPadding(delayInFrames: Int, paddingInFrames: Int): Unit
```

Sets the offload delay and padding.  

### setOffloadEndOfStream

```
fun setOffloadEndOfStream(): Unit
```

Notifies the output that this is the end of the stream.  

### setPlaybackParameters

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

Sets the playback parameters.  

### setPlayerId

```
@UnstableApi
fun setPlayerId(playerId: PlayerId!): Unit
```

Sets the[PlayerId](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId)on the audio output.  

### setPreferredDevice

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

Sets the preferred audio device for routing, or null for no preference.  

### setVolume

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

Sets the volume of the[AudioOutput](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput).  

### stop

```
fun stop(): Unit
```

Signal that the last buffer has been written and playback should stop after playing out all remaining buffers  

### write

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

Writes audio data to the audio output for playback with a presentation timestamp.

The provided`buffer`must be a direct byte buffer with native byte order. The method is read-only and will not modify the bytes. It processes data from`buffer.position()`to`buffer.limit()`(exclusive). Every call will advance`buffer.position()`to reflect the number of bytes written.

The first time this method is called with a new buffer, the buffer must contain one or more complete encoded access units or complete PCM frames.

If this method returns`false`, the same buffer must be used for subsequent calls to this method until it has been fully consumed, or until an intervening call to[flush](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput#flush()).  

|                                              Parameters                                               |
|-------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `buffer: `[ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html)`!`           | The buffer containing the audio data.                                                                                                                                                                                                                     |
| `encodedAccessUnitCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The number of encoded access units in the buffer when the buffer was first used in this method, or 1 if the buffer contains PCM audio. When calling this method again after it returned`false`, the same number of encoded access units must be provided. |
| `presentationTimeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)   | The presentation timestamp, in microseconds, of the first access unit or PCM frame when the buffer was first used in this method. When calling this method again after it returned`false`, the same timestamp must be provided.                           |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|---------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether the buffer was handled fully. |

|                                                                                 Throws                                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|
| [androidx.media3.exoplayer.audio.AudioOutput.WriteException](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/AudioOutput.WriteException) | If the write fails. The audio output cannot be reused after a failure and needs to be recreated. |