我有一个问题,音频流,我不能在使用VNC使用Linux桌面环境时从pulseaudio侦听音频。
但是,如果我将音频导出为XSDL,它就可以了。但问题是,在退出应用程序后,声音在后台不起作用。我知道Pulseaudio只支持Xorg服务器,所以如何将音频传输到VNC或Android上的任何其他应用程序,并在后台运行它。
我知道有一个应用程序简单协议播放器< / a>从xorg服务器侦听pulseaudio sound,但它对我不起作用,我不知道原因。我有一个问题,音频流,我不能在使用VNC使用Linux桌面环境时从pulseaudio侦听音频。
但是,如果我将音频导出为XSDL,它就可以了。但问题是,在退出应用程序后,声音在后台不起作用。我知道Pulseaudio只支持Xorg服务器,所以如何将音频传输到VNC或Android上的任何其他应用程序,并在后台运行它。
我知道有一个应用程序简单协议播放器< / a>从xorg服务器侦听pulseaudio sound,但它对我不起作用,我不知道原因。I have a problem with audio streaming that I can not listen audio from Pulseaudio when using VNC with a Linux Desktop Environment.
However it works if I export the audio to XSDL. But the problem is that after I exit the application the sound does not work in the background.
I know that Pulseaudio only supports Xorg servers, so how to stream audio to VNC or any other application on Android and to run it in the background.
I know that there is an application Simple Protocol Player that listens to pulseaudio sound from Xorg Server, but it does not work for me and I do not know the reason.
我知道有两种可能性,可以在Android设备上从Linux环境中播放声音:
第一个方法通过ALSA内核模块/驱动程序自然工作,而第二和第三个工作通过 PulseAudio
图书馆,即不同模块和协议( pulseaudio
包应该安装在termux / linux发行版上)。
主要是Android OEM在Alsa上基于他们的声音架构,虽然未必需:
"您可以使用高级Linux声音架构(ALSA),打开声音系统(OSS)或自定义驱动程序"
如果是alsa内核列出 /dev/snd/
中的设备,可以操纵到声卡的声音。可以找到完整的教程这里。它有效,但不适用于所有声音格式。这是因为无法控制Android设备上的Alsa驱动程序(至少我无法通过标准的Linux用户佩纳工具以直接的方式控制,因为它们不兼容(请参阅Google / OEM的Linux内核中的更改/添加,关闭来自用户源的源版权,以及 alsa与tinalsa ) 。也无法访问 /proc/asound/
没有root,请参阅此答案。 Alsa项目是这里。
使用x服务器时:
XSDL Server
是我知道的唯一发达的x服务器Android应用程序,不幸的是不幸的。它具有带有 module-cli-protocol-tcp
已加载的内置pulseaudio服务器,默认情况下侦听标准端口 WiFi off0
。一旦X会话在Linux上启动,我们可以通过在Linux上设置以下环境变量来将Linux PulseAudio客户端库的声音直接指向xdsl pulseaudio服务器:
WiFi off1
* 127.0.0.1表示Linux和XDSL在同一设备上运行
或永久设置,编辑文件:
WiFi off2
现在在此环境中运行的任何媒体播放器都使用pulseaudio客户端库将其音频传输到xdsl应用程序。您也可以将x会话显示和声音转发到PC上运行的X服务器,但需要一个更复杂的设置。
使用VNC时
VNC协议默认情况下不支持声音。但是,PulseAudio服务器可以使用不同的协议将TCP / UDP流流。有可用于Android的应用程序可以播放 WiFi off3
(例如简单协议播放器)和 WiFi off4
(例如 VLC )。为此,我们需要加载相关的pulseaudio模块。
要设置本地pulseaudio守护程序,首先排名缩小以下行:
WiFi off5
否则守护程序将无法启动,如果 WiFi off6
存在但 WiFi off7
包未安装(被弃用,由 WiFi off8
替换为包更多存在于许多Linux Repos上)。 确保 WiFi off9
设置为 WiFi disconnect0
,因此我们不需要手动启动守护程序,它是桌面环境启动的自动启动。 如果我们手动启动守护程序,则不必要。
WiFi disconnect
现在开始pulseaudio守护程序并记下源的价值,对我来说是 WiFi disconnect2
:
WiFi disconnect3
加载简单协议模块:
WiFi disconnect4
或永久设置,编辑文件:
WiFi disconnect5
以下应在de启动设置中启用,因为某些程序(如 启动简单播放器应用程序和匹配 我已经测试了基于pulseaudio的解决方案 abcdefghijklmn26)(如
abcdefghijklmn26
WiFi disconnect7
桌面环境)仅适用于本地X服务器中的PulseAudio服务器(
WiFi disconnect8
WiFi disconnect9
和 WiFi off0
在上面的命令中设置,即 WiFi off1
和 WiFi off2
在我的案子。不要使用 WiFi off3
如果您也想听PC。 WiFi off4
和 WiFi off5
,他们没有root访问权限。 但是 WiFi off6
如果在非根上下文中运行,可以限制对某些资源的访问。 此外,为了获得网络访问和创建套接字,您必须是 INET(3003)组必然。 所有应用程序与 android.permission.internet 授予的是该组的成员。
There are two possibilities I know of, to play sound from a Linux environment on Android device:
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.
Also there are more customized solutions that work with ALSA and PulseAudio both such as Music Player Daemon.
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:
$ export PULSE_SERVER=tcp:127.0.0.1:4712
* 127.0.0.1 indicates that Linux and XDSL are running on same device
Or to set permanently, edit file:
# /etc/pulse/client.conf or ~/.config/pulse/client.conf default-server = tcp:127.0.0.1:4712
Now any media player running in this environment that makes use of PulseAudio client libraries, will stream its audio to XDSL app. You can forward X session display and sound to X server running on a PC as well but that needs a more complicated setup.
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:
# /etc/pulse/default.pa #ifexists module-console-kit.so #load-module module-console-kit #.endif
Otherwise daemon will fail to start if /usr/lib/pulse*/modules/module-console-kit.so
exists but consolekit
package isn't installed (which is deprecated, replaced by systemd-login
and no more present on many Linux repos).
Ensure that autospawn
is set to yes
so that we don't need to start daemon manually and it is auto started by Desktop Environment. Not necessary if we start daemon manually.
# /etc/pulse/client.conf # Autospawn a PulseAudio server/daemon when needed autospawn = yes
Now start pulseaudio daemon and note the value of source, for me it's auto_null.monitor
:
$ pulseaudio --start && pactl list | grep -A2 -i RUNNING $ DISPLAY=:0 pulseaudio --start
Load simple-protocol module:
$ DISPLAY=:0 pactl load-module module-simple-protocol-tcp rate=48000 format=s16le channels=2 source=auto_null.monitor record=true port=8000 listen=127.0.0.1
Or to set permanently, edit file:
$ echo 'load-module module-simple-protocol-tcp rate=48000 format=s16le channels=2 source=auto_null.monitor record=true port=8000 listen=127.0.0.1' >> /etc/pulse/default.pa
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:
$ DISPLAY=:0 start-pulseaudio-x11
Start Simple Player app and match bitrate
and port
set in above command i.e. 48000
and 8000
in my case. Don't use listen=127.0.0.1
if you want to listen on PC too.
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.
很好的消息,我可以使用TERMEX上的脉冲延伸,在TERMEX上使用PULSEAUDIO将音频提取到简单的协议播放器,但问题是此方法在offical pulseaudio上不起作用,因为它没有仅具有root的访问权限如果您的系统上有root,您可以提取简单协议播放器的音频
警告:如果音频不起作用,请检查下面的链接,因为有一些注释我没有提到
在Termux中执行此命令:
pactl list sources short
和:
下载应用程序
和:
echo -e " # Simple Protocol Player load-module module-simple-protocol-tcp source=OpenSL_ES_sink.monitor record=true port=12345 rate=44100" >> $PREFIX/etc/pulse/default.pa
并重新启动termux:
关闭Termux中的所有窗口
和:
pulseaudio -k
pulseaudio --start
或仅限:
pulseaudio --start
现在安装sox:
apt install sox
和播放声音:
play [file.mp3]
获取更多信息访问 link
Good news, I've been able to extract audio to Simple Protocol Player using the pulseaudio for Android on Termex but the problem is that this method does not work on the offical pulseaudio because it does not have access privileges for have root only if you have root on your system can you extract audio of Simple Protocol player
WARNING: If the audio does not work, check the link below because there are some notes I did not mention
Do this command :
pactl list sources short
And :
Download application
And :
echo -e "\n# Simple Protocol Player\n\nload-module module-simple-protocol-tcp source=OpenSL_ES_sink.monitor record=true port=12345 rate=44100" >> $PREFIX/etc/pulse/default.pa
And Restart Termux :
close all windows in termux
And :
pulseaudio -k
pulseaudio --start
or only :
pulseaudio --start
now install sox :
apt install sox
And Play sound :
play [file.mp3]
For more information visit Link
© 2022 it.wenda123.org All Rights Reserved. 问答之家 版权所有