-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can FLAC Extension play 96kHz/24bit track without downsampling? #6643
Comments
I tried to reproduce on a Pixel 2 on Android 10 with a flac test file containing a sweep going from 1Hz to 96kHz sampled at 192kHz. I first examined the PCM data outputted by the FLAC extractor using ExoPlayer I then examined the frequency received by the audio engine (audioflinger) and can confirm it received a 192kHz stream. As I do not have a USB sound card supporting 192kHz, I was not able to confirm whether the whole output chain is at 192kHz when such sound card is connected. Note that the AOSP audio system does not open USB sound cards higher than 96kHz. It is possible that Sony modified their MediaPlayer to force output at 192kHz when the source is at such sampling rate but did not change the code of AudioTrack. If that is the case, Exoplayer will not be able to workaround the issue as it uses AudioTrack and not MediaPlayer. In order to better understand the issue, could you please generate 2 bug reports while playing your 96kHz audio FLAC on your USB sound card:
Make sure not to stop the playback until the bug report is fully generated (takes ~2 minutes). How to take a bug report: https://developer.android.com/studio/debug/bug-report |
To clarify, have you observed a 32kHz signal on both the analog (on-device 3.5mm stereo jack) and the digital (USB) or just the digital interface? |
@kim-vde since you've tried this on your end and had no issues, a dig a little bit further into this problem and created even more simpler app that just plays sample .flac. And there was no issues, so it turns out it wasn't because of the ExoPlayer, but apparently something inside my app, which I'm still investigating. @krocard I've observed on both interfaces. @kim-vde @krocard Thanks for investigating this and helping me to eliminate ExoPlayer as the source of the problem. |
I'm reopening this issue with new info: As it turns out, issue on my side was because of the Equalizer. If Equalizer is attached to the player, output always gets downsampled. So, removing Equalizer completely, solved problem but only on some devices... Audio signal is OK (not downsampled):
Audio signal is downsampled:
As it turns out, only Sony and Samsung devices with 3.5mm stereo jack doesn't downsample. |
Are those test done with Exoplayer or Mediaplayer? To be able to tell if the issue has something to do with Exoplayer, or those phone just do not support 96kHz on their USB output, we need a bug report. Could you please play your 96kHz test sound on USB and generate a bug report, please try to not change the audio state (aka do not pause, reach the EOF...) during the bug report generation (~3min). |
With ExoPlayer. I'll generate bug report... |
Note that outputting audio at 96kHz on an analog jack is probably not very compatible with cheap earphones. |
Bug reportsWith ExoPlayer: exoplayer_report_06122019.zip With MediaPlayer: mediaplayer_repory_06122019.zip This bug reports were generated while playing .flac test file via simple sample app. Sample app can play that test file via ExoPlayer or MediaPlayer, whichever is currently chosen. Test results: when playing on USB output with this device, downsampling at around 24kHz happens on both ExoPlayer and MediaPlayer |
Thanks for the bug reports, I will take a look later today.
Why use the USB-C to 3.5mm adapter and not your Steinberg UR28 USB input? |
@krocard sorry I forgot to mention that this new tests were all done using Scarlett Focuscrite 2i2 which doesn't have USB input, so I need to use USB-C to 3.5mm adapter. But, also as I remember, Steinberg UR28 also didn't have USB input, so whenever I was testing output from the devices that only have USB-C, I had to use USB-C to 3.5mm adapter. Sorry if there was some misunderstanding. |
From the bug report section (
The only supported sample rate of your USB audio device is 48kHz, thus the framework downsamples the track that was originaly at 96kHz (
Please test with an USB sound card supporting 96kHz. |
@krocard thank you for checking. I can see that this USB-C to 3.5mm adapter supports only 48kHz. Further more, I've created bug report with one device that is working (Sony Xperia XZ) and one that isn't working with ExoPlayer, but works with MediaPlayer: Sony Xperia XZ
LG V30
I can see in the LG V30 logs, that supported sample rate is only 48kHz so it should downsample, but why it works on the MediaPlayer? |
I'm sorry but those dumpsys extract are not enough for me to understand the LG V30 audio configuration. I'm critically missing the Audio Policy dumpsys. Could you please post 2 full bug reports (zip file like you did in #6643 (comment)):
Also, it would be nice to disable the touch sounds, as they produce lots of audio event unrelated to our problem (settings/sound/touch sounds) |
@krocard here are 2 full bug reports: |
Thanks for the dumpsys @ivan2311, it let me figure out what is going on. Without entering into too much details, MediaPlayer uses a special way of playing audio called "offload". It consists of not decoding the audio in the app and instead have the platform DSP decode it. It is a completely different audio path then the regular PCM playback. Basically LG's PCM interface (contrary to Sony's) has an artificial limitation to 4800kHz even though the HW supports other sample rates. This is not something Exoplayer or even the android framework can change, its forced by LG's configuration. Unfortunately, this low level behavior is phone specific and can not be relied on across the ecosystem. Note that offload APIs were made public in Android 10, so starting with Android 10, non platform player like Exoplayer can support it. Though Exoplayer currently does not. |
To summarize:
|
@krocard thank you for resolving this issue and the explanation! Just one more quick question: if I'm playing HiRes 24bit track, should I enable conversion from HiRes int pcm to float inside DefaultAudioSink, since when it's set to false it converts 24bit pcm to 16bit, but I would like to have an unchanged 24bit at the output? |
This question is unrelated to the main issue. Next time please open a new issue. |
Thanks again @krocard ! |
I'm using FLAC Extension to play .flac files and I have really basic ExoPlayer setup:
.flac files are playing ok, but when I look at the audio output it shows that audio signal can't go above the 24kHz, it always gets downsampled. For testing purposes I have a 96kHz/24bit .flac file that is just simple audio signal that goes from 1kHz to 32kHz and I'm checking audio output with Audacity. And what I'm seeing is that signal never goes above 24kHz.
Is this a bug in the ExoPlayer library since there is a commit that states that 192kHz should be supported: 0b08688?
Does that mean that ExoPlayer downsamples everything that goes above 48kHz?
Am I missing something here to support 96kHz?
Also, I've performed same test using Android MediaPlayer and it's ok, signal goes to 32kHz without any issues.
EDIT:
ExoPlayer version: current dev-v2 version, with latest commit: 87003b3 (I couldn't build FLAC extension with the latest release version release-v2 ). Previously I've used ExoPlayer v2.10.1 and it had the same issue
Testing device: Sony Xperia XZ
Other Audio equipment: external USB sound card (Steinberg UR28) to test output of analog (via on-device 3.5mm stereo jack) and digital audio signal (via USB audio through Steinberg UR28)
The text was updated successfully, but these errors were encountered: