{"record":{"id":"1be7aa5b310b02f7","repo":"DrKLO/Telegram","slug":"failed-to-decode-streaminfo","errorCode":null,"errorMessage":"Failed to decode StreamInfo","messagePattern":"Failed to decode StreamInfo","errorType":"exception","errorClass":"FlacDecoderException","httpStatus":null,"severity":"error","filePath":"TMessagesProj/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoder.java","lineNumber":67,"sourceCode":"   *     which is the flac file header.\n   * @throws FlacDecoderException Thrown if an exception occurs when initializing the decoder.\n   */\n  public FlacDecoder(\n      int numInputBuffers,\n      int numOutputBuffers,\n      int maxInputBufferSize,\n      List<byte[]> initializationData)\n      throws FlacDecoderException {\n    super(new DecoderInputBuffer[numInputBuffers], new SimpleDecoderOutputBuffer[numOutputBuffers]);\n    if (initializationData.size() != 1) {\n      throw new FlacDecoderException(\"Initialization data must be of length 1\");\n    }\n    decoderJni = new FlacDecoderJni();\n    decoderJni.setData(ByteBuffer.wrap(initializationData.get(0)));\n    try {\n      streamMetadata = decoderJni.decodeStreamMetadata();\n    } catch (ParserException e) {\n      throw new FlacDecoderException(\"Failed to decode StreamInfo\", e);\n    } catch (IOException e) {\n      // Never happens.\n      throw new IllegalStateException(e);\n    }\n\n    int initialInputBufferSize =\n        maxInputBufferSize != Format.NO_VALUE ? maxInputBufferSize : streamMetadata.maxFrameSize;\n    setInitialInputBufferSize(initialInputBufferSize);\n  }\n\n  @Override\n  public String getName() {\n    return \"libflac\";\n  }\n\n  @Override\n  protected DecoderInputBuffer createInputBuffer() {\n    return new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_NORMAL);","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoder.java#L49-L85","documentation":"FlacDecoder wraps a ParserException from decoderJni.decodeStreamMetadata() as FlacDecoderException('Failed to decode StreamInfo'). The native FLAC parser could not read a valid STREAMINFO metadata block from the provided header data, so stream parameters (sample rate, channels, frame size) are unknown and decoding cannot continue.","triggerScenarios":"The single initializationData entry is present but does not contain a parseable FLAC STREAMINFO block; the header is truncated, corrupt, or not actually FLAC.","commonSituations":"Corrupt/truncated FLAC header in the initializationData; misidentified media (non-FLAC bytes passed as FLAC); a remuxed stream whose header was altered; native library version mismatch in metadata parsing.","solutions":["Re-extract or re-derive the FLAC header so it contains a valid STREAMINFO block before instantiating the decoder.","Verify the source media is genuinely FLAC (magic bytes 'fLaC') and not mislabeled.","Fall back to the platform FLAC decoder or skip the track."],"exampleFix":"// before\ninit = Collections.singletonList(truncatedHeader);\n\n// after\nList<byte[]> init = extractor.getInitializationData(); // guaranteed valid STREAMINFO\nnew FlacDecoder(nIn, nOut, maxIn, init);","handlingStrategy":"try-catch","validationCode":"// sanity-check the header before constructing\nbyte[] header = initializationData.get(0);\nboolean looksFlac = header != null && header.length >= 4\n    && header[0]=='f' && header[1]=='L' && header[2]=='a' && header[3]=='C';\nif (!looksFlac) { /* re-extract header or skip */ }","typeGuard":null,"tryCatchPattern":"try { new FlacDecoder(nIn, nOut, maxIn, init); }\ncatch (FlacDecoderException e) { /* fall back to platform FLAC or skip track */ }","preventionTips":["Confirm the source is genuine FLAC ('fLaC' magic).","Re-extract a valid STREAMINFO header rather than passing truncated data.","Provide a platform FLAC fallback."],"tags":["audio","exoplayer","flac","parser","streaminfo","corrupt-data"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}