Difference between revisions of "Sound troubleshooting"
imported>ThorstenStaerk |
imported>ThorstenStaerk (basically this said that pulseaudio outputs sound) |
||
Line 39: | Line 39: | ||
= strace'ing sound = | = strace'ing sound = | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
I can hear sound on starting | I can hear sound on starting | ||
speaker-test | speaker-test |
Revision as of 22:03, 4 April 2015
So you want your Linux system to play sound, but it does not? Follow these steps to analyze and solve the problem:
Contents
The Methodology
If your cables and volume are okay
- Test if your sound card driver and cables are okay; play a test sound:
speaker-test
If you hear a sound
If you hear a sound, your cables and drivers are okay.
If you do not hear a sound
If you do not hear a sound, see if you get an error message.
If you do not get an error message
If you do not get an error message, it can be a driver issue. To find out, delete all sound devices and re-create them:
tweedleburg:~ # rm /dev/dsp* tweedleburg:~ # udevtrigger
Check again with dd if=/dev/urandom of=/dev/dsp. If you still do neither get an error message nor sound, it is most probably a driver issue. Get yourself a USB soundcard and proceed.
If you get an error message
If you get an error message like this:
tweedleburg:~ # dd if=/dev/urandom of=/dev/dsp dd: opening `/dev/dsp': Device or resource busy
You should find out what process blocks your sound card. Do this with the command lsof (list open files):
tweedleburg:~ # lsof | grep dsp mplayer 18251 root 4w CHR 14,35 14320 /dev/dsp2
You see, mplayer is blocking /dev/dsp2, you third soundcard. Now find out what soundcard you are using:
tweedleburg:~ # ll /dev/dsp* lrwxrwxrwx 1 root root 9 Jun 21 10:38 /dev/dsp -> /dev/dsp2 crw-rw---- 1 root audio 14, 19 Jun 21 10:36 /dev/dsp1 crw-rw---- 1 root audio 14, 35 Jun 21 10:36 /dev/dsp2
/dev/dsp points to /dev/dsp2, so the soundcard you are using is blocked by mplayer. So, kill mplayer if you are sure that is what you want:
killall mplayer
Knoppix
When there is no sound under Knoppix try
/etc/init.d/alsa-utils start
strace'ing sound
I can hear sound on starting
speaker-test
and I can see with strace that speaker-test triggers activity inside the pulseaudio process. But how do they communicate with each other? First of all let's find out all threads of the speaker-test process:
linux-fpbq:~ # ps -A | grep speaker-test 29145 pts/1 00:00:07 speaker-test linux-fpbq:~ # cd /proc/29145/fd linux-fpbq:/proc/29145/fd # ll total 0 lrwx------ 1 root root 64 Apr 4 15:44 0 -> /dev/pts/1 lrwx------ 1 root root 64 Apr 4 15:44 1 -> /dev/pts/1 lrwx------ 1 root root 64 Apr 4 15:44 2 -> /dev/pts/1 lr-x------ 1 root root 64 Apr 4 15:44 3 -> pipe:[114406] l-wx------ 1 root root 64 Apr 4 15:44 4 -> pipe:[114406] lr-x------ 1 root root 64 Apr 4 15:44 5 -> pipe:[114407] l-wx------ 1 root root 64 Apr 4 15:44 6 -> pipe:[114407] lrwx------ 1 root root 64 Apr 4 15:44 7 -> socket:[114414] linux-fpbq:/proc/29145/fd # lsof +c 15 | grep 114414 speaker-test 29145 root 7u unix 0xf5f19040 0t0 114414 socket threaded-ml 29145 29146 root 7u unix 0xf5f19040 0t0 114414 socket
ok, seems a socket that is open to speaker-test is also open to threaded-ml. So threaded-ml is a thread of speaker-test.
Now process 29145 is currently speaker-test and process 2289 is pulseaudio. strace'ing speaker-test with strace -ffp 29145 I find:
[pid 29146] recvmsg(7, {msg_name(0)=NULL, msg_iov(1)=[{"\0\0\0\0\377\377\377\377\0\0\0\20\0\0\0\0@\0\0\0", 20}], msg_controllen=24, {cmsg_len=24, cmsg_level=SOL_SOCKET, cmsg_type=SCM_CREDENTIALS{pid=2289, uid=0, gid=0}}, msg_flags=0}, 0) = 20
So speaker-test definitely gets messages from process 2289 and it gets them via file descriptor 7:
linux-fpbq:/proc/29145/fd # ll 7 lrwx------ 1 root root 64 Apr 4 15:44 7 -> socket:[114414]
Now strace'ing pulseaudio with the command strace -ffp 2289 I get:
[pid 2289] send(28, "\0\0\0\24\377\377\377\377\0\0\0\0\0\0\0\0\0\0\0\0L\0\0\0=L\377\377\377\377L\0"..., 40, MSG_NOSIGNAL) = 40
In other words, what pulseaudio sends via file descriptor 28 is received by speaker-test via file descriptor 7
linux-fpbq:/proc/2289/fd # ll 28 lrwx------ 1 root root 64 Apr 4 15:13 28 -> socket:[114415]
When restarting speaker-test with
strace speaker-test
I find a line
connect(7, {sa_family=AF_LOCAL, sun_path="/run/user/0/pulse/native"}, 110) = 0
and then file descriptor 7 plays the same role as before...
Look at man 2 connect and man 2 getpeername.
in the end solution was
linux-fpbq:/proc/32380/fd # ss -p | grep 186820 u_str ESTAB 0 0 /run/user/0/pulse/native 186821 * 186820 users:(("pulseaudio",2289,28)) u_str ESTAB 0 0 * 186820 * 186821 users:(("speaker-test",32380,7))