DrKLO/Telegram · warning · UnhandledAudioFormatException

Unhandled format: {inputAudioFormat}

Error message

Unhandled format: {inputAudioFormat}

What it means

ResamplingAudioProcessor.onConfigure throws UnhandledAudioFormatException when the input encoding is none of the supported PCM types: 8-bit, 16-bit, 16-bit big-endian, 24-bit, 32-bit, or float. This processor converts any supported PCM encoding to 16-bit PCM (the common denominator most Android AudioTracks accept); any non-PCM encoding (compressed like AAC/MP3, or an unknown encoding) is rejected because it cannot be resampled without decoding first.

Source

Thrown at TMessagesProj/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java:50

 *   <li>{@link C#ENCODING_PCM_24BIT}
 *   <li>{@link C#ENCODING_PCM_32BIT}
 *   <li>{@link C#ENCODING_PCM_FLOAT}
 * </ul>
 */
/* package */ final class ResamplingAudioProcessor extends BaseAudioProcessor {

  @Override
  @CanIgnoreReturnValue
  public AudioFormat onConfigure(AudioFormat inputAudioFormat)
      throws UnhandledAudioFormatException {
    @C.PcmEncoding int encoding = inputAudioFormat.encoding;
    if (encoding != C.ENCODING_PCM_8BIT
        && encoding != C.ENCODING_PCM_16BIT
        && encoding != C.ENCODING_PCM_16BIT_BIG_ENDIAN
        && encoding != C.ENCODING_PCM_24BIT
        && encoding != C.ENCODING_PCM_32BIT
        && encoding != C.ENCODING_PCM_FLOAT) {
      throw new UnhandledAudioFormatException(inputAudioFormat);
    }
    return encoding != C.ENCODING_PCM_16BIT
        ? new AudioFormat(
            inputAudioFormat.sampleRate, inputAudioFormat.channelCount, C.ENCODING_PCM_16BIT)
        : AudioFormat.NOT_SET;
  }

  @Override
  public void queueInput(ByteBuffer inputBuffer) {
    // Prepare the output buffer.
    int position = inputBuffer.position();
    int limit = inputBuffer.limit();
    int size = limit - position;
    int resampledSize;
    switch (inputAudioFormat.encoding) {
      case C.ENCODING_PCM_8BIT:
        resampledSize = size * 2;
        break;

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Ensure the audio chain decodes compressed formats to PCM before any AudioProcessor; ResamplingAudioProcessor must sit after the decoder.
  2. Guard the processor: only include it when inputAudioFormat.encoding is one of the known PCM constants.
  3. Update ExoPlayer to a version whose processor list matches the encodings your sources use; otherwise map new encodings to a supported PCM encoding via a custom preprocessor.

Example fix

// before: resampler in chain before decoder for a compressed source
List<AudioProcessor> chain = List.of(resamplingProcessor); // ENCODING_AAC -> throw
// after: ensure input is PCM before adding
@C.Encoding int enc = inputAudioFormat.encoding;
boolean isPcm = enc == C.ENCODING_PCM_8BIT || enc == C.ENCODING_PCM_16BIT
  || enc == C.ENCODING_PCM_16BIT_BIG_ENDIAN || enc == C.ENCODING_PCM_24BIT
  || enc == C.ENCODING_PCM_32BIT || enc == C.ENCODING_PCM_FLOAT;
if (isPcm) chain.add(resamplingProcessor);
Defensive patterns

Strategy: validation

Validate before calling

@C.Encoding int enc = inputAudioFormat.encoding;
boolean isPcm = enc == C.ENCODING_PCM_8BIT || enc == C.ENCODING_PCM_16BIT
  || enc == C.ENCODING_PCM_16BIT_BIG_ENDIAN || enc == C.ENCODING_PCM_24BIT
  || enc == C.ENCODING_PCM_32BIT || enc == C.ENCODING_PCM_FLOAT;
if (isPcm) chain.add(resamplingProcessor);

Try / catch

try {
  resamplingProcessor.onConfigure(inputAudioFormat);
} catch (UnhandledAudioFormatException e) {
  // not PCM; ensure a decoder precedes this processor in the chain
}

Prevention

When it happens

Trigger: Passing a compressed encoding (e.g. ENCODING_AAC, ENCODING_MP3) or an unknown/unset encoding into the processor; a pipeline bug where the processor sits before the decoder; an encoding constant the processor's switch does not recognize (newer API encoding not in the list).

Common situations: Mis-ordered audio chain placing resampling before decoding; feeding AudioFormat.NOT_SET; using a custom encoding constant outside the supported PCM set; format negotiation producing an encoding the processor version doesn't know.

Related errors


AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14). Data as JSON: /api/errors/443e2f2db42e666e. Report an issue: GitHub.