{"record":{"id":"b618431737e180ba","repo":"DrKLO/Telegram","slug":"unhandled-format-inputaudioformat-b61843","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/FloatResamplingAudioProcessor.java","lineNumber":45,"sourceCode":" *\n * <ul>\n *   <li>{@link C#ENCODING_PCM_24BIT}\n *   <li>{@link C#ENCODING_PCM_32BIT}\n *   <li>{@link C#ENCODING_PCM_FLOAT} ({@link #isActive()} will return {@code false})\n * </ul>\n */\n/* package */ final class FloatResamplingAudioProcessor extends BaseAudioProcessor {\n\n  private static final int FLOAT_NAN_AS_INT = Float.floatToIntBits(Float.NaN);\n  private static final double PCM_32_BIT_INT_TO_PCM_32_BIT_FLOAT_FACTOR = 1.0 / 0x7FFFFFFF;\n\n  @Override\n  @CanIgnoreReturnValue\n  public AudioFormat onConfigure(AudioFormat inputAudioFormat)\n      throws UnhandledAudioFormatException {\n    @C.PcmEncoding int encoding = inputAudioFormat.encoding;\n    if (!Util.isEncodingHighResolutionPcm(encoding)) {\n      throw new UnhandledAudioFormatException(inputAudioFormat);\n    }\n    return encoding != C.ENCODING_PCM_FLOAT\n        ? new AudioFormat(\n            inputAudioFormat.sampleRate, inputAudioFormat.channelCount, C.ENCODING_PCM_FLOAT)\n        : 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 size = limit - position;\n\n    ByteBuffer buffer;\n    switch (inputAudioFormat.encoding) {\n      case C.ENCODING_PCM_24BIT:\n        buffer = replaceOutputBuffer((size / 3) * 4);\n        for (int i = position; i < limit; i += 3) {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/com/google/android/exoplayer2/audio/FloatResamplingAudioProcessor.java#L27-L63","documentation":"FloatResamplingAudioProcessor.onConfigure throws UnhandledAudioFormatException when the input encoding is not 'high resolution PCM' (Util.isEncodingHighResolutionPcm returns false). This processor specifically converts higher-than-16-bit integer PCM (24-bit, 32-bit int) to 32-bit float; it does not handle 8-bit, 16-bit, float, or compressed encodings. 16-bit and float inputs are not 'high resolution' and are rejected so the pipeline can route them elsewhere (16-bit needs no resampling; float is already float).","triggerScenarios":"Feeding 16-bit PCM, 8-bit PCM, or already-float PCM into FloatResamplingAudioProcessor; a pipeline that always inserts this processor regardless of source encoding; a format change mid-playback dropping below the hi-res threshold.","commonSituations":"Default audio chain that includes float resampling but plays a standard 16-bit track; toggling output to float on a stereo 16-bit source; source switch from 24-bit FLAC to 16-bit MP3 without disabling the resampler.","solutions":["Only insert FloatResamplingAudioProcessor in the chain when the source encoding is ENCODING_PCM_24BIT or ENCODING_PCM_32BIT (high-resolution integer PCM).","For sources that may be mixed, guard insertion: if inputAudioFormat is hi-res PCM include it, otherwise omit it.","Configure the audio sink (DefaultAudioSink) to negotiate the right chain; the sink will skip processors whose onConfigure throws UnhandledAudioFormatException if they report NOT_SET appropriately — ensure the processor is only active for hi-res."],"exampleFix":"// before: always added\nList<AudioProcessor> chain = List.of(floatResamplingProcessor); // throws on 16-bit input\n// after: conditionally include\nList<AudioProcessor> chain = new ArrayList<>();\nif (Util.isEncodingHighResolutionPcm(inputAudioFormat.encoding)\n    && inputAudioFormat.encoding != C.ENCODING_PCM_FLOAT) {\n  chain.add(floatResamplingProcessor);\n}","handlingStrategy":"validation","validationCode":"@C.Encoding int enc = inputAudioFormat.encoding;\nboolean needsFloatResample = Util.isEncodingHighResolutionPcm(enc)\n    && enc != C.ENCODING_PCM_FLOAT;\n// only add FloatResamplingAudioProcessor when needsFloatResample is true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only insert FloatResamplingAudioProcessor for 24/32-bit integer PCM sources.","Let the AudioSink negotiate the processor chain based on the active format.","Disable float resampling when source is 16-bit or already float."],"tags":["exoplayer","audio","pcm","resampling","encoding","hi-res"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}