SecondFirst method works natively through ALSA kernel module/drivers while second and third options work through PulseAudio
libraries i.e. different modules and protocols (pulseaudio
package should be installed on Termux / Linux distro) while the first works natively through ALSA kernel module/drivers.
ButMostly Android OEMs base their sound architecture on ALSA, though not necessary:
"You can use Advanced Linux Sound Architecture (ALSA), Open Sound System (OSS), or a custom driver"
In case of ALSA kernel lists devices in /dev/snd/
which can be manipulated to direct sound towards sound card. Complete tutorial can be found here. It works, but not for all sound formats. It's because ALSA drivers loaded byon Android devices can't be controlled (at least I could not) through standard Linux userspace tools in straightforward manner because they aren't compatible (refer to changes/additions in Linux kernel by Google/OEMs, and the closed source proprietary blobs providing hardware support). However Android kernel lists devicesHALs in userspace, and differences in /dev/snd/
which can be manipulated to direct ALSA towards Android sound cardALSA vs. TinyALSA). AccessAlso access to /proc/asound/
is also required which isn'tnot possible without root. See, see details in this answer and complete tutorial can be found here. It works, but not for all sound formatsthis answer. ALSA project is here.
XWhen using X Server:
XSDL Server
is the only well developed X server Android app I know of, no more developed unfortunately. It has a built-in PulseAudio server with module-cli-protocol-tcp
already loaded, listening on standard port 4712
by default. Once the X Session is started on Linux, we can direct sound from Linux PulseAudio client libraries to XDSL PulseAudio server by setting the following environment variable on Linux:
VNCWhen using VNC:
VNC protocol by default doesn't support sound. However, PulseAudio server can stream over TCP/UDP using different protocols. There are apps available for Android that can play simple protocol
(e.g. Simple Protocol Player) and real-time transport protocol
(e.g. VLC). For this we need to load the related PulseAudio module.
To setup local PulseAudio daemon, first of all comment out following lines:
RELATED: