惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Spread Privacy
Spread Privacy
V
Visual Studio Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recorded Future
Recorded Future
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
Apple Machine Learning Research
Apple Machine Learning Research
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
WordPress大学
WordPress大学
Recent Announcements
Recent Announcements
V
V2EX
The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
V
Vulnerabilities – Threatpost
C
Check Point Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
AI
AI
宝玉的分享
宝玉的分享
P
Proofpoint News Feed
量子位
Attack and Defense Labs
Attack and Defense Labs
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Privacy International News Feed
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
CERT Recently Published Vulnerability Notes
腾讯CDC
Latest news
Latest news
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
Blog — PlanetScale
Blog — PlanetScale
博客园_首页
美团技术团队
The Cloudflare Blog
T
Tenable Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
J
Java Code Geeks
SecWiki News
SecWiki News
Webroot Blog
Webroot Blog
N
News | PayPal Newsroom
博客园 - 叶小钗
博客园 - Franky

涵哲子居

针对于Win用户与Linux用户的战争问题 - 涵哲子居 夏雨自读 - 涵哲子居 初中最后的地生 - 涵哲子居 凌侮行径的本质探讨 - 涵哲子居 我对开源软件与自由软件的看法 - 涵哲子居 如何分类现代编程方法?我对当代编程的理解 - 涵哲子居 我们必须正确认识AI在开发中的作用 - 涵哲子居 浅显利益论 - 涵哲子居 稳定性与价格——深思如何选择“大厂”与“小厂”服务 - 涵哲子居 何为学,为何学 - 涵哲子居 无聊的人和无趣的人 - 涵哲子居 丙午杂言 - 涵哲子居 LeanCloud 停服: 一次关于服务选择的思考 - 涵哲子居 记一次使用Zellij的体验 - 涵哲子居 给fuwari添加NMP播放器 - 涵哲子居 [过时] Termux:通用基础包 - 涵哲子居 Hexo博客搭建之从入门到入土 - 涵哲子居 乙巳杂言 - 涵哲子居
Termux在Proot内播放音频文件的问题 - 涵哲子居
涵哲子 · 2026-02-05 · via 涵哲子居

昨天,我突发奇想打算找个TUI播放器在Termux的Arch里使用,但是,发生了一些令人不悦的小插曲。

问题#

当我找了一款名为 go-musicfox 的支持网易云的终端音乐播放器并尝试播放一首歌试试时,该应用报了一些错:

$ musicfox

ALSA lib confmisc.c:855:(parse_card) [error.core] cannot find card '0'

ALSA lib conf.c:5207:(_snd_config_evaluate) [error.core] function snd_func_card_inum returned error: No such file or directory

ALSA lib confmisc.c:422:(snd_func_concat) [error.core] error evaluating strings

ALSA lib conf.c:5207:(_snd_config_evaluate) [error.core] function snd_func_concat returned error: No such file or directory

ALSA lib confmisc.c:1342:(snd_func_refer) [error.core] error evaluating name

ALSA lib conf.c:5207:(_snd_config_evaluate) [error.core] function snd_func_refer returned error: No such file or directory

ALSA lib conf.c:5730:(snd_config_expand) [error.core] Evaluate error: No such file or directory

ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) [error.pcm] Unknown PCM default

ALSA lib confmisc.c:855:(parse_card) [error.core] cannot find card '0'

ALSA lib conf.c:5207:(_snd_config_evaluate) [error.core] function snd_func_card_inum returned error: No such file or directory

ALSA lib confmisc.c:422:(snd_func_concat) [error.core] error evaluating strings

ALSA lib conf.c:5207:(_snd_config_evaluate) [error.core] function snd_func_concat returned error: No such file or directory

ALSA lib confmisc.c:1342:(snd_func_refer) [error.core] error evaluating name

ALSA lib conf.c:5207:(_snd_config_evaluate) [error.core] function snd_func_refer returned error: No such file or directory

