我司自组网产品测试过程中,经常使用madplay来测试声卡功能是否正常。老产品大多采用了Qualcomm Atheros AR9344处理器,已经有现成的固件集成了madplay;这次的新产品采用了Qualcomm Atheros的QCA9558处理器,需要临时编译一个固件,才能测试声卡。在OpenWRT目录下,使用make menuconfig,勾选Sound - -> madplay,如下图
保存配置后直接使用make V=s 命令进行编译,会遇到如下问题
make[6]: Entering directory `/home/lics/data/code/ars-mb-a1/build_dir/target-mips_34kc_uClibc-0.9.33.2/alsa-lib-1.1.0/src/topology'
CC parser.lo
parser.c: In function 'snd_tplg_build_file':
parser.c:262:35: error: 'S_IRUSR' undeclared (first use in this function)
open(outfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
^
parser.c:262:35: note: each undeclared identifier is reported only once for each function it appears in
parser.c:262:45: error: 'S_IWUSR' undeclared (first use in this function)
open(outfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
^
parser.c: In function 'snd_tplg_build':
parser.c:330:35: error: 'S_IRUSR' undeclared (first use in this function)
open(outfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
^
parser.c:330:45: error: 'S_IWUSR' undeclared (first use in this function)
open(outfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
^
make[6]: *** [parser.lo] Error 1
如下图
很明显,这个错误是在编译alsa-lib过程中出现的。
ALSA是Advanced Linux Sound Architecture,高级Linux声音架构的简称,它在Linux操作系统上提供了音频和MIDI(Musical Instrument Digital Interface,音乐设备数字化接口)的支持。在2.6系列内核中,ALSA已经成为默认的声音子系统,用来替换2.4系列内核中的OSS(Open Sound System,开放声音系统)。ALSA的主要特性包括:高效地支持从消费类入门级声卡到专业级音频设备所有类型的音频接口,完全模块化的设计, 支持对称多处理(SMP)和线程安全,对OSS的向后兼容,以及提供了用户空间的alsa-lib库来简化应用程序的开发。
可见,madplay用到了alsa-lib库,问题就出在这里。查看了一下AR9344中的代码,发现当时针对这个问题做了个补丁,如下
--- a/src/topology/parser.c
+++ b/src/topology/parser.c
@@ -18,6 +18,7 @@#include "list.h"
#include "tplg_local.h"
+#include <sys/stat.h>/*
* Parse compound
将AR9344代码中的这个补丁移动至QCA9558代码中的对应目录,make clean之后再重新make,以上问题不再出现。将编译得到的固件下载至QCA9558板卡中,madplay命令正常运行,如下图
附上这个补丁给需要的读者
0001-topology-Add-missing-include-sys-stat.h-by-zencheer.patch
这个补丁需要放置在如下目录
feeds/packages/libs/alsa-lib/patches/
最后,附上madplay的简介
madplay is a command-line MPEG audio decoder and player based on the MAD library (libmad). MAD is a high-quality MPEG audio decoder. It currently supports MPEG-1 and the MPEG-2 extension to Lower Sampling Frequencies, as well as the so-called MPEG 2.5 format. All three audio layers (Layer I, Layer II, and Layer III a.k.a. MP3) are fully implemented.