2

Goal: Play music on a server, preferably using cmus, using SSH for player control.

First try: cmus
I run cmus in a terminal, literally nothing happens. It just loads (i guess). Tried cmus -vvvvv - Also just loads. Tried this and this - No changes to the issue. But: running it from a physical terminal on the computer works! (Both starting cmus, and playing audio successfully)

Second try: MOC
Running mocp opens it up, I can add files too. When trying to play a song, this message appears: can't open audio: device or resource busy MOC - No possible solution found.

Third try: mp3blaster
It starts. I can add files. It doesn't play: Failed to open sound device
Tried several suggestions (very outdated) from google, nothing helped. The one that seemed to help many others with this was padsc mp3blaster - But again, no help for me.

I am using ALSA with PulseAudio. Audio itself works fine. play or mplayer both work fine, but they don't offer libraries and playlists. Both work fine over SSH too.

I'm really clueless to what to do here since cmus doesn't print anything and mplayer works fine. I checked alsamixer and nothing is muted or disabled. There's only one single soundcard.

Not trying to have a broad suggest-me-something question here, I just added the other players since it might help find the issue, but the question aims to focus on getting cmus to work.

I've tried DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus cmus too (found here), same result.

Edit: TO BE CLEAR: The music is on the machine I SSH into and I want to play the music locally from the machine, controlling the CLI music player via SSH. Sorry for the confusion. I'm not trying to stream audio over SSH. I just want to use cmus in an SSH Terminal to play music that already is on the server I'm connecting to.

Edit: mplayer doesn't work anymore either, it used to all the time until I just tried:

AO: [pulse] Init failed: Connection refused
Failed to initialize audio driver 'pulse'
[AO_ALSA] alsa-lib: pcm_hw.c:1602:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0p' failed (-16): Device or resource busy
[AO_ALSA] alsa-lib: pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
[AO_ALSA] Playback open error: Device or resource busy
Failed to initialize audio driver 'alsa'
[AO SDL] Samplerate: 32000Hz Channels: Stereo Format s16le
[AO SDL] using aalib audio driver.
[AO SDL] Unable to open audio: No available audio device
Failed to initialize audio driver 'sdl:aalib'
Could not open/initialize audio device -> no sound.
Audio: no sound
Video: no video

Same for play:

ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
play FAIL formats: can't open output file `default': snd_pcm_open error: Device or resource busy

I've tried it as root too, same result. But: If I run either as the user which is logged into the X session (even over SSH), it works.

  • Generally you stream but see linuxquestions.org/questions/linux-networking-3/… – Panther Nov 5 '18 at 1:07
  • 1
    Maybe part of the environment exported from SSH is confusing the players. E.g. for mp3blaster, make sure it has selected the SDL audio driver, and then try forcing SDL to use the right backend with export SDL_AUDIODRIVER=pulseaudio or maybe export SDL_AUDIODRIVER=alsa – sourcejedi Nov 5 '18 at 9:44
  • @l0b0 Please see my edit, I'm not trying to stream. – confetti Nov 5 '18 at 12:02
  • Does the mplayer output show which audio device it eventually uses? – JigglyNaga Nov 5 '18 at 12:16
  • @JigglyNaga Just tried it, mplayer doesn't work anymore either. It used to work all the time, that's really weird. Added output to question. I've tried to run it as root too. Same with play. – confetti Nov 5 '18 at 12:35
2

I solved the issue with something rather obvious I missed this whole time. I had to allow other users (not the user logged into the X session under which the pulseaudio deamon runs) access to PA.

On the user under which the PA deamon runs:

# create pulse config dir in $HOME if it doesn't exist yet
mkdir .pulse
# copy the default PA config file
cp /etc/pulse/default.pa .pulse/default.pa
# edit the file
nano .pulse/default.pa

Then add onto the end of the file:

# make PA accessible by all users
load-module module-native-protocol-unix auth-anonymous=1 socket=/tmp/acpulsesocket

Then, logged in as the user from which you want to play audio:

# create pulse config dir in $HOME of the controlling user
mkdir .pulse
# create client configuration file
nano .pulse/client.conf

And paste the following into the file:

default-server = unix:/tmp/acpulsesocket

Save, restart pulseaudio: pulseaudio -k

Now cmus and every other player is working just fine.

1

I use mpd and ncmpcpp to achieve the same thing.

Start mpd on the server, then use ncmpcpp -h hostname_of_jukebox to control it from any other computer on the network.

No need for ssh besides starting mpd remotely (which can be autostarted as a service/daemon, if you want).

You can use other programs to control mpd, as well.

  • That looks very cool, but I consider the cmus-over-ssh approach to be simpler, especially when it's a remote location and you don't want to open another port globally. – confetti Nov 5 '18 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.