{"record":{"id":"bd8d81db4911f529","repo":"google/ExoPlayer","slug":"unhandled-input-format-audioformat","errorCode":null,"errorMessage":"Unhandled input format: ${audioFormat}","messagePattern":"Unhandled input format: (.+?)","errorType":"exception","errorClass":"AudioProcessor.UnhandledAudioFormatException","httpStatus":null,"severity":"error","filePath":"library/common/src/main/java/com/google/android/exoplayer2/audio/AudioProcessingPipeline.java","lineNumber":129,"sourceCode":"   * Configures the pipeline to process input audio with the specified format. Returns the\n   * configured output audio format.\n   *\n   * <p>To apply the new configuration for use, the pipeline must be {@linkplain #flush() flushed}.\n   * Before applying the new configuration, it is safe to queue input and get output in the old\n   * input/output formats/configuration. Call {@link #queueEndOfStream()} when no more input will be\n   * supplied for processing in the old configuration.\n   *\n   * @param inputAudioFormat The format of audio that will be queued after the next call to {@link\n   *     #flush()}.\n   * @return The configured output audio format.\n   * @throws AudioProcessor.UnhandledAudioFormatException If the specified format is not supported\n   *     by the pipeline.\n   */\n  @CanIgnoreReturnValue\n  public AudioFormat configure(AudioFormat inputAudioFormat)\n      throws AudioProcessor.UnhandledAudioFormatException {\n    if (inputAudioFormat.equals(AudioFormat.NOT_SET)) {\n      throw new AudioProcessor.UnhandledAudioFormatException(inputAudioFormat);\n    }\n\n    AudioFormat intermediateAudioFormat = inputAudioFormat;\n\n    for (int i = 0; i < audioProcessors.size(); i++) {\n      AudioProcessor audioProcessor = audioProcessors.get(i);\n      AudioFormat nextFormat = audioProcessor.configure(intermediateAudioFormat);\n      if (audioProcessor.isActive()) {\n        checkState(!nextFormat.equals(AudioFormat.NOT_SET));\n        intermediateAudioFormat = nextFormat;\n      }\n    }\n\n    return pendingOutputAudioFormat = intermediateAudioFormat;\n  }\n\n  /**\n   * Clears any buffered data and pending output. If any underlying audio processors are {@linkplain","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/google/ExoPlayer/blob/dd430f7053a1a3958deea3ead6a0565150c06bfc/library/common/src/main/java/com/google/android/exoplayer2/audio/AudioProcessingPipeline.java#L111-L147","documentation":"AudioProcessingPipeline.configure(AudioFormat) chains configure() across every AudioProcessor in the pipeline and throws AudioProcessor.UnhandledAudioFormatException when the chain cannot accept the input format. The explicitly shown case is inputAudioFormat.equals(AudioFormat.NOT_SET) — configuring with an unset format — but any processor in the chain may also throw UnhandledAudioFormatException for encodings/channel counts it rejects, and that propagates out of the pipeline.","triggerScenarios":"Calling pipeline.configure(new AudioFormat(...)) with a NOT_SET format, or feeding a format (encoding, channel count, sample rate combination) that at least one active AudioProcessor in the pipeline cannot process, e.g. 5.1-channel PCM into a processor limited to stereo, or non-PCM input into an audio DSP chain.","commonSituations":"Using SilenceSkippingAudioProcessor/ChannelMixingAudioProcessor/SonicAudioProcessor which only accept ENCODING_PCM_16BIT; playing exotic devices or files that output 24-bit/float PCM; reconfiguring the pipeline after a mid-stream format change without draining/resetting processors; calling configure before the upstream format is known (NOT_SET).","solutions":["Check inputAudioFormat against AudioFormat.NOT_SET before configuring and only call configure() once a real format is available.","Verify the source produces C.ENCODING_PCM_16BIT (or insert ToInt16PcmAudioProcessor ahead of the chain) since most built-in processors require 16-bit PCM.","Inspect which processor throws by configuring each AudioProcessor individually; replace or remove the restrictive one for the offending channel count.","Catch AudioProcessor.UnhandledAudioFormatException at the renderer level to disable the failing processor rather than crash playback."],"exampleFix":"// before\npipeline.configure(AudioFormat.NOT_SET); // throws UnhandledAudioFormatException\n\n// after\nif (!inputFormat.equals(AudioFormat.NOT_SET)\n    && inputFormat.encoding == C.ENCODING_PCM_16BIT) {\n  AudioFormat out = pipeline.configure(inputFormat);\n} else {\n  // skip processing, use passthrough path\n}","handlingStrategy":"try-catch","validationCode":"public boolean isPipelineFormatSupported(AudioProcessingPipeline p, AudioFormat f) {\n  if (f.equals(AudioFormat.NOT_SET)) return false;\n  try {\n    // dry-run configure on a scratch instance or the same pipeline before flush\n    p.configure(f);\n    return true;\n  } catch (AudioProcessor.UnhandledAudioFormatException e) {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  pipeline.configure(inputFormat);\n} catch (AudioProcessor.UnhandledAudioFormatException e) {\n  // Disable the unsupported processor and use a shorter chain / passthrough\n  Log.w(TAG, \"Unsupported audio format \" + e.getAudioFormat(), e);\n  pipeline = new AudioProcessingPipeline(ImmutableList.of());\n  pipeline.configure(inputFormat);\n}","preventionTips":["Never call configure() with AudioFormat.NOT_SET; wait until the upstream format is known.","Know each built-in processor's encoding limits — most require ENCODING_PCM_16BIT.","Prepend ToInt16PcmAudioProcessor when sources may output float/24-bit PCM.","Handle mid-stream format changes by draining and re-configuring the whole pipeline, not reconfiguring in place."],"tags":["exoplayer","media3","audio","audio-processor","pcm"],"backgroundTag":null,"analyzedSha":"dd430f7053a1a3958deea3ead6a0565150c06bfc","analyzedAt":"2026-08-14T12:22:02.982Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}