ALSA lib conf.c:5730:(snd_config_expand) [error.core] Evaluate error: No such file or directory

ALSA lib pcm.c:2722:(snd_pcm_open_noupdate) [error.pcm] Unknown PCM default

e…这说实话并不是一个所期望的理想输出。那到底是什么情况呢?通过这一大堆的error,我们可以很轻易的看出,似乎 ALSA 这个 Linux 内核底层的音频驱动架构 工作的并不太顺利。

ALSA 作为 Linux 内核的底层音频接口,需要直接操作硬件。其对所需求的应用提供音频接口,通过驱动等和硬件进行通信。当该应用 musicfox 尝试调用其中的一个接口发出播放的请求时,ALSA 需要定位可用设备并对音频通道等采取初始化。

然而,在 Termux 的 Proot 环境中,这条本应正常运行的链路发生了断裂。proot-distro虽然通过模拟实现了一个基本的、以发行版为基础的生产环境,但并未提供对一些硬件节点的直通访问。因此,尽管 musicfox 能正常加载 ALSA 库,但内核层面却返回了空集——其报错中的第一条”cannot find card ‘0’” 正是 ALSA 遍历其相关列表时无法寻找到任何有效声卡驱动的有力证据。

既然在 Proot 环境内无法直接地调用硬件,那么可以尝试使音频通过其他方式绕过 Proot,由 Termux 本体代为输出。即理论上可通过以下方案实现:

Proot 内的所需求应用 -> ALSA -> PulseAudio 客户端 -> Termux 本体所开启的 PulseAudio 服务器 -> Termux 本体调用硬件 -> 系统音频输出

其方案主要在于:在 Proot 内部配置 ALSA 的 PulseAudio 插件即如alsa-plugins-pulse(本文所提到的问题应用go-musicfox只能使用 ALSA),将原本指向硬件的相关请求重定向至 PulseAudio 的转接层;同时确保 Termux 本体已运行 pulseaudio 服务并开启监听。

如此,所需求应用便可通过中间层 PulseAudio 来正常播放音频了。那么,既然理论存在,实践开始!

解决#

配置 Termux 本体的 PulseAudio 服务#

  1. 在 Termux 安装 PulseAudio

在 Termux 内(非 proot-distro 环境内)执行:

  1. 在 Termux 内启动 PulseAudio 服务

使用下列命令来启动服务:

pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1" --exit-idle-time=-1

  1. (可选)将服务启动命令写入 Shell 配置文件

为了方便使用,可将该启动命令写入相关文件(如自动打开 proot-distro 的命令前或其他文件,根据自己情况配置,非必要)

配置 proot-distro 下的 PulseAudio 客户端#

  1. 在 proot-distro 内安装 PulseAudio

根据自己所使用的相应发行版的软件安装方法以安装该软件,以 Archlinux 做演示(包名视发行版而定):

sudo pacman -S pulseaudio

  1. 设置 PulseAudio 相关环境变量以配置服务器地址

根据自己所使用的相应 Shell 变量声明方法以配置 PULSE_SERVER 变量,以 Fish 做演示:

set -gx PULSE_SERVER 127.0.0.1

为了之后打开不用重新声明,可将该环境变量写入相关文件(如 fish.config 等 Shell 配置文件,根据自己情况配置,非必要)

  1. 在 proot-distro 内安装 alsa-plugins 插件

根据自己所使用的相应发行版的软件安装方法以安装该插件,以 Archlinux 做演示(包名视发行版而定):

sudo pacman -S alsa-plugins

  1. 新建~/.asoundrc 并写入以下内容:

pcm.!default {

type pulse

fallback "sysdefault"

hint {

show on

description "Default ALSA Output (PulseAudio)"

}

}

ctl.!default {

type pulse

fallback "sysdefault"

}

测试#

目前,我们已经完成了相关配置,接下来便可以在 Proot 环境内播放音频试一试了。

可见,musicfox已经可以正常播放了。