{"record":{"id":"7a6a0501d9ba875b","repo":"DrKLO/Telegram","slug":"unhandled-format-inputaudioformat","errorCode":null,"errorMessage":"Unhandled format: {inputAudioFormat}","messagePattern":"Unhandled format: (.+?)","errorType":"exception","errorClass":"UnhandledAudioFormatException","httpStatus":null,"severity":"warning","filePath":"TMessagesProj/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java","lineNumber":57,"sourceCode":"   *\n   * @param outputChannels The mapping from input to output channel indices, or {@code null} to\n   *     leave the input unchanged.\n   */\n  public void setChannelMap(@Nullable int[] outputChannels) {\n    pendingOutputChannels = outputChannels;\n  }\n\n  @Override\n  @CanIgnoreReturnValue\n  public AudioFormat onConfigure(AudioFormat inputAudioFormat)\n      throws UnhandledAudioFormatException {\n    @Nullable int[] outputChannels = pendingOutputChannels;\n    if (outputChannels == null) {\n      return AudioFormat.NOT_SET;\n    }\n\n    if (inputAudioFormat.encoding != C.ENCODING_PCM_16BIT) {\n      throw new UnhandledAudioFormatException(inputAudioFormat);\n    }\n\n    boolean active = inputAudioFormat.channelCount != outputChannels.length;\n    for (int i = 0; i < outputChannels.length; i++) {\n      int channelIndex = outputChannels[i];\n      if (channelIndex >= inputAudioFormat.channelCount) {\n        throw new UnhandledAudioFormatException(inputAudioFormat);\n      }\n      active |= (channelIndex != i);\n    }\n    return active\n        ? new AudioFormat(inputAudioFormat.sampleRate, outputChannels.length, C.ENCODING_PCM_16BIT)\n        : AudioFormat.NOT_SET;\n  }\n\n  @Override\n  public void queueInput(ByteBuffer inputBuffer) {\n    int[] outputChannels = Assertions.checkNotNull(this.outputChannels);","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java#L39-L75","documentation":"ChannelMappingAudioProcessor.onConfigure throws UnhandledAudioFormatException when the input audio encoding is not C.ENCODING_PCM_16BIT. This processor performs channel remapping (reordering/selecting channels) on 16-bit PCM only; any other encoding (8-bit, 24-bit, 32-bit int, float, compressed) is not handled and is rejected at configuration time so the pipeline can decide whether to skip the processor or fail playback.","triggerScenarios":"Feeding audio whose decoded PCM encoding is anything other than 16-bit (e.g. ENCODING_PCM_FLOAT from a float decoder, ENCODING_PCM_24BIT/32BIT hi-res source) into a ChannelMappingAudioProcessor that has pending output channels configured.","commonSituations":"Hi-res audio sources (24/32-bit PCM) routed through a default audio chain that includes channel mapping; enabling channel mapping on a device path where the decoder outputs float PCM; mismatch between source encoding and processor expectations after a format change mid-stream.","solutions":["Insert a ResamplingAudioProcessor or FloatResamplingAudioProcessor upstream to convert the input to 16-bit PCM before the ChannelMappingAudioProcessor.","Only enable channel mapping (setOutputChannels) when the source is known to be 16-bit PCM; disable it otherwise (leave pendingOutputChannels null so onConfigure returns NOT_SET and the processor is bypassed).","If the source may be hi-res, prefer an audio sink that accepts the native encoding and do remapping after a format the sink supports."],"exampleFix":"// before: channel mapping always configured\nchannelMappingProcessor.setOutputChannels(new int[]{1, 0}); // applies to any encoding\n// source is 24-bit PCM -> onConfigure throws UnhandledAudioFormatException\n// after: only enable when source is 16-bit, else bypass\nif (inputAudioFormat.encoding == C.ENCODING_PCM_16BIT) {\n  channelMappingProcessor.setOutputChannels(new int[]{1, 0});\n} else {\n  channelMappingProcessor.setOutputChannels(null); // bypass\n}","handlingStrategy":"validation","validationCode":"if (inputAudioFormat.encoding == C.ENCODING_PCM_16BIT) {\n  channelMappingProcessor.setOutputChannels(map);\n} else {\n  channelMappingProcessor.setOutputChannels(null); // bypass\n}","typeGuard":null,"tryCatchPattern":"try {\n  channelMappingProcessor.onConfigure(inputAudioFormat);\n} catch (UnhandledAudioFormatException e) {\n  // not 16-bit; route through resampler first or bypass\n}","preventionTips":["Only enable channel mapping when the source is 16-bit PCM.","Insert a resampler upstream to normalize to 16-bit before channel processors.","Reset pendingOutputChannels to null on format changes."],"tags":["exoplayer","audio","pcm","channel-mapping","encoding"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}