Resposta curta, registrada com raiz reside nos consoles virtuais (por exemplo, Ctrl + Alt + N), inicie o daemon pulseaudio e reproduza o vídeo:
/usr/bin/pulseaudio --start
mplayer -vo fbdev2 test.mp4
[Importante] tentou com /usr/bin/pulseaudio --system
não é necessário aqui. E você deve residir raiz (não sudo ou mesmo su) e consoles virtuais para executar toda a etapa incluindo daemon iniciar e reproduzir vídeo. Nenhum efeito se você tentar su
e iniciar o daemon dentro do terminal virtual do X Session.
Resposta longa, como descubro:
Primeiro passo, abra um novo terminal com o novo console virtual. A razão por trás disso é que a sessão X provavelmente não funcionará com framebuffer.
Agora eu preciso saber se é limitado ao mplayer ou não. Então eu tentei com o comando play para tocar música básica, por ex. sons internos do kde, play /usr/share/sounds/KDE-Im-Cant-Connect.ogg
com o sudo no novo console virtual:
$ sudo play /usr/share/sounds/KDE-Im-Cant-Connect.ogg
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
play FAIL formats: can't open output file 'default': snd_pcm_open error: Connection refused
$
Não se limita a mplayer ou música complexa.
Então, agora temos que nos aprofundar na diferença entre got sound e sem som . vamos tentar strace no usuário normal na sessão X (tem som), (nome do arquivo su1.log é enganoso aqui, nada a ver com su):
strace -o /tmp/su1.log -v -s 1000000 play /usr/share/sounds/KDE-Im-Cant-Connect.ogg
e console virtual (sem som):
strace -o /tmp/su2.log -v -s 1000000 play /usr/share/sounds/KDE-Im-Cant-Connect.ogg
vi /tmp/su2.log, navegue até o final:
connect(8, {sa_family=AF_LOCAL, sun_path="/run/user/0/pulse/native"}, 110) = -1 ENOENT (No such file or directory)
close(8) = 0
socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0) = 8
fcntl(8, F_GETFD) = 0x1 (flags FD_CLOEXEC)
setsockopt(8, SOL_SOCKET, SO_PRIORITY, [6], 4) = 0
fcntl(8, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(8, {sa_family=AF_LOCAL, sun_path="/var/run/pulse/native"}, 110) = -1 ENOENT (No such file or directory)
close(8) = 0
write(5, "x", 1) = 1
write(2, "ALSA lib pulse.c:243:(pulse_connect) ", 37) = 37
write(2, "PulseAudio: Unable to connect: Connection refused\n", 50) = 50
write(2, "\n", 1) = 1
futex(0x135a8e0, FUTEX_UNLOCK_PI_PRIVATE, 0) = 0
sendto(7, "W", 1, MSG_NOSIGNAL, NULL, 0) = -1 ENOTSOCK (Socket operation on non-socket)
write(7, "W", 1) = 1
futex(0x135a8e0, FUTEX_UNLOCK_PI_PRIVATE, 0) = 0
futex(0x7f34065089d0, FUTEX_WAIT, 7956, NULL) = -1 EAGAIN (Resource temporarily unavailable)
munmap(0x7f3406509000, 67112960) = 0
unlink("/dev/shm/pulse-shm-3719764676") = 0
close(6) = 0
close(7) = 0
close(5) = 0
close(4) = 0
write(2, "play FAIL formats: ", 19) = 19
write(2, "can't open output file 'default': snd_pcm_open error: Connection refused", 72) = 72
write(2, "\n", 1) = 1
E também o kdiff3 para comparar "open (":
de ambos os logs$ grep 'open(' /tmp/su1.log > /tmp/su1_open.log
$ grep 'open(' /tmp/su2.log > /tmp/su2_open.log
$ kdiff3 /tmp/su1_open.log /tmp/su2_open.log
$
Éumpoucodiferentepara/run/user/0/pulse,agoraeupercebiuid1000(usuárionormal)e0(root),emque"/ run / user / 1000 / pulse "e" run / user / 0 / pulse "só pedem quando jogar com o uid 1000 e 0 respectivamente:
$ grep 'run/user/0/pulse' /tmp/su1.log
$ grep 'run/user/1000/pulse' /tmp/su2.log
$ grep 'run/user/1000/pulse' /tmp/su1.log
recvmsg(5, {msg_name(0)=NULL, msg_iov(1)=[{"# l /run/user/0/pulse/
total 0
84490 drwx------. 4 root root 80 Jul 22 01:44 ..
86867 drwx------. 2 root root 40 Jul 22 01:44 .
#
# l /run/user/1000/pulse/
total 4.0K
29328 -rw-------. 1 xiaobai xiaobai 5 Jul 22 00:58 pid
30544 srwxrwxrwx. 1 xiaobai xiaobai 0 Jul 22 00:58 native
31058 drwx------. 2 xiaobai xiaobai 80 Jul 22 00:58 .
27430 drwx------. 14 xiaobai xiaobai 280 Jul 22 01:06 ..
# l /run/user/1000/pulse/native
30544 srwxrwxrwx. 1 xiaobai xiaobai 0 Jul 22 00:58 /run/user/1000/pulse/native
# file /run/user/1000/pulse/native
/run/user/1000/pulse/native: socket
# file /run/user/1000/pulse/pid
/run/user/1000/pulse/pid: ASCII text
# cat /run/user/1000/pulse/pid
2205
#
# pulseaudio --check
# pulseaudio --check -v
I: [pulseaudio] main.c: Daemon running as PID 2205
#
# ps aux|grep 2205
xiaobai 2205 0.0 0.2 565980 11080 ? S<l 00:58 0:01 /usr/bin/pulseaudio --start
root 8747 0.0 0.0 113008 2300 pts/2 S+ 01:58 0:00 grep --color=auto 2205
#
# /usr/bin/pulseaudio --start
W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).
N: [pulseaudio] main.c: User-configured server at {34959d136592433aad171659a5cd523f}unix:/run/user/1000/pulse/native, which appears to be local. Probing deeper.
# l /run/user/0/
total 0
17794 drwxr-xr-x. 4 root root 80 Jul 22 01:44 ..
85629 drwxr-xr-x. 2 root root 80 Jul 22 01:44 systemd
84490 drwx------. 4 root root 80 Jul 22 01:44 .
86867 drwx------. 2 root root 80 Jul 22 02:02 pulse
# cat /run/user/0/pulse/pid
9731
#
/usr/bin/pulseaudio --start
mplayer -vo fbdev2 test.mp4
$ sudo play /usr/share/sounds/KDE-Im-Cant-Connect.ogg
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
play FAIL formats: can't open output file 'default': snd_pcm_open error: Connection refused
$
connect(8, {sa_family=AF_LOCAL, sun_path="/run/user/0/pulse/native"}, 110) = -1 ENOENT (No such file or directory)
close(8) = 0
socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0) = 8
fcntl(8, F_GETFD) = 0x1 (flags FD_CLOEXEC)
setsockopt(8, SOL_SOCKET, SO_PRIORITY, [6], 4) = 0
fcntl(8, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(8, {sa_family=AF_LOCAL, sun_path="/var/run/pulse/native"}, 110) = -1 ENOENT (No such file or directory)
close(8) = 0
write(5, "x", 1) = 1
write(2, "ALSA lib pulse.c:243:(pulse_connect) ", 37) = 37
write(2, "PulseAudio: Unable to connect: Connection refused\n", 50) = 50
write(2, "\n", 1) = 1
futex(0x135a8e0, FUTEX_UNLOCK_PI_PRIVATE, 0) = 0
sendto(7, "W", 1, MSG_NOSIGNAL, NULL, 0) = -1 ENOTSOCK (Socket operation on non-socket)
write(7, "W", 1) = 1
futex(0x135a8e0, FUTEX_UNLOCK_PI_PRIVATE, 0) = 0
futex(0x7f34065089d0, FUTEX_WAIT, 7956, NULL) = -1 EAGAIN (Resource temporarily unavailable)
munmap(0x7f3406509000, 67112960) = 0
unlink("/dev/shm/pulse-shm-3719764676") = 0
close(6) = 0
close(7) = 0
close(5) = 0
close(4) = 0
write(2, "play FAIL formats: ", 19) = 19
write(2, "can't open output file 'default': snd_pcm_open error: Connection refused", 72) = 72
write(2, "\n", 1) = 1
$ grep 'open(' /tmp/su1.log > /tmp/su1_open.log
$ grep 'open(' /tmp/su2.log > /tmp/su2_open.log
$ kdiff3 /tmp/su1_open.log /tmp/su2_open.log
$
$ grep 'run/user/0/pulse' /tmp/su1.log
$ grep 'run/user/1000/pulse' /tmp/su2.log
$ grep 'run/user/1000/pulse' /tmp/su1.log
recvmsg(5, {msg_name(0)=NULL, msg_iov(1)=[{"# l /run/user/0/pulse/
total 0
84490 drwx------. 4 root root 80 Jul 22 01:44 ..
86867 drwx------. 2 root root 40 Jul 22 01:44 .
#
# l /run/user/1000/pulse/
total 4.0K
29328 -rw-------. 1 xiaobai xiaobai 5 Jul 22 00:58 pid
30544 srwxrwxrwx. 1 xiaobai xiaobai 0 Jul 22 00:58 native
31058 drwx------. 2 xiaobai xiaobai 80 Jul 22 00:58 .
27430 drwx------. 14 xiaobai xiaobai 280 Jul 22 01:06 ..
# l /run/user/1000/pulse/native
30544 srwxrwxrwx. 1 xiaobai xiaobai 0 Jul 22 00:58 /run/user/1000/pulse/native
# file /run/user/1000/pulse/native
/run/user/1000/pulse/native: socket
# file /run/user/1000/pulse/pid
/run/user/1000/pulse/pid: ASCII text
# cat /run/user/1000/pulse/pid
2205
#
# pulseaudio --check
# pulseaudio --check -v
I: [pulseaudio] main.c: Daemon running as PID 2205
#
# ps aux|grep 2205
xiaobai 2205 0.0 0.2 565980 11080 ? S<l 00:58 0:01 /usr/bin/pulseaudio --start
root 8747 0.0 0.0 113008 2300 pts/2 S+ 01:58 0:00 grep --color=auto 2205
#
# /usr/bin/pulseaudio --start
W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).
N: [pulseaudio] main.c: User-configured server at {34959d136592433aad171659a5cd523f}unix:/run/user/1000/pulse/native, which appears to be local. Probing deeper.
# l /run/user/0/
total 0
17794 drwxr-xr-x. 4 root root 80 Jul 22 01:44 ..
85629 drwxr-xr-x. 2 root root 80 Jul 22 01:44 systemd
84490 drwx------. 4 root root 80 Jul 22 01:44 .
86867 drwx------. 2 root root 80 Jul 22 02:02 pulse
# cat /run/user/0/pulse/pid
9731
#
%pre%%pre%%pre%%pre%%pre%B%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%{34959d136592433aad171659a5cd523f}unix:/run/user/1000/pulse/native%pre%%pre%", 4096}], msg_controllen=0, msg_flags=0}, 0) = 100
connect(5, {sa_family=AF_LOCAL, sun_path="/run/user/1000/pulse/native"}, 110) = 0
recvmsg(6, {msg_name(0)=NULL, msg_iov(1)=[{"%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%B%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%{34959d136592433aad171659a5cd523f}unix:/run/user/1000/pulse/native%pre%%pre%", 4096}], msg_controllen=0, msg_flags=0}, 0) = 100
connect(6, {sa_family=AF_LOCAL, sun_path="/run/user/1000/pulse/native"}, 110) = 0
$ grep 'run/user/0/pulse' /tmp/su2.log
mkdir("/run/user/0/pulse", 0700) = -1 EEXIST (File exists)
open("/run/user/0/pulse", O_RDONLY|O_NOCTTY|O_NOFOLLOW|O_CLOEXEC) = 5
lstat("/run/user/0/pulse", {st_dev=makedev(0, 41), st_ino=86867, st_mode=S_IFDIR|0700, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=40, st_atime=2015/07/22-01:44:45, st_mtime=2015/07/22-01:44:45, st_ctime=2015/07/22-01:47:59}) = 0
lstat("/run/user/0/pulse", {st_dev=makedev(0, 41), st_ino=86867, st_mode=S_IFDIR|0700, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=40, st_atime=2015/07/22-01:44:45, st_mtime=2015/07/22-01:44:45, st_ctime=2015/07/22-01:47:59}) = 0
connect(5, {sa_family=AF_LOCAL, sun_path="/run/user/0/pulse/native"}, 110) = -1 ENOENT (No such file or directory)
mkdir("/run/user/0/pulse", 0700) = -1 EEXIST (File exists)
open("/run/user/0/pulse", O_RDONLY|O_NOCTTY|O_NOFOLLOW|O_CLOEXEC) = 8
lstat("/run/user/0/pulse", {st_dev=makedev(0, 41), st_ino=86867, st_mode=S_IFDIR|0700, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=40, st_atime=2015/07/22-01:44:45, st_mtime=2015/07/22-01:44:45, st_ctime=2015/07/22-01:47:59}) = 0
lstat("/run/user/0/pulse", {st_dev=makedev(0, 41), st_ino=86867, st_mode=S_IFDIR|0700, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=40, st_atime=2015/07/22-01:44:45, st_mtime=2015/07/22-01:44:45, st_ctime=2015/07/22-01:47:59}) = 0
connect(8, {sa_family=AF_LOCAL, sun_path="/run/user/0/pulse/native"}, 110) = -1 ENOENT (No such file or directory)
$
B%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%{34959d136592433aad171659a5cd523f}unix:/run/user/1000/pulse/native%pre%%pre%", 4096}], msg_controllen=0, msg_flags=0}, 0) = 100
connect(5, {sa_family=AF_LOCAL, sun_path="/run/user/1000/pulse/native"}, 110) = 0
recvmsg(6, {msg_name(0)=NULL, msg_iov(1)=[{"%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%B%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%{34959d136592433aad171659a5cd523f}unix:/run/user/1000/pulse/native%pre%%pre%", 4096}], msg_controllen=0, msg_flags=0}, 0) = 100
connect(6, {sa_family=AF_LOCAL, sun_path="/run/user/1000/pulse/native"}, 110) = 0
$ grep 'run/user/0/pulse' /tmp/su2.log
mkdir("/run/user/0/pulse", 0700) = -1 EEXIST (File exists)
open("/run/user/0/pulse", O_RDONLY|O_NOCTTY|O_NOFOLLOW|O_CLOEXEC) = 5
lstat("/run/user/0/pulse", {st_dev=makedev(0, 41), st_ino=86867, st_mode=S_IFDIR|0700, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=40, st_atime=2015/07/22-01:44:45, st_mtime=2015/07/22-01:44:45, st_ctime=2015/07/22-01:47:59}) = 0
lstat("/run/user/0/pulse", {st_dev=makedev(0, 41), st_ino=86867, st_mode=S_IFDIR|0700, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=40, st_atime=2015/07/22-01:44:45, st_mtime=2015/07/22-01:44:45, st_ctime=2015/07/22-01:47:59}) = 0
connect(5, {sa_family=AF_LOCAL, sun_path="/run/user/0/pulse/native"}, 110) = -1 ENOENT (No such file or directory)
mkdir("/run/user/0/pulse", 0700) = -1 EEXIST (File exists)
open("/run/user/0/pulse", O_RDONLY|O_NOCTTY|O_NOFOLLOW|O_CLOEXEC) = 8
lstat("/run/user/0/pulse", {st_dev=makedev(0, 41), st_ino=86867, st_mode=S_IFDIR|0700, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=40, st_atime=2015/07/22-01:44:45, st_mtime=2015/07/22-01:44:45, st_ctime=2015/07/22-01:47:59}) = 0
lstat("/run/user/0/pulse", {st_dev=makedev(0, 41), st_ino=86867, st_mode=S_IFDIR|0700, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=40, st_atime=2015/07/22-01:44:45, st_mtime=2015/07/22-01:44:45, st_ctime=2015/07/22-01:47:59}) = 0
connect(8, {sa_family=AF_LOCAL, sun_path="/run/user/0/pulse/native"}, 110) = -1 ENOENT (No such file or directory)
$
"Nenhum arquivo ou diretório" somente quando / run / user / 0 / pulse, vamos verificar (com root):
%pre%Neste ponto, eu sei que o pid 2205 está em execução e deveria existir com o uid 0 para que funcione.
Eu pesquisei no Google e descobri pulseaudio --check :
%pre%Tentei com arg verbose, peguei! o daemon está rodando como pid 2205 , provou o que eu observei acima:
%pre%Então, agora eu confio que o áudio de pulso pode fazer isso funcionar. Verifique o pid 2205 para descobrir como foi acionado:
%pre% Então, vamos tentar /usr/bin/pulseaudio --start
:
E agora, o novo diretório de pulsos aparece sob o uid 0 com o novo pid:
%pre% E finalmente o som funciona. Experimente você mesmo agora com mplayer -vo fbdev2 test.mp4
[Nota] su
pode funcionar em alguma circunstância estranha. Por exemplo. Sessão X 11 - > Ctrl + Alt + 2 - > faça o login com o uid 1000 - > su - root - > /usr/bin/pulseaudio --start
e mplayer -vo fbdev2 funcionam bem. Então Ctrl + Alt + 3 - > faça o login com root - > /usr/bin/pulseaudio --start
e mplayer funcionam juntos - > volte Ctrl + Alt + 2 - > O mplayer no console virtual 2 não funciona mais.