{"record":{"id":"b84b216ec03a485d","repo":"DrKLO/Telegram","slug":"invalid-output-encoding-mode-outputmode-for","errorCode":null,"errorMessage":"Invalid output encoding (mode={outputMode}) for: {inputFormat}","messagePattern":"Invalid output encoding \\(mode=(.+?)\\) for: (.+?)","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"TMessagesProj/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java","lineNumber":770,"sourceCode":"        outputEncoding =\n            MimeTypes.getEncoding(checkNotNull(inputFormat.sampleMimeType), inputFormat.codecs);\n        outputChannelConfig = Util.getAudioTrackChannelConfig(inputFormat.channelCount);\n      } else {\n        outputMode = OUTPUT_MODE_PASSTHROUGH;\n        @Nullable\n        Pair<Integer, Integer> encodingAndChannelConfig =\n            audioCapabilities.getEncodingAndChannelConfigForPassthrough(inputFormat);\n        if (encodingAndChannelConfig == null) {\n          throw new ConfigurationException(\n              \"Unable to configure passthrough for: \" + inputFormat, inputFormat);\n        }\n        outputEncoding = encodingAndChannelConfig.first;\n        outputChannelConfig = encodingAndChannelConfig.second;\n      }\n    }\n\n    if (outputEncoding == C.ENCODING_INVALID) {\n      throw new ConfigurationException(\n          \"Invalid output encoding (mode=\" + outputMode + \") for: \" + inputFormat, inputFormat);\n    }\n    if (outputChannelConfig == AudioFormat.CHANNEL_INVALID) {\n      throw new ConfigurationException(\n          \"Invalid output channel config (mode=\" + outputMode + \") for: \" + inputFormat,\n          inputFormat);\n    }\n    int bufferSize =\n        specifiedBufferSize != 0\n            ? specifiedBufferSize\n            : audioTrackBufferSizeProvider.getBufferSizeInBytes(\n                getAudioTrackMinBufferSize(outputSampleRate, outputChannelConfig, outputEncoding),\n                outputEncoding,\n                outputMode,\n                outputPcmFrameSize != C.LENGTH_UNSET ? outputPcmFrameSize : 1,\n                outputSampleRate,\n                inputFormat.bitrate,\n                enableAudioTrackPlaybackParams ? MAX_PLAYBACK_SPEED : DEFAULT_PLAYBACK_SPEED);","sourceCodeStart":752,"sourceCodeEnd":788,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java#L752-L788","documentation":"After passthrough/offload setup, DefaultAudioSink validates that the resolved outputEncoding is not C.ENCODING_INVALID. If it is, it throws ConfigurationException('Invalid output encoding (mode=...) for: ...'), indicating the encoding derived from the format/mime type/codecs (or from passthrough capabilities) resolved to an invalid value the AudioTrack cannot use.","triggerScenarios":"Offload path: MimeTypes.getEncoding(sampleMimeType, codecs) returns ENCODING_INVALID for an unrecognized/offload-incompatible mime+codecs pair. Passthrough path: a non-null capability pair whose first element is ENCODING_INVALID. Any path leaving outputEncoding unset to the invalid sentinel.","commonSituations":"Format carries a sampleMimeType not mapped to a known C.ENCODING_* constant; codecs attribute parsing fails to resolve; enabling offload for a codec the platform does not recognize.","solutions":["Set a supported sampleMimeType (and codecs string) on the Format so MimeTypes.getEncoding resolves to a valid encoding.","Disable offload/passthrough and decode to PCM if the format's encoding cannot be resolved.","Check MimeTypes.getEncoding(...) for the format's mime/codecs before configuring the sink."],"exampleFix":"// before\nformat = new Format.Builder().setSampleMimeType(\"audio/unknown\").build();\n\n// after\nformat = new Format.Builder().setSampleMimeType(MimeTypes.AUDIO_AC4).build();","handlingStrategy":"validation","validationCode":"// confirm the encoding resolves before configuring the sink\nint enc = MimeTypes.getEncoding(format.sampleMimeType, format.codecs);\nif (enc == C.ENCODING_INVALID) { /* fix Format mime/codecs or disable offload */ }","typeGuard":null,"tryCatchPattern":"try { sink.configure(format, false, attrs); }\ncatch (AudioSink.ConfigurationException e) { /* fall back to PCM decode */ }","preventionTips":["Always set a known sampleMimeType on Format objects.","Avoid enabling offload for codecs the platform does not recognize.","Validate MimeTypes.getEncoding output during format construction."],"tags":["audio","exoplayer","encoding","offload","configuration","format-validation"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}