[General Topics] avs333:
Each and every app on Google Play makes use of Android audio system to play music files (excluding my old andLess and the "USB Audio Recorder PRO" for external usb). The trouble with such playback is that you get a perfect 16/48000 or (44100) stream no matter the source file which is first downsampled then (digitally) clipped to the requested volume. Just try running this while playing _any_ file ("pcm15p" is for Qualcomm-based devices only, "15" needs be replaced with a different number for other ones):

adb shell cat /proc/asound/card0/pcm15p/sub0/hw_params
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 240
buffer_size: 480

As the time goes by and new devices receive better hardware, you'd expect this to change. No such luck with Android yet.

So I wrote a test app that plays lossless FLAC files directly through the ALSA driver.

The disgrace is:

1) It's targeted to recent msm8974 or apq8084 based devices and has no built-in support for other ones. If you've got an unsupported device, you have to modify the cards.xml file settings before anything, and this may be tricky (see below).

2) Root access is a must. A Permissive selinux setup may also be required (adb shell; setenforce Permissive).

3) No formats other than 16/24-bit FLAC or 16-bit APE are supported. There's a curious bug with 24-bit APE (won't be fixed);

-- All files not recognised for playback will be routed to Android;

-- If a particular sample rate (e.g., 176400) is not supported by hardware, it will be silently downsampled to its base rate (88200 or 44100 in this example);

-- If a particular format (i.e. a compressed stream, or 24-bit pcm or even 16-bit on some usb devices) is not supported, an error will be shown

4) In ALSA mode, volume controls work only when the app is in foreground (to be fixed);

5) Switching to/fro the Compr device may reboot your phone (kernel bug; workaround will be included later);

The settings file is called "/sdcard/.alsaplayer/cards.xml" and it's well commented. If you have a device missing there, all settings go in this file. A simple tip is checking the output of a mixer program like tinymixer and adding the diff when the device is playing and when it's not. These ALSA contrtols will be executed each time before the device is opened/closed/volume managed. The periods size/number to be added later.

This app also tries to play on "compressed" (a.k.a. "offload") Qualcomm devices, but you'll not be able to play FLAC files ulesss your kernel is patched; all newer msm8974/apq8084 devices support the hardware FLAC decoding, please ask your kernel developer to add the code like https://github.com/CyanogenMod/andr...mmit/f961d70994fe5f097b90e2cb5cfd87e90302c456 (I'm not providing a patch intentionally as (1) it's straightforward for an experienced developer (2) the codeaurora interface is really broken). For me, an offload FLAC playback sounds +worse+ than the direct pcm one (and I don't know the reasons why) -- I'm testing with the sennheiser IE-80 & audiotechnica ath 1000D headphones.

The program is opensource https://github.com/avs333/alsaplayer

The kudos go to skvalex who wrote almost all java part!