{"record":{"id":"c07962555be001d0","repo":"google/ExoPlayer","slug":"unhandled-input-format-inputaudioformat-c07962","errorCode":null,"errorMessage":"Unhandled input format: {inputAudioFormat}","messagePattern":"Unhandled input format: (.+?)","errorType":"exception","errorClass":"AudioProcessor.UnhandledAudioFormatException","httpStatus":null,"severity":"error","filePath":"library/core/src/main/java/com/google/android/exoplayer2/audio/ToFloatPcmAudioProcessor.java","lineNumber":51,"sourceCode":" *\n * @deprecated com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which\n *     contains the same ExoPlayer code). See <a\n *     href=\"https://developer.android.com/guide/topics/media/media3/getting-started/migration-guide\">the\n *     migration guide</a> for more details, including a script to help with the migration.\n */\n@Deprecated\n/* package */ final class ToFloatPcmAudioProcessor extends BaseAudioProcessor {\n\n  private static final int FLOAT_NAN_AS_INT = Float.floatToIntBits(Float.NaN);\n  private static final double PCM_32_BIT_INT_TO_PCM_32_BIT_FLOAT_FACTOR = 1.0 / 0x7FFFFFFF;\n\n  @Override\n  @CanIgnoreReturnValue\n  public AudioFormat onConfigure(AudioFormat inputAudioFormat)\n      throws UnhandledAudioFormatException {\n    @C.PcmEncoding int encoding = inputAudioFormat.encoding;\n    if (!Util.isEncodingHighResolutionPcm(encoding)) {\n      throw new UnhandledAudioFormatException(inputAudioFormat);\n    }\n    return encoding != C.ENCODING_PCM_FLOAT\n        ? new AudioFormat(\n            inputAudioFormat.sampleRate, inputAudioFormat.channelCount, C.ENCODING_PCM_FLOAT)\n        : AudioFormat.NOT_SET;\n  }\n\n  @Override\n  public void queueInput(ByteBuffer inputBuffer) {\n    int position = inputBuffer.position();\n    int limit = inputBuffer.limit();\n    int size = limit - position;\n\n    ByteBuffer buffer;\n    switch (inputAudioFormat.encoding) {\n      case C.ENCODING_PCM_24BIT:\n        buffer = replaceOutputBuffer((size / 3) * 4);\n        for (int i = position; i < limit; i += 3) {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/google/ExoPlayer/blob/dd430f7053a1a3958deea3ead6a0565150c06bfc/library/core/src/main/java/com/google/android/exoplayer2/audio/ToFloatPcmAudioProcessor.java#L33-L69","documentation":"Deprecated ToFloatPcmAudioProcessor converted high-resolution integer PCM (24/32-bit) to 32-bit float PCM for output devices that accept float. onConfigure throws UnhandledAudioFormatException unless Util.isEncodingHighResolutionPcm(encoding) — i.e. the input must be ENCODING_PCM_24BIT, ENCODING_PCM_32BIT, or ENCODING_PCM_FLOAT; 16-bit or compressed input is rejected because the conversion would be meaningless.","triggerScenarios":"The sink enabling this processor while the decoded chain delivers 16-bit PCM — historically when float output was requested on devices/API levels where the decoder emitted 16-bit, or with custom audio processors chained in the wrong order.","commonSituations":"Legacy apps on old ExoPlayer versions requesting float output for 16-bit sources; custom DefaultAudioSink configurations forcing the deprecated float path; class is deprecated precisely because float conversion is now handled internally — presence of this error signals outdated integration code.","solutions":["Upgrade to a modern ExoPlayer/Media3 release where ToFloatPcmAudioProcessor is no longer used and float handling is internal.","Do not manually inject ToFloatPcmAudioProcessor into the audio processor chain.","Only request float output when the source decodes to 24/32-bit PCM.","If pinned to an old version, disable float output (default PCM 16-bit) in the sink configuration."],"exampleFix":"// before (deprecated path)\nsinkBuilder.setAudioProcessors(\n    new AudioProcessor[] {new ToFloatPcmAudioProcessor()});\n\n// after — let the sink handle conversion; supply no custom processors\n// DefaultAudioSink chooses float automatically for high-res PCM\nsinkBuilder.setAudioProcessors(new AudioProcessor[0]);","handlingStrategy":"validation","validationCode":"static boolean supportsFloatConversion(@C.PcmEncoding int enc) {\n  return Util.isEncodingHighResolutionPcm(enc);\n}\n// only enable float output paths when supportsFloatConversion(currentPcmEncoding)","typeGuard":null,"tryCatchPattern":"try {\n  sink.configure(floatOutputOn);\n} catch (AudioProcessor.UnhandledAudioFormatException e) {\n  sink.configure(floatOutputOff); // fall back to 16-bit chain\n}","preventionTips":["Upgrade to Media3 — the deprecated processor is gone","Never inject deprecated ToFloatPcmAudioProcessor manually","Request float output only for 24/32-bit sources"],"tags":["exoplayer","audio","pcm","float","deprecated","configuration"],"backgroundTag":null,"analyzedSha":"dd430f7053a1a3958deea3ead6a0565150c06bfc","analyzedAt":"2026-08-14T12:22:02.982Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}