Improve support for custom float audio processors
- Dominant language
- Java
- Stars
- 21.9k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
### Use case description
My app is a music player with many audiophile users. These users tend to use very high-quality lossless audio that can have bit rates in the megabytes and usually output large samples like 32-bit or Float PCM. However, ExoPlayer's functionality for rendering this high quality audio `enableFloatOutput` is severely lacking for two reasons:
1. I cannot use `AudioProcessor` instances with float output. This prevents features that are standard for music players, like ReplayGain. This is presumably due to `SonicAudioProcessor` and other internal audio processors expecting 16-bit PCM.
2. ExoPlayer always resamples audio to a single format. On low-power devices playing high-definition files, this can result in distorted playback as the resampling task is simply too expensive. This is also probably due to the internal audio processors.
### Proposed solution
Replace `enableFloatOutput` with a new `AudioSink` flag called `enableRawOutput` that signals ExoPlayer to drop all of it's internal audio processors and just output in the source audio quality. This output should still be routed to the user's audio processors, however, with some documentation explaining that user audio processors should expect all possible PCM formats if `enableRawOutput` is `true`.
### Alternatives considered
I could do some evil reflection hacks in `DefaultAudioSink` (with float output enabled) to replace the internal audio processors which resample with my own audio processors that don't resample. I do not like this at all, especially since I don't know if there are any other reasons for why float output is structured this way outside of the internal audio processors.
### Additional info
If there is any other good reason for why resampling is done like this, please let me know. I am also happy to work on a PR that implements this if it is a reasonable addition.
Contributor guide
Assessment
This issue has not been assessed yet.