Why does aplay work when pulseaudio is running and else not?
I have a ubuntu install with pulseaudio default installed. When pulseaudio is running this works: aplay -D hw:2,7 /usr/share/xbmc/sounds/Bursting\ Bubbles/nav.wav
But when no pulseaudio daemon is running it doesn't. The command doesn't give an error but 开发者_StackOverflow社区I can't hear a sound.
hw:2,7 is a Nvidia hdmi device.
Why is this? I can't figure it out.
Read this link.
It states that alsa (aplay) is configured to send its output to pulseaudio (which is your sound server) by default.
When your sound server is not running you will not be able to hear a sound as you have observed.
See also "PulseAudio Removal"section to detach it from alsa.
I hope this helps.
Using -D pulse
should do the trick like:
aplay -D pulse /usr/share/xbmc/sounds/Bursting\ Bubbles/nav.wav
That way aplay should use the pulseaudio device which you should be able to find with aplay -L
I had the exact same problem; I'm on Ubuntu 11.04 Natty. I had pulseaudio
startup disabled (e.g. 10.10 - How can I replace pulseaudio with alsa? - Ask Ubuntu or PulseAudio - ArchWiki):
$ cat /etc/pulse/client.conf | grep -ve '^#\|^$'
; default-sink =
; default-source =
; default-server =
autospawn = no
; daemon-binary = /usr/bin/pulseaudio
; extra-arguments = --log-target=syslog
; cookie-file =
; enable-shm = yes
; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB
$ pgrep pulse
$
In this context, I'd get:
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC269 Analog [ALC269 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
$ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=Intel
HDA Intel, ALC269 Analog
Default Audio Device
front:CARD=Intel,DEV=0
HDA Intel, ALC269 Analog
Front speakers
...
hw:CARD=Intel,DEV=0
HDA Intel, ALC269 Analog
Direct hardware device without any conversions
plughw:CARD=Intel,DEV=0
HDA Intel, ALC269 Analog
Hardware device with all software conversions
...
... but, even if I specified explicitly device hw0:0
, which should play samples on the device directly through ALSA, bypassing any server:
aplay -f cd -v -Dhw:0,0 --test-position loop_s16_stereo.wav
...
BUFPOS: avg5507/16508 min0/0 max22016/22016 (22016) (0:0/0)
BUFPOS: avg2754/19261 min0/0 max22016/22016 (22016) (0:0/0)
... and I'd see even the device settings - AND buffer positions being changed - and still, no sound? And even alsamixer
showed all controls set to the max!
Well, just by accident, I first enabled pulseaudio
:
pulseaudio --start
... and after like a minute of startup completed, then started System / Preferences / Sound, or here:
gnome-volume-control
... and I realized that there, right by the "Output volume" bar, there is a "Mute" checkbox - and it was checked! So I unchecked it, sound test started working; closed gnome-volume-control
and then shut down pulseaudio
again:
pulseaudio --kill
Now, I cannot start gnome-volume-control
anymore (regardless of the tips in 10.10 - How do I adjust the volume without pulseaudio? - Ask Ubuntu - apparently earlier versions allowed choice of a backend, via "Device" dropdown: old.png, but newer don't: new.png; and so without pulseaudio
, they will always fail with "Waiting for sound system to respond").
However, NOW when I run the aplay
command - it PLAYS (as it is supposed to)!
This mute is apparently related to a key under /desktop/gnome/sound/
path in gconf-editor
(see gnome - How to disable Alert volume from the command line? - Ask Ubuntu), but I can't tell which one really; I just note that at the moment, enable_esd
, event_sounds
and input_feedback_sounds
are all checked for me - and this apparently makes the aplay
command work properly, even without pulseaudio
.
Hope this helps someone,
Cheers!
精彩评论