LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1250|回复: 9

再问 linux 声音问题

[复制链接]
发表于 2010-6-7 16:05:11 | 显示全部楼层 |阅读模式
用的是 kde 桌面,它要用 pulseaudio 作声音服务器。没有装 alsa-base, 因为装了它会用 dmix 代替 pulseaudio 作声音服务器,而 dmix 不怎么样。

现在的问题是,开机时有一提示:

Error: Driver 'pcspkr' is already registered, aborting...

根据
http://insanelabs.com/debian/deb ... aborting-%E2%80%9D/
上的说法,要安装 alsa-base 进行配置,那么我怎样配置 alsa-base 选用 pulseaudio 而不是它自己默认的 dmix 作声音服务器呢?

还有一点,如果用的是 pulseaudio, iceweasel 中的 flashplugin 是不能发声的,并且点了有声的 flash 甚至会使 iceweasel 崩溃,怎么使 flashplugin-nonfree 用 pulseaudio 发声。

我知道 adobe 的 flashplugin 完全是个鸡肋,
发表于 2010-6-7 16:49:20 | 显示全部楼层
不要把驱动driver跟服务器server搞混了。alsa是驱动,是更底层的东西。声音服务器最后要走驱动到声卡,而不是驱动要经过声音服务器。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-6-7 21:46:06 | 显示全部楼层
那么我的说法有点问题,我想问的是怎么配置使系统使用 pulseaudio 作为默认的声音服务器,而不是默认的 dmix,
回复 支持 反对

使用道具 举报

发表于 2010-6-7 22:37:40 | 显示全部楼层
你用了pulseaudio还是会走一遍dmix的,如果你用alsa的话,想绕过去就在pulseaudio设置直接使用hw,或者(抄自http://www.slackwiki.org/Disable_dmix_for_alsa):
  1. Open your favourite text editor and create the file "~/.asoundrc" for custom user configuration or "/etc/asound.conf" for global system configuration and write the following in it:
  2. pcm.!default {
  3. type plug
  4. slave.pcm hw
  5. }
复制代码
禁用dmix也就是设置默认直接送到硬件。这样的问题是所有程序都必须走pulseaudio,否则就独占声卡。不知道是不是所有软件都支持pulseaudio作为声音后端。
回复 支持 反对

使用道具 举报

发表于 2010-6-7 23:36:13 | 显示全部楼层
你可以看看 /etc/asound.conf 或  ~/.asoundrc,要是这两个文件中没有定义使用dmix插件,绝不会使用dmix。
回复 支持 反对

使用道具 举报

发表于 2010-6-7 23:39:08 | 显示全部楼层
如何设置alsa默认走pulseaudio (抄自http://www.pulseaudio.org/wiki/P ... *****Applications):
ALSA Applications

If the PulseAudio plugin for alsalibs is installed all applications with support for the ALSA API should be able to access a PulseAudio server. You need version 1.0.12 or newer of the ALSA packages for the PulseAudio plugin to be included.

To activate the driver edit /etc/asound.conf or ~/.asoundrc and add:

  1. pcm.pulse {
  2.     type pulse
  3. }

  4. ctl.pulse {
  5.     type pulse
  6. }
复制代码

Now you you can access the PulseAudio server under the virtual ALSA device pulse:

% aplay -Dpulse foo.wav
% amixer -Dpulse

If you want to make the PulseAudio driver the default, use something like this in the ALSA configuration files:


  1. pcm.!default {
  2.     type pulse
  3. }
  4. ctl.!default {
  5.     type pulse
  6. }
复制代码


If you select the default ALSA device to be "pulse", you need to make sure that PA doesn't try to open the "default" device for its own audio output. If you previously were loading module-alsa-sink without special device argument this means you have to change it to the raw "hw:0" devices. Example:

load-module module-alsa-sink device=hw:0
load-module module-alsa-source device=hw:0

If you use HAL this is not necessary, because the raw ALSA device strings are used anyway.

The PulseAudio plugin for ALSA supports audio playback, audio capturing and supports the mixer.
回复 支持 反对

使用道具 举报

发表于 2010-6-7 23:50:18 | 显示全部楼层
Post by abby;2095176
你可以看看 /etc/asound.conf 或  ~/.asoundrc,要是这两个文件中没有定义使用dmix插件,绝不会使用dmix。

现在的系统默认没有这两个文件,而且alsa默认就使用dmix的,证据就是,不用做任何设置,不支持混音的声卡也可以同时放多个声音。

说实话,真不知道为什么要用pulseaudio如果你不是想把声音送到别的机器的话。
pulseaudio在本地机器上的作用就是把几个声音混在一起然后送到声卡。这个作用跟alsa内置的dmix是一样的,也许效果会好一点。
可是如果你的耳朵很好,能听出这种差别,并且想要非常好的听cd之类,那你就应该让播放软件独占声卡,这样才会受影响。
如果几个声音都混在一起了,还谈什么声音效果呢?
难道是想用电脑同时放出各种乐器的声音然后自己调配出高质量音乐?!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-6-8 00:24:53 | 显示全部楼层
回楼上的,

mpd 用 dmix 混音的话 cpu 占用在 6% 左右,而 pulseaudio 只有 %1 而已,
回复 支持 反对

使用道具 举报

发表于 2010-6-8 01:41:01 | 显示全部楼层
真的是哦,什么时候alsa变成这样,缺省就有混音的呢?   但对比之下,用我以前写的dmix配置只占1%cpu,pulseaudio要占用3%cpu,而不要/etc/asound.conf之后,alsa居然要占用11%到25%的cpu!现在猜测是dmix缺省音频频率不是硬件频率,需要转换。

shit~~!!! 应用程序占用cpu有区别的,我的机子ogg123用alsa时1%cpu,audacious2要6%cpu,用pulse时还要加上每个发声进程多占1%。总的说还是自己配置dmix占CPU少些啊,pulseaudio主要好处有各种特性。

题外话:
还是jackd占用cpu最少。
最后,想串通各种后端:  pulse用jackd作后端 ,pulse用了16%cpu;alsa用jackd作pcm.default ,没播10秒就卡住了。得不偿失。

音质来说,pulse与alsa的dmix一样。后来插上creative sb audigy2,顿时觉得这钱应该花的! 播放一首质量很差的歌,内置声卡明显有杂音,audigy2的效果简直就像高质量文件一样动听。迟些一定要到淘宝上找一只。
回复 支持 反对

使用道具 举报

发表于 2010-6-9 02:24:04 | 显示全部楼层
dmix默认是48000,播放44100的mp3,cpu占用率mplayer为6~7%,mpg123为7%。
自己设置成44100后,cpu占用率mplayer为4~5%,mpg123为3%。
设置成跟音频文件一样的比率可以节省一些cpu使用量。
不过官方wiki里提到把48000(比如dvd)降成44100时可能会有问题,比如不同步。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表