Open Flamefire opened 2 years ago
No idea as to how to get 24/192 working properly. The support should be in kernel and we are using the stock audio hal, so everything should be in place. Maybe we are lacking some kind of prop?
As for the audio_policy_configuration.xml file, that is directly from stock with just some minor modifications, which you can check in the history. The file is identical across all devices.
Maybe we are lacking some kind of prop?
It should all be in the audio_policy_configuration.xml
as my experiments seem to prove.
I'm not sure why we still copy the audio_output_policy.conf, see https://github.com/whatawurst/android_device_sony_yoshino-common/blob/8caad0bfff6fda594d672e6206d1d28dfac28262/platform/config-files.mk#L17. I'd say we should not. According to https://source.android.com/devices/audio/implement-policy?hl=en
Note: Support for the USE_XML_AUDIO_POLICY_CONF build flag and thus the ability to use the deprecated CONF format was removed in Android 10.
If I compare https://github.com/whatawurst/android_device_sony_yoshino-common/blob/bda77a1cf0fbda2c1ee70002986fe965b4b9feb9/config/audio_policy/audio_output_policy.conf and https://github.com/whatawurst/android_device_sony_yoshino-common/blob/bda77a1cf0fbda2c1ee70002986fe965b4b9feb9/config/audio_policy/audio_policy_configuration.xml it seems to be indeed a "correct translation".
On my experiments with PowerAmp and that XML file I found that adding the 24bit 192kHz format to the deepbuffer was required. Not sure why.
I'd suspect even a bug in the player as according to the comments in the conf file if the player requests an output with flag AUDIO_OUTPUT_FLAG_DIRECT and a format of either AUDIO_FORMAT_PCM_24_BIT_PACKED or AUDIO_FORMAT_PCM_8_24_BIT it should work.
I'm also surprised to NOT see AUDIO_FORMAT_PCM_FLOAT
in the config files.
I'll hopefully get a test phone in the next couple days or weeks. Then I can test if it even works on stock XZ1C/lilac.
As for the audio_policy_configuration.xml file, that is directly from stock with just some minor modifications,
I have just extracted the file from G8441_Vodafone DE_47.2.A.11.228-R4C firmware and compared it to our current file: There is more than just "minor" modifications. E.g. having "Earpiece" and "FM Tuner" in the attached devices list and many new routes. So I guess mostly this commit: https://github.com/whatawurst/android_device_sony_yoshino-common/commit/ce75be163103a1a5dd684702dbc95e5bcbaa07fe#diff-79534e6aad8e786df2c39afb15e669d04bbe292a4bff7804146a4da50135d4b6
Also comparing the conf file vs the XML file from stock I see 192kHz in the conf but not in the XML: E.g.:
direct_pcm_24 {
flags AUDIO_OUTPUT_FLAG_DIRECT
formats AUDIO_FORMAT_PCM_24_BIT_PACKED|AUDIO_FORMAT_PCM_8_24_BIT|AUDIO_FORMAT_PCM_32_BIT
sampling_rates 44100|48000|88200|96000|176400|192000|352800|384000
bit_width 24
app_type 69940
}
Pretty strange as if Sony forgot about that...
Some more input: Stock XZ1C supports 24/192 output. Logcat from PowerAmp trying it:
APM_AudioPolicyManager: getOutputForAttr() device 0x4, sampling rate 192000, format 0x6, channel mask 0x3, flags 0x9
AudioFlinger: openOutput() this 0xea43e000, module 10 Device 0x4, SamplingRate 192000, Format 0x000006, Channels 0x3, flags 0x1
audio_hw_primary: adev_open_output_stream: enter: format(0x6) sample_rate(192000) channel_mask(0x3) devices(0x4) flags(0x1) stream_handle(0xefb6e000)
BTW: Any reason we don't use the source-build audio module but copy it from the stock rom? vendor/qcom/opensource/audio-hal/primary-hal/configs/msm8998
even has some configs.
Wow... I think I found the issue: Under accessibility services "Mono-Audio" is enabled by default. This disables direct output: https://github.com/LineageOS/android_vendor_qcom_opensource_audio/blob/343077c4a5393459bc6b4a5fbccdeb0b33b6e5d4/policy_hal/AudioPolicyManager.cpp#L1727-L1731 This then enables the "deep-buffer" flag: https://github.com/LineageOS/android_vendor_qcom_opensource_audio/blob/343077c4a5393459bc6b4a5fbccdeb0b33b6e5d4/policy_hal/AudioPolicyManager.cpp#L1847-L1848
--> Boom, we run into the 16Bit@48kHz config of that: https://github.com/whatawurst/android_device_sony_yoshino-common/blob/8caad0bfff6fda594d672e6206d1d28dfac28262/config/audio_policy/audio_policy_configuration.xml#L77-L78 Instead of https://github.com/whatawurst/android_device_sony_yoshino-common/blob/8caad0bfff6fda594d672e6206d1d28dfac28262/config/audio_policy/audio_policy_configuration.xml#L94-L96
Not sure why the default is Mono-Audio and why deep-buffer doesn't support the high-res output. I'd expect that for Mono it can simply downmix the stereo to mono keeping the original quality... We might want to improve on this or just keep it...
BTW: Not fully sure why all the compressed formats were removed with https://github.com/whatawurst/android_device_sony_yoshino-common/commit/0199389e95d9c462404de79c30a6c6ad9fe80961 and https://github.com/whatawurst/android_device_sony_yoshino-common/commit/62a5376f58931e3b12f41e5425c9bf7067e0e8c7#diff-79534e6aad8e786df2c39afb15e669d04bbe292a4bff7804146a4da50135d4b6 E.g. lilac has those in stock, wouldn't that mean they are supported in LOS too when copying the audio.primary.so from stock? Or is there more involved in those formats? Should we have a configuration option in yoshino-common to use or not use those configs and e.g. have adjusted files per platform depending on the stock configs?
A user noted that e.g. the lilac phone supports 24bit 192kHz audio output but not on our LOS ROMs: https://forum.xda-developers.com/t/rom-lineageos-17-1-18-1-unofficial-update-2021-09-18.4308295/page-11#post-85879703
So far I found the
audio_policy_configuration.xml
to be responsible for that. Android 9 had the audio*.conf files while Android 10+ has theaudio_policy_configuration.xml
, so I'd guess something went wrong in the "translation"@cryptomilk @derfelot How was
audio_policy_configuration.xml
created exactly? And shouldn't that be a device specific file instead of yoshino-common?With some experiments I was able to get 24/192 output working: https://forum.xda-developers.com/t/rom-lineageos-17-1-18-1-unofficial-update-2021-09-18.4308295/post-85905893 But basically just pure Trial&error. This is the file I'm using: audio_policy_configuration.xml.txt
Any input/ideas here?