{"record":{"id":"d6f5bce977813f48","repo":"google/ExoPlayer","slug":"unhandled-input-format-audioformat-d6f5bc","errorCode":null,"errorMessage":"Unhandled input format: {audioFormat}","messagePattern":"Unhandled input format: (.+?)","errorType":"exception","errorClass":"UnhandledAudioFormatException","httpStatus":null,"severity":"error","filePath":"library/common/src/main/java/com/google/android/exoplayer2/audio/ChannelMixingAudioProcessor.java","lineNumber":60,"sourceCode":"  public ChannelMixingAudioProcessor() {\n    matrixByInputChannelCount = new SparseArray<>();\n  }\n\n  /**\n   * Stores a channel mixing matrix for processing audio with a given {@link\n   * ChannelMixingMatrix#getInputChannelCount() channel count}. Overwrites any previously stored\n   * matrix for the same input channel count.\n   */\n  public void putChannelMixingMatrix(ChannelMixingMatrix matrix) {\n    int inputChannelCount = matrix.getInputChannelCount();\n    matrixByInputChannelCount.put(inputChannelCount, matrix);\n  }\n\n  @Override\n  protected AudioFormat onConfigure(AudioFormat inputAudioFormat)\n      throws UnhandledAudioFormatException {\n    if (inputAudioFormat.encoding != C.ENCODING_PCM_16BIT) {\n      throw new UnhandledAudioFormatException(inputAudioFormat);\n    }\n    @Nullable\n    ChannelMixingMatrix channelMixingMatrix =\n        matrixByInputChannelCount.get(inputAudioFormat.channelCount);\n    if (channelMixingMatrix == null) {\n      throw new UnhandledAudioFormatException(\n          \"No mixing matrix for input channel count\", inputAudioFormat);\n    }\n    if (channelMixingMatrix.isIdentity()) {\n      return AudioFormat.NOT_SET;\n    }\n    return new AudioFormat(\n        inputAudioFormat.sampleRate,\n        channelMixingMatrix.getOutputChannelCount(),\n        C.ENCODING_PCM_16BIT);\n  }\n\n  @Override","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/google/ExoPlayer/blob/dd430f7053a1a3958deea3ead6a0565150c06bfc/library/common/src/main/java/com/google/android/exoplayer2/audio/ChannelMixingAudioProcessor.java#L42-L78","documentation":"ChannelMixingAudioProcessor.onConfigure throws AudioProcessor.UnhandledAudioFormatException when the incoming encoding is anything other than C.ENCODING_PCM_16BIT. The processor performs matrix mixing on 16-bit PCM only, so any other encoding (8-bit, 24-bit, 32-bit integer, float, or encodings like AC3 passthrough) is rejected at configure time before any audio is queued.","triggerScenarios":"Calling channelMixingAudioProcessor.configure(format) (directly or via an AudioProcessingPipeline) with encoding != C.ENCODING_PCM_16BIT — e.g. ENCODING_PCM_FLOAT from an Ogg/Opus decoder or ENCODING_PCM_24BIT from high-resolution FLAC.","commonSituations":"Building a custom DefaultAudioSink processor chain that includes channel mixing while the source outputs float or 24-bit PCM; enabling an equalizer/mixing DSP for lossless content; device default audio format changes after Bluetooth route switching.","solutions":["Place ToInt16PcmAudioProcessor (or set the sink's float/pcm output to 16-bit) before the ChannelMixingAudioProcessor so it receives ENCODING_PCM_16BIT.","Configure the decoder (e.g. DefaultRenderersFactory setEnableDecoderFloatOutput(false)) so PCM output is 16-bit.","Catch UnhandledAudioFormatException and fall back to a chain without channel mixing for unsupported encodings."],"exampleFix":"// before\nChannelMixingAudioProcessor mixer = new ChannelMixingAudioProcessor();\nmixer.configure(new AudioFormat(48000, 2, C.ENCODING_PCM_FLOAT)); // throws\n\n// after\nToInt16PcmAudioProcessor to16 = new ToInt16PcmAudioProcessor();\nAudioFormat pcm16 = to16.configure(floatFormat);\nmixer.configure(pcm16);","handlingStrategy":"validation","validationCode":"if (inputFormat.encoding != C.ENCODING_PCM_16BIT) {\n  inputFormat = toInt16Processor.configure(inputFormat); // convert first\n}\nAudioFormat out = channelMixingProcessor.configure(inputFormat);","typeGuard":null,"tryCatchPattern":"try {\n  mixer.configure(inputFormat);\n} catch (AudioProcessor.UnhandledAudioFormatException e) {\n  // Passthrough without mixing\n  mixerDisabled = true;\n}","preventionTips":["Order processor chains so PCM conversion to 16-bit happens before ChannelMixingAudioProcessor.","Disable float decoder output when using 16-bit-only processors.","Log the encoding at configure time to catch format surprises from new devices."],"tags":["exoplayer","media3","audio","channel-mixing","pcm"],"backgroundTag":null,"analyzedSha":"dd430f7053a1a3958deea3ead6a0565150c06bfc","analyzedAt":"2026-08-14T12:22:02.982Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}