Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15358552
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类: LINUX

2009-12-08 12:55:45


1. 查看当前alsa版本
luther@gliethttp:~$ cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.20.
2. 下载driver和lib
luther@gliethttp:~$ wget ftp://ftp.alsa-project.org/pub/driver/alsa-driver-1.0.21.tar.bz2
luther@gliethttp:~$ wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.21a.tar.bz2
luther@gliethttp:~$ wget ftp://ftp.alsa-project.org/pub/utils/alsa-utils-1.0.21.tar.bz2
3. 首先关闭alsa,以防安装时出现异常错误
luther@gliethttp:~$ sudo /etc/init.d/alsa-utils stop
4. 编译alsa-lib库,应该保持alsa-driver和alsa-lib版本一致
luther@gliethttp:~/alsa-lib-1.0.21a$ ./configure
luther@gliethttp:~/alsa-lib-1.0.21a$ make -j4
luther@gliethttp:~/alsa-lib-1.0.21a$ sudo make install
5. 编译alsa-driver驱动
luther@gliethttp:~/alsa-driver-1.0.21$ ./configure
luther@gliethttp:~/alsa-driver-1.0.21$ make -j4
luther@gliethttp:~/alsa-driver-1.0.21$ sudo make install
6. 编译alsa-utils-1.0.21
luther@gliethttp:~/alsa-driver-1.0.21$ cd /usr/lib
luther@gliethttp:/usr/lib$ sudo ln -s libpanelw.so.5 libpanelw.so
=============================================================
安装libncursesw5库,经过对configure的log输出,发现编译测试libpanelw库时,连接了lncursesw,所以只要
gcc -o conftest -g -O2 -I/usr/include/ncursesw   -L/usr/lib conftest.c -lpanelw  -lncursesw -lasound -lm -ldl -lpthread
上面其中1个库不存在都会导致:configure: error: panelw library not found
=============================================================
luther@gliethttp:~$ sudo apt-get install libncursesw5-dev
luther@gliethttp:~/alsa-utils-1.0.21$ ./configure --disable-xmlto直接禁用xmlto即可,不用安装了
=============================================================
安装xmlto否则提示:xmlto: command not found
luther@gliethttp:~$ wget
luther@gliethttp:~/xmlto-0.0.20.orig$ ./configure
luther@gliethttp:~/xmlto-0.0.20.orig$ make -j4
luther@gliethttp:~/xmlto-0.0.20.orig$ sudo make install
=============================================================
luther@gliethttp:~/alsa-utils-1.0.21$ make -j4
luther@gliethttp:~/alsa-utils-1.0.21$ sudo make install
7. 重新启动pc
luther@gliethttp:~$ sudo reboot
8. 查看alsa版本
luther@gliethttp:~$ cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.21.
Compiled on Dec  8 2009 for kernel 2.6.31-14-generic (SMP).
9. 使用speaker-test
luther@gliethttp:~$ speaker-test -Dplug:front -c2
但是出现如下错误提示:
ALSA lib pcm_dmix.c:1010:(snd_pcm_dmix_open) unable to open slave
Playback open error: -16,Device or resource busy
原因:VirtualBox中winxp起来之后,占用了声音,所以出现这样的提示,将VirtualBox中winxp关闭即可正常,由此可以看出来speaker-test和aplay使用的OSS架构通过/dev/dsp设备节点操作声卡
10. 使用aplay播放wav文件-aplay能够自适应wav格式,这远比/dev/dsp的oss方便多,免去了cat 8k_8bits_mon.wav > /dev/dsp默认格式数据制作的麻烦[luther.gliethttp].
luther@gliethttp:~/.wine/drive_c/AudioConverter$ ll
total 459M
-rw-r--r-- 1 luther luther  75M 2009-12-08 13:39 chujia.wav
-rw-r--r-- 1 luther luther  75M 2009-12-08 13:40 chujia_48000.wav
-rw-r--r-- 1 luther luther 206M 2009-12-08 13:40 出嫁.mp3
-rw-r--r-- 1 luther luther 103M 2009-12-08 13:42 chujia-1.wav
-rw-r--r-- 1 luther luther 206M 2009-12-08 13:43 出嫁.wav
luther@gliethttp:~/.wine/drive_c/AudioConverter$ aplay 出嫁.wav
Playing WAVE 'chujia-2.wav' : Signed 24 bit Little Endian in 3bytes, Rate 44100 Hz, Channels 6
Invalid rate plugin version 10002
或者使用
luther@gliethttp:~/.wine/drive_c/AudioConverter$ aplay -Dplug:dmix 出嫁.wav
11. alsa测试5.1声道
luther@gliethttp:~$ speaker-test -Dplug:surround51 -c6 -twav

speaker-test 1.0.21

Playback device is plug:surround51
Stream parameters are 48000Hz, S16_LE, 6 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 3 to 5461
Period size range from 3 to 5461
Using max buffer size 5460
Periods = 4
was set period_size = 1365
was set buffer_size = 5460
 0 - Front Left
 4 - Center
 1 - Front Right
 3 - Rear Right
 2 - Rear Left
 5 - LFE
Time per period = 8.531396
 0 - Front Left
 4 - Center
或者使用plugin方式播放,但是仍然不能与mplayer同时播放
luther@gliethttp:~$ speaker-test -Dplug:front -c6 -twav
或者
luther@gliethttp:~/mp3$ speaker-test -Dplug:dmix -c6 -twav

打开pcm设备时用snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, 0)就直接打开hw而不会进过plugin层

当前pcm支持的所有功能插件--来自alsa-lib-1.0.21a/configure|21776|
PCM_PLUGIN_LIST="copy linear route mulaw alaw adpcm rate plug multi shm file null empty share meter hooks lfloat ladspa dmix dshare dsnoop asym iec958 softvol extplug ioplug mmap_emul"
aplay 能够smplayer同时播放,但是不能与终端上的mplayer一起播放,原因是这样的,mplayer默认使用oss方式操作声卡,因为oss是独占 声卡,所以当然就出现了,当aplay打开后,打开mplayer,因为声卡被aplay占用,mplayer将等待直到aplay释放声卡为止,而当 mplayer先打开播放,那么因为oss使得声卡被mplayer独占,所以aplay老是提示:Device or resource busy,解决方法就是,让mplayer使用alsa驱动播放数据:
luther@gliethttp:~/.wine/drive_c/AudioConverter$ mplayer -ao alsa 出嫁.mp3
luther@gliethttp:~/.wine/drive_c/AudioConverter$ aplay 出嫁.wav
这样mplayer和aplay就可以同时使用了[luther.gliethttp]

阅读(5163) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

lihaoran19822010-04-28 14:34:14

你好,我的系统上安装了mplayer和smplayer,但是用oss的驱动的时候两个播放的都很快,但是smplayer改用alsa后就正常了,我以为是音频驱动的问题,按照你说的方法装上了,先在mplayer可以用alsa播放,但还是速度很快,而且smplayer用alsa也是这样,请问是什么问题啊?

chinaunix网友2010-03-20 12:12:45

非常感谢! 已经把声卡驱动成功安装