Skip to content

Allow to use float output in any case if output provider doesn't support 16-bit int#3104

Open
nift4 wants to merge 1 commit intoandroidx:mainfrom
nift4:floatfallback
Open

Allow to use float output in any case if output provider doesn't support 16-bit int#3104
nift4 wants to merge 1 commit intoandroidx:mainfrom
nift4:floatfallback

Conversation

@nift4
Copy link
Contributor

@nift4 nift4 commented Mar 5, 2026

This commit is a continuation of 4f4ad5f and fe4f235 by Toni, decoupling DefaultAudioSink logic from assumptions that AudioTrack is used.

  • If audio output provider doesn't support 16-bit int PCM, we should use float PCM in any case, even if input isn't high-resolution PCM
  • Unlike when this check was written, ToFloatPcmAudioProcessor now supports every linear PCM format, similar to ToIntPcmAudioProcessor, it is no longer limited to high-resolution only
  • While AudioTrack (and by extension AudioTrackAudioOutputProvider) always supports 16-bit int (hence, this change is a no-op for them), it may not apply to other ways of outputting PCM
  • Additionally, the same applies to the provider possibly not supporting float PCM output. Currently, we have the enableFloatOutput option, but this is scheduled to be replaced by a more generic one. While we're here, we can address it as well by adding a check.

support 16-bit int

This commit is a continuation of 4f4ad5f
and fe4f235 by Toni, decoupling
DefaultAudioSink logic from assumptions that AudioTrack is used.

* If audio output provider doesn't support 16-bit int PCM, we
  should use float PCM in any case, even if input isn't
  high-resolution PCM
* Unlike when this check was written, ToFloatPcmAudioProcessor now
  supports every linear PCM format, similar to ToIntPcmAudioProcessor,
  it is no longer limited to high-resolution only
* While AudioTrack (and by extension AudioTrackAudioOutputProvider)
  always supports 16-bit int (hence, this change is a no-op for
  them), it may not apply to other ways of outputting PCM
* Additionally, the same applies to the provider possibly not
  supporting float PCM output. Currently, we have the
  enableFloatOutput option, but this is scheduled to be replaced
  by a more generic one. While we're here, we can address it as
  well by adding a check.
@tonihei
Copy link
Collaborator

tonihei commented Mar 10, 2026

An audio output not supporting 16-bit PCM sounds very unusual. I appreciate that the abstraction of the AudioTrack-based output makes this theoretically possible, but I wonder if you have a concrete use case in mind?

(PR looks good otherwise, just making sure we really need this bit of logic)

@nift4
Copy link
Contributor Author

nift4 commented Mar 10, 2026

I was thinking of a custom PCM mixer for my WIP libusb output and that should use the highest determinator format. A PCM mixer can only mix what has the same format, and I intend to do with float32 for being said highest determinator. So I need to convert all audio to float32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants