Package com.google.android.exoplayer2.audio

## Interface AudioProcessor

- All Known Implementing Classes:
    `BaseAudioProcessor`, `SilenceSkippingAudioProcessor`, `SonicAudioProcessor`, `TeeAudioProcessor`

      public interface AudioProcessor

  Interface for audio processors, which take audio data as input and transform it, potentially modifying its channel count, encoding and/or sample rate.

  In addition to being able to modify the format of audio, implementations may allow parameters to be set that affect the output audio and whether the processor is active/inactive.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface | Description
    --- | --- | ---
    `static class` | `AudioProcessor.AudioFormat` | PCM audio format that may be handled by an audio processor.
    `static class` | `AudioProcessor.UnhandledAudioFormatException` | Exception thrown when a processor can't be configured for a given input audio format.

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static ByteBuffer` | `EMPTY_BUFFER` | An empty, direct `ByteBuffer`.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `AudioProcessor.AudioFormat` | `configure​(AudioProcessor.AudioFormat inputAudioFormat)` | Configures the processor to process input audio with the specified format.
    `void` | `flush()` | Clears any buffered data and pending output.
    `ByteBuffer` | `getOutput()` | Returns a buffer containing processed output data between its position and limit.
    `boolean` | `isActive()` | Returns whether the processor is configured and will process input buffers.
    `boolean` | `isEnded()` | Returns whether this processor will return no more output from `getOutput()` until `flush()` has been called and more input has been queued.
    `void` | `queueEndOfStream()` | Queues an end of stream signal.
    `void` | `queueInput​(ByteBuffer inputBuffer)` | Queues audio data between the position and limit of the `inputBuffer` for processing.
    `void` | `reset()` | Resets the processor to its unconfigured state, releasing any resources.

- - ### Field Detail

    - #### EMPTY_BUFFER

          static final ByteBuffer EMPTY_BUFFER

      An empty, direct `ByteBuffer`.

  - ### Method Detail

    - #### configure

          @CanIgnoreReturnValue
          AudioProcessor.AudioFormat configure​(AudioProcessor.AudioFormat inputAudioFormat)
                                        throws AudioProcessor.UnhandledAudioFormatException

      Configures the processor to process input audio with the specified format. After calling this method, call `isActive()` to determine whether the audio processor is active. Returns the configured output audio format if this instance is active.

      After calling this method, it is necessary to `flush()` the processor to apply the new configuration. Before applying the new configuration, it is safe to queue input and get output in the old input/output formats. Call `queueEndOfStream()` when no more input will be supplied in the old input format.

      Parameters:
        `inputAudioFormat` - The format of audio that will be queued after the next call to `flush()`.
      Returns:
        The configured output audio format if this instance is `active`.
      Throws:
        `AudioProcessor.UnhandledAudioFormatException` - Thrown if the specified format can't be handled as input.

    - #### isActive

          boolean isActive()

      Returns whether the processor is configured and will process input buffers.

    - #### queueInput

          void queueInput​(ByteBuffer inputBuffer)

      Queues audio data between the position and limit of the `inputBuffer` for processing. After calling this method, processed output may be available via `getOutput()`. Calling `queueInput(ByteBuffer)` again invalidates any pending output.
      Parameters:
        `inputBuffer` - The input buffer to process. It must be a direct byte buffer with native byte order. Its contents are treated as read-only. Its position will be advanced by the number of bytes consumed (which may be zero). The caller retains ownership of the provided buffer.

    - #### queueEndOfStream

          void queueEndOfStream()

      Queues an end of stream signal. After this method has been called, `queueInput(ByteBuffer)` may not be called until after the next call to `flush()`. Calling `getOutput()` will return any remaining output data. Multiple calls may be required to read all of the remaining output data. `isEnded()` will return `true` once all remaining output data has been read.

    - #### getOutput

          ByteBuffer getOutput()

      Returns a buffer containing processed output data between its position and limit. The buffer will always be a direct byte buffer with native byte order. Calling this method invalidates any previously returned buffer. The buffer will be empty if no output is available.
      Returns:
        A buffer containing processed output data between its position and limit.

    - #### isEnded

          boolean isEnded()

      Returns whether this processor will return no more output from `getOutput()` until `flush()` has been called and more input has been queued.

    - #### flush

          void flush()

      Clears any buffered data and pending output. If the audio processor is active, also prepares the audio processor to receive a new stream of input in the last configured (pending) format.

    - #### reset

          void reset()

      Resets the processor to its unconfigured state, releasing any resources.