Skip to main content
added 253 characters in body
Source Link
Irfan Latif
  • 21.2k
  • 3
  • 74
  • 225

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:

Second and third options work through PulseAudio libraries i.e. different modules and protocols (pulseaudio package should be installed on Linux distro) while the first works natively through ALSA kernel module/drivers.

But ALSA drivers loaded by Android 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 in Linux kernel by Google, and the closed source proprietary blobs providing hardware support). However Android kernel lists devices in /dev/snd/ which can be manipulated to direct ALSA towards Android sound card. Access to /proc/asound/ is also required which isn't possible without root. See details in this answer and complete tutorial can be found here. It works, but not for all sound formats. ALSA project is here.

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:

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:

First method works natively through ALSA kernel module/drivers while second and third work through PulseAudio libraries i.e. different modules and protocols (pulseaudio package should be installed on Termux / Linux distro).

Mostly 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 on 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, the closed source proprietary HALs in userspace, and differences in ALSA vs. TinyALSA). Also access to /proc/asound/ is not possible without root, see details in this answer. ALSA project is here.

When 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:

When 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:

added 514 characters in body
Source Link
Irfan Latif
  • 21.2k
  • 3
  • 74
  • 225
  • Play through native ALSA libraries
  • Stream through PulseAudio
  • Forward to X Server (on UNIX or TCP socket)
  • Stream over IP (TCP or UDP) e.g. when using VNC

But ALSA drivers loaded by Android 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 in Linux kernel by Google, and the closed source proprietary blobs providing hardware support). However Android kernel lists devices in /dev/snd/ which can be manipulated to direct ALSA towards Android sound card. CompleteAccess to /proc/asound/ is also required which isn't possible without root. See details in this answer and complete tutorial can be found here. It works, but not for all sound formats. ALSA project is here.

VNC:
VNC protocol by default doesn't support sound. However, PulseAudio server can stream over TCP/UDP using different protocols as we see in previous section. There are apps available for Android that can play simple protocol, one issimple protocol Simple Protocol Player(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:

  • Play through native ALSA libraries
  • Stream through PulseAudio
  • Forward to X Server (on UNIX or TCP socket)
  • Stream over IP (TCP) e.g. when using VNC

But ALSA drivers loaded by Android 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 in Linux kernel by Google, and the closed source proprietary blobs providing hardware support). However Android kernel lists devices in /dev/snd which can be manipulated to direct ALSA towards Android sound card. Complete tutorial can be found here. It works, but not for all sound formats. ALSA project is here.

VNC:
VNC protocol by default doesn't support sound. However, PulseAudio server can stream over TCP using different protocols as we see in previous section. There are apps available for Android that can play simple protocol, one is Simple Protocol Player. For this we need to load the related PulseAudio module.
To setup local PulseAudio daemon, first of all comment out following lines:

  • Play through native ALSA libraries
  • Stream through PulseAudio
  • Forward to X Server (on UNIX or TCP socket)
  • Stream over IP (TCP or UDP) e.g. when using VNC

But ALSA drivers loaded by Android 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 in Linux kernel by Google, and the closed source proprietary blobs providing hardware support). However Android kernel lists devices in /dev/snd/ which can be manipulated to direct ALSA towards Android sound card. Access to /proc/asound/ is also required which isn't possible without root. See details in this answer and complete tutorial can be found here. It works, but not for all sound formats. ALSA project is here.

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:

added 114 characters in body
Source Link
Irfan Latif
  • 21.2k
  • 3
  • 74
  • 225

Following should be enabled in DE startup settings, necessary because some programs such as emixer on Enlightenment Desktop Environment works only if PulseAudio server in local X server is published:

I have tested both of PulseAudio based solutions on ArchLinuxARM and Ubuntu, and they work without root access. ButHowever SELinux may restrict access to certain resources if running in non-root context. Also, in order to get network access and create sockets, you have to be member of inet (3003) group necessarily. All apps with android.permission.INTERNET granted are member of this group.

Following should be enabled in DE startup settings, necessary because some programs such as emixer on Enlightenment Desktop Environment works only if local X server is published:

I have tested both of PulseAudio based solutions on ArchLinuxARM and Ubuntu, and they work without root access. But in order to get network access and create sockets, you have to be member of inet (3003) group necessarily. All apps with android.permission.INTERNET granted are member of this group.

Following should be enabled in DE startup settings, necessary because some programs such as emixer on Enlightenment Desktop Environment works only if PulseAudio server in local X server is published:

I have tested both of PulseAudio based solutions on ArchLinuxARM and Ubuntu, and they work without root access. However SELinux may restrict access to certain resources if running in non-root context. Also, in order to get network access and create sockets, you have to be member of inet (3003) group necessarily. All apps with android.permission.INTERNET granted are member of this group.

added 116 characters in body
Source Link
Irfan Latif
  • 21.2k
  • 3
  • 74
  • 225
Loading
Source Link
Irfan Latif
  • 21.2k
  • 3
  • 74
  • 225
Loading