DrKLO/Telegram · error · ConfigurationException
Invalid output encoding (mode={outputMode}) for: {inputForma
Error message
Invalid output encoding (mode={outputMode}) for: {inputFormat} What it means
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.
Source
Thrown at TMessagesProj/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java:770
outputEncoding =
MimeTypes.getEncoding(checkNotNull(inputFormat.sampleMimeType), inputFormat.codecs);
outputChannelConfig = Util.getAudioTrackChannelConfig(inputFormat.channelCount);
} else {
outputMode = OUTPUT_MODE_PASSTHROUGH;
@Nullable
Pair<Integer, Integer> encodingAndChannelConfig =
audioCapabilities.getEncodingAndChannelConfigForPassthrough(inputFormat);
if (encodingAndChannelConfig == null) {
throw new ConfigurationException(
"Unable to configure passthrough for: " + inputFormat, inputFormat);
}
outputEncoding = encodingAndChannelConfig.first;
outputChannelConfig = encodingAndChannelConfig.second;
}
}
if (outputEncoding == C.ENCODING_INVALID) {
throw new ConfigurationException(
"Invalid output encoding (mode=" + outputMode + ") for: " + inputFormat, inputFormat);
}
if (outputChannelConfig == AudioFormat.CHANNEL_INVALID) {
throw new ConfigurationException(
"Invalid output channel config (mode=" + outputMode + ") for: " + inputFormat,
inputFormat);
}
int bufferSize =
specifiedBufferSize != 0
? specifiedBufferSize
: audioTrackBufferSizeProvider.getBufferSizeInBytes(
getAudioTrackMinBufferSize(outputSampleRate, outputChannelConfig, outputEncoding),
outputEncoding,
outputMode,
outputPcmFrameSize != C.LENGTH_UNSET ? outputPcmFrameSize : 1,
outputSampleRate,
inputFormat.bitrate,
enableAudioTrackPlaybackParams ? MAX_PLAYBACK_SPEED : DEFAULT_PLAYBACK_SPEED);View on GitHub (pinned to 45ab8f4308)
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.
Example fix
// before
format = new Format.Builder().setSampleMimeType("audio/unknown").build();
// after
format = new Format.Builder().setSampleMimeType(MimeTypes.AUDIO_AC4).build(); Defensive patterns
Strategy: validation
Validate before calling
// confirm the encoding resolves before configuring the sink
int enc = MimeTypes.getEncoding(format.sampleMimeType, format.codecs);
if (enc == C.ENCODING_INVALID) { /* fix Format mime/codecs or disable offload */ } Try / catch
try { sink.configure(format, false, attrs); }
catch (AudioSink.ConfigurationException e) { /* fall back to PCM decode */ } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid output channel config (mode={outputMode}) for: {inpu
- Invalid sample rate or number of channels: {sampleRate}, {ch
- Unhandled format: {inputAudioFormat}
- Unhandled format: {inputAudioFormat}
- Unhandled format: {inputAudioFormat}
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/b84b216ec03a485d.
Report an issue: GitHub.