{"record":{"id":"40cc8d3ffe112ad4","repo":"DrKLO/Telegram","slug":"failed-to-initialize-decoder","errorCode":null,"errorMessage":"Failed to initialize decoder","messagePattern":"Failed to initialize decoder","errorType":"exception","errorClass":"FlacDecoderException","httpStatus":null,"severity":"error","filePath":"TMessagesProj/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java","lineNumber":60,"sourceCode":"    }\n  }\n\n  private static final int TEMP_BUFFER_SIZE = 8192; // The same buffer size as libflac.\n\n  private final long nativeDecoderContext;\n\n  @Nullable private ByteBuffer byteBufferData;\n  @Nullable private ExtractorInput extractorInput;\n  @Nullable private byte[] tempBuffer;\n  private boolean endOfExtractorInput;\n\n  public FlacDecoderJni() throws FlacDecoderException {\n    if (!FlacLibrary.isAvailable()) {\n      throw new FlacDecoderException(\"Failed to load decoder native libraries.\");\n    }\n    nativeDecoderContext = flacInit();\n    if (nativeDecoderContext == 0) {\n      throw new FlacDecoderException(\"Failed to initialize decoder\");\n    }\n  }\n\n  /**\n   * Sets the data to be parsed.\n   *\n   * @param byteBufferData Source {@link ByteBuffer}.\n   */\n  public void setData(ByteBuffer byteBufferData) {\n    this.byteBufferData = byteBufferData;\n    this.extractorInput = null;\n  }\n\n  /**\n   * Sets the data to be parsed.\n   *\n   * @param extractorInput Source {@link ExtractorInput}.\n   */","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java#L42-L78","documentation":"After the FLAC libraries load, FlacDecoderJni calls the native flacInit(); if it returns 0 the constructor throws FlacDecoderException('Failed to initialize decoder'), indicating the native FLAC decoder context could not be created despite the libraries being available.","triggerScenarios":"flacInit() returns 0 — typically an internal native allocation/init failure, or a build/version problem in the FLAC JNI library, rather than a data problem (no stream data has been supplied yet at construction time).","commonSituations":"A broken or ABI-mismatched FLAC native library that loads but fails to allocate its decoder context; memory pressure during native init; a custom/patched FLAC build with an init bug.","solutions":["Rebuild/repackage the FLAC extension native libraries for the correct ABI and library version.","Fall back to the platform MediaCodec FLAC decoder when FlacDecoderJni construction fails.","Check for native memory limits / low-memory conditions on the device."],"exampleFix":"// before\ntry { jni = new FlacDecoderJni(); }\ncatch (FlacDecoderException e) { /* unhandled crash */ }\n\n// after\ntry { jni = new FlacDecoderJni(); }\ncatch (FlacDecoderException e) { usePlatformFlacDecoder(); }","handlingStrategy":"try-catch","validationCode":"// n/a: failure is internal to native init; no caller-side precondition to check beyond lib availability\n// ensure FlacLibrary.isAvailable() first (see error 75)","typeGuard":null,"tryCatchPattern":"try { new FlacDecoderJni(); }\ncatch (FlacDecoderException e) { /* rebuild libs or fall back to platform FLAC */ }","preventionTips":["Use a correctly built FLAC native library matching the device ABI.","Implement a platform FLAC decoder fallback.","Watch for low-memory conditions during native init."],"tags":["audio","exoplayer","flac","native-library","codec-init","jni"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}