DrKLO/Telegram · error · ConfigurationException

Unable to configure passthrough for: {inputFormat}

Error message

Unable to configure passthrough for: {inputFormat}

What it means

DefaultAudioSink throws ConfigurationException('Unable to configure passthrough for: ...') when, in OUTPUT_MODE_PASSTHROUGH, audioCapabilities.getEncodingAndChannelConfigForPassthrough(inputFormat) returns null — i.e. the device's reported audio capabilities do not support passing the given format through to the platform AudioTrack untouched. Passthrough requires the device to natively decode/handle that encoding.

Source

Thrown at TMessagesProj/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java:761

      outputChannelConfig = Util.getAudioTrackChannelConfig(outputFormat.channelCount);
      outputPcmFrameSize = Util.getPcmFrameSize(outputEncoding, outputFormat.channelCount);
    } else {
      inputPcmFrameSize = C.LENGTH_UNSET;
      availableAudioProcessors = new AudioProcessor[0];
      outputSampleRate = inputFormat.sampleRate;
      outputPcmFrameSize = C.LENGTH_UNSET;
      if (useOffloadedPlayback(inputFormat, audioAttributes)) {
        outputMode = OUTPUT_MODE_OFFLOAD;
        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

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Confirm the target device actually advertises the encoding via AudioManager/AudioCapabilities before requesting passthrough.
  2. Fall back to decoded PCM playback (disable passthrough/offload) when capabilities do not include the required encoding.
  3. Correct the Format's sampleMimeType/codecs/channelCount so they match a passthrough-capable encoding on the device.

Example fix

// before
sink = new DefaultAudioSink(...); // passthrough enabled by default for surround

// after
DefaultAudioSink sink = new DefaultAudioSink.Builder(context)
    .setEnableAudioTrackPlayback(false) // force decode-to-PCM
    .build();
Defensive patterns

Strategy: validation

Validate before calling

// before enabling passthrough, check device capabilities
AudioCapabilities caps = AudioCapabilities.getCapabilities(context);
boolean passthroughOk =
    caps.getEncodingAndChannelConfigForPassthrough(inputFormat) != null;
if (!passthroughOk) { /* disable passthrough, decode to PCM */ }

Try / catch

try { sink.configure(inputFormat, /* isOffload= */ false, /* audioAttrs= */ attrs); }
catch (AudioSink.ConfigurationException e) { /* retry with passthrough/offload disabled */ }

Prevention

When it happens

Trigger: Calling configure() (or starting playback) on a format marked for passthrough (e.g. AC3, E-AC3, DTS, TrueHD) on a device/TV whose AudioCapabilities report no matching encoding, or where the format's channel count exceeds what passthrough supports.

Common situations: Playing surround/AC3 content on a phone or emulator without the codec; HDMI/TV capability negotiation returning an empty set; a malformed Format with a sampleMimeType the device cannot pass through; running on an emulator that lacks passthrough support.

Related errors


AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14). Data as JSON: /api/errors/8c82c70a3f31cdc0. Report an issue: GitHub.