{"record":{"id":"d489b65e64e9f3f8","repo":"DrKLO/Telegram","slug":"unhandled-format-inputaudioformat-d489b6","errorCode":null,"errorMessage":"Unhandled format: {inputAudioFormat}","messagePattern":"Unhandled format: (.+?)","errorType":"exception","errorClass":"UnhandledAudioFormatException","httpStatus":null,"severity":"error","filePath":"TMessagesProj/src/main/java/com/google/android/exoplayer2/audio/TrimmingAudioProcessor.java","lineNumber":76,"sourceCode":"\n  /** Sets the trimmed frame count returned by {@link #getTrimmedFrameCount()} to zero. */\n  public void resetTrimmedFrameCount() {\n    trimmedFrameCount = 0;\n  }\n\n  /**\n   * Returns the number of audio frames trimmed since the last call to {@link\n   * #resetTrimmedFrameCount()}.\n   */\n  public long getTrimmedFrameCount() {\n    return trimmedFrameCount;\n  }\n\n  @Override\n  public AudioFormat onConfigure(AudioFormat inputAudioFormat)\n      throws UnhandledAudioFormatException {\n    if (inputAudioFormat.encoding != OUTPUT_ENCODING) {\n      throw new UnhandledAudioFormatException(inputAudioFormat);\n    }\n    reconfigurationPending = true;\n    return trimStartFrames != 0 || trimEndFrames != 0 ? inputAudioFormat : AudioFormat.NOT_SET;\n  }\n\n  @Override\n  public void queueInput(ByteBuffer inputBuffer) {\n    int position = inputBuffer.position();\n    int limit = inputBuffer.limit();\n    int remaining = limit - position;\n\n    if (remaining == 0) {\n      return;\n    }\n\n    // Trim any pending start bytes from the input buffer.\n    int trimBytes = min(remaining, pendingTrimStartBytes);\n    trimmedFrameCount += trimBytes / inputAudioFormat.bytesPerFrame;","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/com/google/android/exoplayer2/audio/TrimmingAudioProcessor.java#L58-L94","documentation":"TrimmingAudioProcessor.onConfigure rejects any input AudioFormat whose encoding is not the processor's OUTPUT_ENCODING (16-bit PCM). It throws UnhandledAudioFormatException to signal that the processor can only be inserted into a PCM-16-bit audio pipeline. The check happens before any reconfiguration is applied, so the processor never silently drops data of an incompatible type.","triggerScenarios":"Inserting TrimmingAudioProcessor into an audio chain whose upstream delivers a non-PCM-16BIT encoding (e.g. ENCODING_PCM_FLOAT, ENCODING_PCM_24BIT, or a passthrough/offload encoding). The mismatch is detected when the audio sink calls onConfigure during format setup.","commonSituations":"Applying trim to float or 24/32-bit PCM output; chaining the trimmer after another processor that converted PCM to float; enabling audio offload so the encoding reaching the processor is not 16-bit.","solutions":["Feed only 16-bit PCM audio into TrimmingAudioProcessor, or insert a format-converting processor upstream so the encoding reaching it is ENCODING_PCM_16BIT.","Verify the input AudioFormat.encoding equals the processor's OUTPUT_ENCODING before adding the processor to the AudioProcessor chain.","Skip trimming when the pipeline uses float/high-bit-depth PCM and trim is not strictly required."],"exampleFix":"// before\nsink.addAudioProcessor(trimmingProcessor); // fed by a PCM_FLOAT chain\n\n// after\nif (inputAudioFormat.encoding == AudioFormat.ENCODING_PCM_16BIT) {\n  sink.addAudioProcessor(trimmingProcessor);\n}","handlingStrategy":"validation","validationCode":"// before adding TrimmingAudioProcessor to the chain\nAudioFormat in = /* upstream output format */;\nif (in.encoding == TrimmingAudioProcessor.OUTPUT_ENCODING /* ENCODING_PCM_16BIT */) {\n  chain.add(trimmingProcessor);\n}","typeGuard":"// n/a: encoding is an int constant; guard by equality check, not a type guard\nstatic boolean canTrim(AudioFormat f) {\n  return f != null && f.encoding == AudioFormat.ENCODING_PCM_16BIT;\n}","tryCatchPattern":"try { processor.onConfigure(inputAudioFormat); }\ncatch (UnhandledAudioFormatException e) { /* skip this processor or convert PCM to 16-bit upstream */ }","preventionTips":["Always feed 16-bit PCM into TrimmingAudioProcessor.","Insert a PCM-format-converting processor upstream when the chain uses float/high-bit-depth audio.","Unit-test the processor chain with each encoding you intend to support."],"tags":["audio","exoplayer","audio-processor","encoding-mismatch","format-validation"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}