mpv, ffmpeg, vlc, any application using audio can't access PulseAudio when launched from GNOME Terminal. No problem when launching GNOME MPV or VLC from the application menu.
This is the error mpv:
[ao/alsa] Playback open error: Connection refused
[ao] Failed to initialize audio driver 'alsa'
Could not open/initialize audio device -> no sound.
This is the error from vlc:
alsa audio output error: cannot open ALSA device "default": Connection refused
main audio output error: module not functional
main decoder error: failed to create audio output
The user running the CLI and GUI applications is of course the same and belongs to the audio group. "pulseaudio --check" exits with return code 1, which tells me it is unable to check for a running pulseaudio process, which is wrong because there's one already running under the same user.
I would say that a I have this problem since at least month or so. I can definitely tell it used to work, but I dunno a which point it broke.
I also straced mpv. I believe this is the relevant part, but it does not tell me anything more than saying it is unable to talk to PulseAudio:
[pid 13120] <... read resumed>0x7ffe12797888, 16) = -1 EAGAIN (Resource temporarily unavailable)
[pid 13120] prctl(PR_GET_NAME, "pulseaudio") = 0
[pid 13120] getpid() = 13120
[pid 13120] sendto(5, "<11>Dec 28 10:58:59 pulseaudio[1"..., 92, MSG_NOSIGNAL, NULL, 0) = 92
[pid 13120] close(3) = 0
[pid 13120] close(4) = 0
[pid 13120] exit_group(1) = ?
[pid 13120] +++ exited with 1 +++
[pid 13090] <... wait4 resumed>[{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 13120
[pid 13090] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=13120, si_uid=1000, si_status=1, si_utime=0, si_stime=0} ---
[pid 13090] write(14, "x", 1) = 1
[pid 13090] write(2, "ALSA lib pulse.c:242:(pulse_conn"..., 37ALSA lib pulse.c:242:(pulse_connect) ) = 37
[pid 13090] write(2, "PulseAudio: Unable to connect: C"..., 50PulseAudio: Unable to connect: Connection refused
) = 50
[pid 13090] write(2, "\n", 1
) = 1
[pid 13090] futex(0x246ae10, FUTEX_UNLOCK_PI_PRIVATE) = 0
So far I could not find any helpful around. Thanks for any pointers to the underlying issue!