google/ExoPlayer · error · UnhandledAudioFormatException
No mixing matrix for input channel count {audioFormat}
Error message
No mixing matrix for input channel count {audioFormat} What it means
ChannelMixingAudioProcessor looks up a ChannelMixingMatrix by input channel count in matrixByInputChannelCount. If none was registered for that count, onConfigure throws UnhandledAudioFormatException with 'No mixing matrix for input channel count' plus the format. The processor ships with no default matrices: you must call putChannelMixingMatrix(...) for every input channel count you intend to accept.
Source
Thrown at library/common/src/main/java/com/google/android/exoplayer2/audio/ChannelMixingAudioProcessor.java:66
* ChannelMixingMatrix#getInputChannelCount() channel count}. Overwrites any previously stored
* matrix for the same input channel count.
*/
public void putChannelMixingMatrix(ChannelMixingMatrix matrix) {
int inputChannelCount = matrix.getInputChannelCount();
matrixByInputChannelCount.put(inputChannelCount, matrix);
}
@Override
protected AudioFormat onConfigure(AudioFormat inputAudioFormat)
throws UnhandledAudioFormatException {
if (inputAudioFormat.encoding != C.ENCODING_PCM_16BIT) {
throw new UnhandledAudioFormatException(inputAudioFormat);
}
@Nullable
ChannelMixingMatrix channelMixingMatrix =
matrixByInputChannelCount.get(inputAudioFormat.channelCount);
if (channelMixingMatrix == null) {
throw new UnhandledAudioFormatException(
"No mixing matrix for input channel count", inputAudioFormat);
}
if (channelMixingMatrix.isIdentity()) {
return AudioFormat.NOT_SET;
}
return new AudioFormat(
inputAudioFormat.sampleRate,
channelMixingMatrix.getOutputChannelCount(),
C.ENCODING_PCM_16BIT);
}
@Override
public void queueInput(ByteBuffer inputBuffer) {
ChannelMixingMatrix channelMixingMatrix =
checkStateNotNull(matrixByInputChannelCount.get(inputAudioFormat.channelCount));
int inputFramesToMix = inputBuffer.remaining() / inputAudioFormat.bytesPerFrame;
ByteBuffer outputBuffer =View on GitHub (pinned to dd430f7053)
Solutions
- Pre-register matrices for every channel count your app can encounter: for (int ch = 1; ch <= 8; ch++) mixer.putChannelMixingMatrix(ChannelMixingMatrix.create(ch, targetChannels));
- Register ChannelMixingMatrix.create(inputChannels, inputChannels) (identity) as a safe default for counts you do not actually want to remix.
- Catch UnhandledAudioFormatException at configure time to skip mixing for unexpected channel counts.
Example fix
// before
mixer.putChannelMixingMatrix(ChannelMixingMatrix.create(2, 1));
// 6-channel input -> UnhandledAudioFormatException
// after
for (int ch = 1; ch <= 8; ch++) {
mixer.putChannelMixingMatrix(ch == 2
? ChannelMixingMatrix.create(2, 1)
: ChannelMixingMatrix.create(ch, ch)); // identity passthrough
} Defensive patterns
Strategy: validation
Validate before calling
boolean hasMatrix = false;
for (int ch = 1; ch <= 8; ch++) {
if (ch == inputFormat.channelCount) { hasMatrix = true; break; }
}
if (!hasMatrix) mixer.putChannelMixingMatrix(
ChannelMixingMatrix.create(inputFormat.channelCount, inputFormat.channelCount)); Try / catch
try {
mixer.configure(inputFormat);
} catch (AudioProcessor.UnhandledAudioFormatException e) {
if (e.getMessage() != null && e.getMessage().contains("mixing matrix")) {
mixer.putChannelMixingMatrix(
ChannelMixingMatrix.create(
inputFormat.channelCount, inputFormat.channelCount));
mixer.configure(inputFormat);
} else {
throw e;
}
} Prevention
- Register matrices for every channel count your app can play (1 through 8 is a safe range).
- Register identity matrices as harmless defaults for counts you do not want to remix.
- Unit-test configure() with mono, stereo, 5.1 and 8-channel fixtures.
When it happens
Trigger: Calling putChannelMixingMatrix(ChannelMixingMatrix.create(2, 1)) (stereo-to-mono only) and then playing 6-channel (5.1) content, or forgetting to register any matrix at all before configure().
Common situations: App registers stereo-only mixing and the user plays multichannel audio (5.1 AAC, 8-channel WAV); device audio framework hands a different channel count after route changes; unit tests using mono fixtures while production registers stereo matrices.
Related errors
- Unhandled input format: {audioFormat}
- Default channel mixing coefficients for {inputChannelCount}-
- Coefficient at index {i} is negative.
- Unhandled input format: ${audioFormat}
- Unhandled input format: {audioFormat}
AI-assisted analysis of google/ExoPlayer@dd430f7053 (2026-08-14).
Data as JSON: /api/errors/ddba0b3e278f765d.
Report an issue: GitHub.