google/ExoPlayer · error · AudioSink.ConfigurationException

Invalid output channel config (mode=%s) for: %s

Error message

Invalid output channel config (mode=%s) for: %s

What it means

DefaultAudioSink validates the resolved AudioTrack channel configuration after picking an output mode. If outputChannelConfig is AudioFormat.CHANNEL_INVALID — the channel layout implied by the format (e.g. Util.getAudioTrackChannelConfig of the channel count) has no Android AudioFormat equivalent (channel counts Android cannot map, like some raw counts for compressed or unusual layouts) — ConfigurationException('Invalid output channel config (mode=...) for: <format>') is thrown.

Source

Thrown at library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java:731

            getAudioCapabilities().getEncodingAndChannelConfigForPassthrough(inputFormat);
        if (encodingAndChannelConfig == null) {
          throw new ConfigurationException(
              "Unable to configure passthrough for: " + inputFormat, inputFormat);
        }
        outputEncoding = encodingAndChannelConfig.first;
        outputChannelConfig = encodingAndChannelConfig.second;
        // Passthrough only supports AudioTrack playback parameters, but we only enable it this was
        // specifically requested by the app.
        enableAudioTrackPlaybackParams = preferAudioTrackPlaybackParams;
      }
    }

    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);

    offloadDisabledUntilNextConfiguration = false;
    Configuration pendingConfiguration =
        new Configuration(

View on GitHub (pinned to dd430f7053)

Solutions

  1. Fall back to PCM decode mode for that format (disable offload/passthrough), where channel config derives safely from channel count.
  2. Check Util.getAudioTrackChannelConfig(format.channelCount) != AudioFormat.CHANNEL_INVALID before enabling offload/passthrough for an item.
  3. Catch ConfigurationException and retry with a DefaultAudioSink built with OFFLOAD_MODE_DISABLED and no passthrough.
  4. Verify the manifest/container channelCount matches the actual stream (mis-declared 0 or negative counts cause this).

Example fix

// before
if (shouldOffload) sinkBuilder.setOffloadMode(OFFLOAD_MODE_ENABLED_ALWAYS);

// after — gate offload on a mappable channel configuration
boolean channelOk = Util.getAudioTrackChannelConfig(format.channelCount)
    != AudioFormat.CHANNEL_INVALID;
sinkBuilder.setOffloadMode(
    shouldOffload && channelOk
        ? DefaultAudioSink.OFFLOAD_MODE_ENABLED_ALWAYS
        : DefaultAudioSink.OFFLOAD_MODE_DISABLED);
Defensive patterns

Strategy: validation

Validate before calling

boolean channelConfigValid =
    Util.getAudioTrackChannelConfig(format.channelCount)
        != AudioFormat.CHANNEL_INVALID;
if (!channelConfigValid) {
  // avoid offload/passthrough for this item; use PCM mode
}

Try / catch

try {
  prepareWithMode(item, OFFLOAD);
} catch (PlaybackException e) { // wraps ConfigurationException
  prepareWithMode(item, PCM); // channel config unresolvable in offload
}

Prevention

When it happens

Trigger: Playing a format whose channel count maps to CHANNEL_INVALID for the chosen mode — typically passthrough encodings whose channel layout must be derived from the bitstream, or unusual PCM channel counts — combined with offload/passthrough configuration.

Common situations: Offload enabled for codecs where Android requires a channel mask instead of a count; device firmware returning odd channel masks; streams mislabeling channelCount in their manifests/containers; mixing raw channel counts with AudioFormat.CHANNEL_OUT_* masks in custom sinks.

Related errors


AI-assisted analysis of google/ExoPlayer@dd430f7053 (2026-08-14). Data as JSON: /api/errors/0336f91e56136924. Report an issue: GitHub.