DrKLO/Telegram · warning · UnhandledAudioFormatException
Unhandled format: {inputAudioFormat}
Error message
Unhandled format: {inputAudioFormat} What it means
ChannelMappingAudioProcessor.onConfigure throws UnhandledAudioFormatException when the input audio encoding is not C.ENCODING_PCM_16BIT. This processor performs channel remapping (reordering/selecting channels) on 16-bit PCM only; any other encoding (8-bit, 24-bit, 32-bit int, float, compressed) is not handled and is rejected at configuration time so the pipeline can decide whether to skip the processor or fail playback.
Source
Thrown at TMessagesProj/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java:57
*
* @param outputChannels The mapping from input to output channel indices, or {@code null} to
* leave the input unchanged.
*/
public void setChannelMap(@Nullable int[] outputChannels) {
pendingOutputChannels = outputChannels;
}
@Override
@CanIgnoreReturnValue
public AudioFormat onConfigure(AudioFormat inputAudioFormat)
throws UnhandledAudioFormatException {
@Nullable int[] outputChannels = pendingOutputChannels;
if (outputChannels == null) {
return AudioFormat.NOT_SET;
}
if (inputAudioFormat.encoding != C.ENCODING_PCM_16BIT) {
throw new UnhandledAudioFormatException(inputAudioFormat);
}
boolean active = inputAudioFormat.channelCount != outputChannels.length;
for (int i = 0; i < outputChannels.length; i++) {
int channelIndex = outputChannels[i];
if (channelIndex >= inputAudioFormat.channelCount) {
throw new UnhandledAudioFormatException(inputAudioFormat);
}
active |= (channelIndex != i);
}
return active
? new AudioFormat(inputAudioFormat.sampleRate, outputChannels.length, C.ENCODING_PCM_16BIT)
: AudioFormat.NOT_SET;
}
@Override
public void queueInput(ByteBuffer inputBuffer) {
int[] outputChannels = Assertions.checkNotNull(this.outputChannels);View on GitHub (pinned to 45ab8f4308)
Solutions
- Insert a ResamplingAudioProcessor or FloatResamplingAudioProcessor upstream to convert the input to 16-bit PCM before the ChannelMappingAudioProcessor.
- Only enable channel mapping (setOutputChannels) when the source is known to be 16-bit PCM; disable it otherwise (leave pendingOutputChannels null so onConfigure returns NOT_SET and the processor is bypassed).
- If the source may be hi-res, prefer an audio sink that accepts the native encoding and do remapping after a format the sink supports.
Example fix
// before: channel mapping always configured
channelMappingProcessor.setOutputChannels(new int[]{1, 0}); // applies to any encoding
// source is 24-bit PCM -> onConfigure throws UnhandledAudioFormatException
// after: only enable when source is 16-bit, else bypass
if (inputAudioFormat.encoding == C.ENCODING_PCM_16BIT) {
channelMappingProcessor.setOutputChannels(new int[]{1, 0});
} else {
channelMappingProcessor.setOutputChannels(null); // bypass
} Defensive patterns
Strategy: validation
Validate before calling
if (inputAudioFormat.encoding == C.ENCODING_PCM_16BIT) {
channelMappingProcessor.setOutputChannels(map);
} else {
channelMappingProcessor.setOutputChannels(null); // bypass
} Try / catch
try {
channelMappingProcessor.onConfigure(inputAudioFormat);
} catch (UnhandledAudioFormatException e) {
// not 16-bit; route through resampler first or bypass
} Prevention
- Only enable channel mapping when the source is 16-bit PCM.
- Insert a resampler upstream to normalize to 16-bit before channel processors.
- Reset pendingOutputChannels to null on format changes.
When it happens
Trigger: Feeding audio whose decoded PCM encoding is anything other than 16-bit (e.g. ENCODING_PCM_FLOAT from a float decoder, ENCODING_PCM_24BIT/32BIT hi-res source) into a ChannelMappingAudioProcessor that has pending output channels configured.
Common situations: Hi-res audio sources (24/32-bit PCM) routed through a default audio chain that includes channel mapping; enabling channel mapping on a device path where the decoder outputs float PCM; mismatch between source encoding and processor expectations after a format change mid-stream.
Related errors
- Unhandled format: {inputAudioFormat}
- Unhandled format: {inputAudioFormat}
- Unhandled format: {inputAudioFormat}
- Unhandled format: {inputAudioFormat}
- Invalid output encoding (mode={outputMode}) for: {inputForma
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/7a6a0501d9ba875b.
Report an issue: GitHub.