[LG V40 Guides, News, & Discussion] csglinux:
Big thanks to Dannemand for pursuing this. It is frustrating that LG are unaware of (or don't care about) this re-sampling issue.

I just checked with the trial version of Poweramp. It's not working correctly for me:

Output thread 0xee783980, name AudioOut_15, tid 3849, type 0 (MIXER):

I/O handle: 21

Standby: no

Sample rate: 48000 Hz

HAL frame count: 1920

HAL format: 0x1 (AUDIO_FORMAT_PCM_16_BIT)

HAL buffer size: 7680 bytes

Channel count: 2

Channel mask: 0x00000003 (front-left, front-right)

Processing format: 0x1 (AUDIO_FORMAT_PCM_16_BIT)

Is there some setting I'm overlooking, or do I need the paid version? (The UI does look pretty.)

Here's brief summary/re-wording of something I posted a while back on headfi...

I found a post on the V20 thread that looked really optimistic (I can't post a link to it because of the anti-spam rules here, but you'll find it if you search the headfi V30 tips/tricks thread). I tried that suggestion (and a zillion other options) on a rooted V30 and nothing worked :( I pm'd the user that made that post, but they never replied. FYI, my V30's Oreo /system/build.prop contains this line:

vendor.audio.offload.pcm.16bit.enable=false

Changing the above to "true", and/or adding "audio.offload.pcm.16bit.enable=true" has no effect on my V30.

The closest I've gotten to something interesting was to replace the AUDIO_FORMAT_PCM_16_BIT flags in audio_policy.conf and audio_policy_configuration.xml in /etc, /vendor/etc and /vendor/etc/audio with

AUDIO_FORMAT_PCM_24_BIT_PACKED. This results in audio_flinger reporting 44 kHz/24 bit, but it still goes through the mixer. (I still hear the resampling artifacts and audio_flinger still reports "mixer" on the output thread). I've never heard a V20, so I'm not 100% sure the fix in the above link actually worked, or just tricked audio_flinger. However, it's interesting that the output thread reports "DIRECT". I've not been able to get the V30 to do that.

Neutron and UAPP avoid the Android mixer by calling the AudioTrack API. I asked Dmitry Kos (Neutron developer) whether he thought there was any hope of a global/system-wide fix for this. His reply:

"No no, it is not possible because it depends on each app which is

doing audio output. E.g. app needs to implement access to AudioTrack

in its code which is then compiled into a binary executable."

And also...

"LG knows about AudioTrack for sure, it is an internal main audio class

for audio input/output and is well documented inside the Android OS

source code. It is used directly by the system apps too but may be

developers of firmware do not bother with format switching (or

matching to a track) and therefore do not implement extended

functionality."

I'm not sure all hope is lost for a system-wide fix, but after a couple of days of messing around with system files and getting nowhere, I gave up. I'll happily try again if I get any other ideas or suggestions :)

P.S. Aha! There are indeed settings for Poweramp :) Under Settings->Audio->Output, there's an AudioTrack output option. That looked promising, but seems to do nothing :( However, below that is a "Hi-Res Output" option. If you switch this on for the wired headset/aux, we can indeed get direct output, by-passing the mixer. Nice find ctheanh! The one small caveat seems to be that you have to set the sampling rate manually. 44/16 plays back as 44/24 and reports as such via audio_flinger (which is great news), but so does 96/24, 192/24, etc. Curiously, the higher-res tracks sound ok even when reported as 44 kHz. I'll have to run some tracks through an FFT to see if it's just a reporting issue.