mpd stops communicating with ALSA after system upgrade

Need help with MPD?
Post Reply
delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

mpd stops communicating with ALSA after system upgrade

Post by delooper » January 19th, 2018, 4:47 pm

Greetings,

I've had mpd and alsa driving a headless linux box to serve music to a DSP for about two years now. It's been running well. . . until a couple of days ago when a system upgrade seems to have caused a communication problem between mpd and alsa. i.e. I can still drive mpd from my cell phone. Alsa just doesn't receive the music from mpd, at least, not in a way that makes it to the speakers.

The new error messages I'm seeing in the mpd.log file, since the system upgrade are:

Code: Select all

zeroconf: No global port, disabling zeroconf​
errno: failed to open log file "/var/log/mpd/mpd.log" (config line 38): Permission denied​
output: Failed to open mixer for 'USB Streamer - LX521.4'​
db: No such directory
alsa_mixer: Failed to read mixer for 'USB Streamer - LX521.4': no such mixer control: PCM​
It's odd the complaint that it can't open the mpd.log file appears in the mpd.log file. Should it be clear what can't open the mpd.log file? Given that my configuration has not changed at all, i.e. /etc/mpd.conf and /etc/asound are the same as before the upgrade, my first guess is there is a permission problem. I've run through the mpd documentation and tried to make sure all the permissions are correct but I'm at a loss on what could be going wrong.

The mixer error occurs later, so I'm hopeful the error is really a permission error and those later errors are extraneous, but perhaps they are not? My alsa configuration is a little non-standard in that I have done a channel remapping by changing the ctl and pcm defaults -- my left and right speakers are channels 8 and 9 respectively.

Does this ring any bells?

My audio_output part of mpd.conf is pretty simple:

Code: Select all

audio_output {
        type            "alsa"
        name            "USB Streamer - LX521.4"
}
Any ideas what the problem is? Unfortunately I have a very weak understanding of how Alsa works, so I'm rather confused about this problem.

max
Forum team
Posts: 863
Joined: January 15th, 2013, 3:43 pm

Re: mpd stops communicating with ALSA after system upgrade

Post by max » January 19th, 2018, 8:17 pm


delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

Re: mpd stops communicating with ALSA after system upgrade

Post by delooper » January 20th, 2018, 3:34 am

Thanks for the link.

I'd like to use that but they have the requirement of using the most recent mpd. I have a LUbuntu distribution which is more than a dozen revisions away from the most recent mpd. I've been trying to compile from source. Can do that, but installing the freshly-compiled mpd is giving me trouble.

Looking at the revision history, it does not appear that what I'm dealing with is a bug. It's probably just a faulty installation, brought on by a LUbuntu auto-update that made a small change that mpd does not like. That's my guess, anyhow. But I can't tell which would be less work as both involve things I don't understand.

So I uninstalled mpd, then reinstalled it, using apt. Essentially the same problem but the error message in /var/log/mpd now is:
output: Failed to open mixer for 'USB Streamer - LX521.4'
which is interesting because before there was the additional phrase "no such mixer control: PCM".

Does anyone have a sense for how these error messages work? Is there any way to decipher them, other than reading the source code? I haven't come across any on-line documentation that is this specific.

edit: I realize this is because I had verbose logging turned off. I turn verbose logging back on and I get the previous error messages:

Code: Select all

Jan 19 20:53 : alsa_mixer: Failed to read mixer for 'USB Streamer - LX521.4': no such mixer control: PCM

...

Jan 19 20:53 : output: opened plugin=alsa name="USB Streamer - LX521.4" audio_format=44100:16:2
Jan 19 20:53 : output: Failed to open mixer for 'USB Streamer - LX521.4'

max
Forum team
Posts: 863
Joined: January 15th, 2013, 3:43 pm

Re: mpd stops communicating with ALSA after system upgrade

Post by max » January 20th, 2018, 6:49 am

delooper wrote:
January 20th, 2018, 3:34 am
I'd like to use that but they have the requirement of using the most recent mpd. I have a LUbuntu distribution which is more than a dozen revisions away from the most recent mpd.
"They" is me; I wrote that page. And there are good reasons why I refuse to even read your support request if you don't follow these instructions, which indeed includes that you need to have the latest MPD version. Sorry.

skidoo
Posts: 162
Joined: April 28th, 2013, 10:06 pm
Location: Western Germany

Re: mpd stops communicating with ALSA after system upgrade

Post by skidoo » January 20th, 2018, 7:04 pm

Debian and *buntu MPDs are ancient. Compile from source with package parameters as a starter. BTW: Pulseaudio installed? Your mpd.conf does not shoẃ a mixer device... Google for ALSA debugging.

delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

Re: mpd stops communicating with ALSA after system upgrade

Post by delooper » January 20th, 2018, 9:47 pm

Do you know some good resources for installing a freshly-compiled mpd?

When I installed from the package (in LUbuntu) it created the mpd user and audio group. I've uninstalled, so the mpd user and audio group is gone.

After compiling, and "make install", I copied my mpd.conf file to /etc/mpd.conf. I want to run mpd via the "mpd user".

mpd complained it could not find the configuration file. . . so I re-created the mpd user and audio groups, and make sure /etc/mpd.conf was owned by mpd and in the audio group. I've put mpd in the audio group, and my own user. I made mpd's home dir /var/lib/mpd and made its owner/group mpd/audio.

Is the mpd user home directory used for anything? I ensured it was owned by mpd and in the audio group, just in case.

I'm still getting the same complaint from mpd:

Code: Select all

/etc$ mpd --stdout --no-daemon --verbose
exception: No configuration file found
/etc$ ls -la mpd*
-rw-r--r-- 1 mpd audio 14288 Jan 20 12:38 mpd.conf
I'm reading the documentation at www.musicpd.org, but it does not seem to mention some of the most basic things, like the user setting in the config file and what it's used for. Similarly, file permissions are not gone into in much detail.

delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

Re: mpd stops communicating with ALSA after system upgrade

Post by delooper » January 20th, 2018, 9:55 pm

First I'd like to very enthusiastically thank you for the feedback!
skidoo wrote:
January 20th, 2018, 7:04 pm
Debian and *buntu MPDs are ancient. Compile from source with package parameters as a starter. BTW: Pulseaudio installed? Your mpd.conf does not shoẃ a mixer device... Google for ALSA debugging.
I've tried both specifying a mixer and not. Before this system update I did not specify the mixer and mpd communicated perfectly with ALSA.

After the update, seeing the mixer complaint I modified the audio_output part, thinking that might help. Trying this:

Code: Select all

audio_output {
        type            "alsa"
        name            "USB Streamer - LX521.4"
        mixer_control   "USBStreamer Output"
}
The error message changes to:
alsa_output: "USB Streamer - LX521.4" [alsa] failed to play: Broken pipe
I do not know if this is relevant, but a rather important item could be my /etc/asound.conf file:
pcm.usbSTR {
type hw
card USBStreamer
device 0
}

pcm.usbREMAP {
type plug
slave.pcm usbSTR
ttable.0.8 1
ttable.1.9 1
}

pcm.!default {
type plug
slave.pcm usbREMAP
}

ctl.!default {
type plug
slave.pcm usbREMAP
}
Regarding audio_output, here is my amixer output:

Code: Select all

amixer -c 1
Simple mixer control 'Mic',0
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right - Rear Left - Rear Right - Front Center - Woofer - Side Left - Side Right - Rear Center - ?
  Limits: Capture 0 - 255
  Front Left: Capture 255 [100%] [0.00dB] [on]
  Front Right: Capture 255 [100%] [0.00dB] [on]
  Rear Left: Capture 255 [100%] [0.00dB] [on]
  Rear Right: Capture 255 [100%] [0.00dB] [on]
  Front Center: Capture 255 [100%] [0.00dB] [on]
  Woofer: Capture 255 [100%] [0.00dB] [on]
  Side Left: Capture 255 [100%] [0.00dB] [on]
  Side Right: Capture 255 [100%] [0.00dB] [on]
  Rear Center: Capture 255 [100%] [0.00dB] [on]
  ?: Capture 255 [100%] [0.00dB] [on]
Simple mixer control 'Mic',1
  Capabilities: cvolume cvolume-joined cswitch cswitch-joined
  Capture channels: Mono
  Limits: Capture 0 - 255
  Mono: Capture 255 [100%] [0.00dB] [on]
Simple mixer control 'USBStreamer Clock Selector',0
  Capabilities: enum
  Items: 'USBStreamer Internal Clock' 'USBStreamer TOSLINK Clock'
  Item0: 'USBStreamer Internal Clock'
Simple mixer control 'USBStreamer Output',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right - Rear Left - Rear Right - Front Center - Woofer - Side Left - Side Right - Rear Center - ?
  Limits: Playback 0 - 255
  Mono:
  Front Left: Playback 255 [100%] [0.00dB] [on]
  Front Right: Playback 255 [100%] [0.00dB] [on]
  Rear Left: Playback 255 [100%] [0.00dB] [on]
  Rear Right: Playback 255 [100%] [0.00dB] [on]
  Front Center: Playback 255 [100%] [0.00dB] [on]
  Woofer: Playback 255 [100%] [0.00dB] [on]
  Side Left: Playback 255 [100%] [0.00dB] [on]
  Side Right: Playback 255 [100%] [0.00dB] [on]
  Rear Center: Playback 255 [100%] [0.00dB] [on]
  ?: Playback 255 [100%] [0.00dB] [on]
Simple mixer control 'USBStreamer Output',1
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 255
  Mono: Playback 249 [98%] [-3.00dB] [on]

delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

Re: mpd stops communicating with ALSA after system upgrade

Post by delooper » January 20th, 2018, 10:48 pm

A rather non-mpd technical question: I'm going through the build log for the ubuntu mpd package:

https://launchpadlibrarian.net/29814691 ... ING.txt.gz

and I don't see where the details are that would create the mpd user or the audio group. I don't know much about how such packages are constructed. Where would you look for this information? I want to ensure my mpd user and audio groups are set up appropriately, and anything else that might need to be set up.

skidoo
Posts: 162
Joined: April 28th, 2013, 10:06 pm
Location: Western Germany

Re: mpd stops communicating with ALSA after system upgrade

Post by skidoo » January 22nd, 2018, 3:06 pm

Debian and *bunutu create and set permissions for mpd user: check package for mpd.postinst file - no home directory required.

MPD configuration file

Code: Select all

$ mpd --stdout --no-daemon --verbose /etc/mpd.conf
@max> man mpd
MPD searches for a config file in $XDG_CONFIG_HOME/mpd/mpd.conf then ~/.mpdconf then /etc/mpd.conf or uses CONF_FILE.
but

Code: Select all

$ mpd
results in
exception: No configuration file found
- MPD from git master.

delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

Re: mpd stops communicating with ALSA after system upgrade

Post by delooper » January 23rd, 2018, 5:10 am

Thanks for the feedback. Regarding your suggestion:

Code: Select all

mpd --stdout --no-daemon --verbose /etc/mpd.conf
that gives me the result:

Code: Select all

config_file: loading file /etc/mpd.conf
fatal_error: Failed to set group 29: Operation not permitted
. . . and I'm not certain what that means.

And thanks for letting me know about the mpd.postinst file, I'll look into that.

delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

Re: mpd stops communicating with ALSA after system upgrade

Post by delooper » January 25th, 2018, 6:50 am

skidoo wrote:
January 22nd, 2018, 3:06 pm
Debian and *bunutu create and set permissions for mpd user: check package for mpd.postinst file - no home directory required.

MPD configuration file

Code: Select all

$ mpd --stdout --no-daemon --verbose /etc/mpd.conf
I found a mpd.postinst file for a Debian mpd package: https://github.com/volumio/Build/blob/m ... d.postinst

I see it creates the mpd user in the audio group, it updates the /var/log/mpd, /var/lib/mpd, and /var/lib/mpd/playlists directory properties and then it updates the /etc/mpd.conf file properties.

I've done all these things and still

Code: Select all

/etc$ mpd --stdout --no-daemon --verbose /etc/mpd.conf
config_file: loading file /etc/mpd.conf
fatal_error: Failed to set group 29: Operation not permitted
I'm starting to think my problem really isn't the mpd version. It's starting to look like the problem is some small change in how ALSA works. I just need to figure out how to get mpd to work with it.

For example, if I remove the current mpd, and reinstall mpd from the LUbuntu package, I get the old error message in mpd.log:

Code: Select all

Jan 24 22:28 : client: [0] process command "status"
ALSA lib dlmisc.c:254:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/i386-linux-gnu/alsa-lib/libasound_module_ctl_plug.so
Jan 24 22:28 : alsa_mixer: Failed to read mixer for 'USB Streamer - LX521.4': failed to attach to default: No such device or address
Jan 24 22:28 : client: [0] command returned 0
And that rang a bell. If I run alsamixer without any command line options, I get the same error message:

Code: Select all

alsamixer
ALSA lib dlmisc.c:254:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/i386-linux-gnu/alsa-lib/libasound_module_ctl_plug.so
cannot open mixer: No such device or address
So I suspect that error message in mpd.log is just a direct copy of the error message from alsamixer. Which means mpd is calling alsamixer without specifying which device to use. If I run:

Code: Select all

alsamixer -D hw:USBStreamer
Alsamixer runs perfectly.

I thought my asound.conf file was enough to get ALSA to default to the USBStreamer, but it seems that alsamixer doesn't obey those rules. . .

delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

Re: mpd stops communicating with ALSA after system upgrade

Post by delooper » January 25th, 2018, 7:01 am

Am I right in thinking this is an alsamixer error message?

I think I need to somehow tell mpd to specify the USBStreamer device when it interacts with alsamixer. But it's unclear to me how to do that.

delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

Re: mpd stops communicating with ALSA after system upgrade

Post by delooper » January 25th, 2018, 6:33 pm

If I change my audio_output field in /etc/mpd.conf to:

Code: Select all

audio_output {
        type            "alsa"
        name            "USB Streamer - LX521.4"
        device          "hw:USBStreamer,0"
}
The mpd.log error message becomes:

Code: Select all

Jan 25 02:47 : decoder_thread: probing plugin flac
Jan 25 02:47 : decoder: audio_format=44100:16:2, seekable=true
Jan 25 02:47 : alsa_output: opened hw:USBStreamer,0 type=HW
Jan 25 02:47 : alsa_output: format=S32_LE (Signed 32 bit Little Endian)
Jan 25 02:47 : alsa_output: buffer: size=12..26214 time=272..594422
Jan 25 02:47 : alsa_output: period: size=6..13107 time=136..297211
Jan 25 02:47 : alsa_output: default period_time = buffer_time/4 = 500000/4 = 125000
Jan 25 02:47 : alsa_output: buffer_size=22050 period_size=5513
Jan 25 02:47 : output: opened plugin=alsa name="USB Streamer - LX521.4" audio_format=44100:32:10
Jan 25 02:47 : output: converting from 44100:16:2
ALSA lib dlmisc.c:254:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/i386-linux-gnu/alsa-lib/libasound_module_ctl_plug.so
Jan 25 02:47 : output: Failed to open mixer for 'USB Streamer - LX521.4'
Which looks closer to operational than before.

jast
Forum team
Posts: 18
Joined: January 15th, 2013, 4:03 pm
Location: Germany
Contact:

Re: mpd stops communicating with ALSA after system upgrade

Post by jast » January 26th, 2018, 8:46 am

I believe you can't use "type plug" in "ctl" definitions in asound.conf.

delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

Re: mpd stops communicating with ALSA after system upgrade

Post by delooper » January 26th, 2018, 9:46 am

Interesting. It worked not very long ago, and lasted for two years. Are you aware of any documentation around this change?

It feels good to be learning something. Okay, so I remove that ctl.!default statement from asound.conf and the error message is gone. alsamixer loads without specifying a device. But now mpd isn't making any noise.

I imagine mpd or alsa somehow needs to know the corresponding ctl device. Would something like:

Code: Select all

ctl.!default {
 type hw
 card USBStreamer
}
be a suitable replacement? I imagine it can't be that. . . because it's not working for me.

Code: Select all

Jan 26 01:42 : decoder_thread: probing plugin flac
Jan 26 01:42 : decoder: audio_format=44100:16:2, seekable=true
Jan 26 01:42 : alsa_output: opened hw:USBStreamer,0 type=HW
Jan 26 01:42 : alsa_output: format=S32_LE (Signed 32 bit Little Endian)
Jan 26 01:42 : alsa_output: buffer: size=12..26214 time=272..594422
Jan 26 01:42 : alsa_output: period: size=6..13107 time=136..297211
Jan 26 01:42 : alsa_output: default period_time = buffer_time/4 = 500000/4 = 125000
Jan 26 01:42 : alsa_output: buffer_size=22050 period_size=5513
Jan 26 01:42 : output: opened plugin=alsa name="USB Streamer - LX521.4" audio_format=44100:32:10
Jan 26 01:42 : output: converting from 44100:16:2
Jan 26 01:42 : output: Failed to open mixer for 'USB Streamer - LX521.4'

delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

Re: mpd stops communicating with ALSA after system upgrade

Post by delooper » January 26th, 2018, 8:35 pm

I change my asound.conf to:

Code: Select all

pcm.!default {
  type plug
  slave.pcm {
   slave.pcm {
    type hw
    card USBStreamer
    device 0
    }
  ttable.0.8 1
  ttable.1.9 1
  }
}
and alsamixer loads fine now. There's no alsamixer error messages in the mpd.log file. That's all great, but now speaker-test fails! Sigh.

Code: Select all

speaker-test -c 10 -t sin -D plughw:USBStreamer

speaker-test 1.1.0

Playback device is plughw:USBStreamer
Stream parameters are 48000Hz, S16_LE, 10 channels
Sine wave rate is 440.0000Hz
Playback open error: -16,Device or resource busy
Do you know how to check what ALSA thinks its doing? in particular, what process is using it? I recall there's a file somewhere, but it does not appear to be /var/lib/alsa/asound.state.

delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

Re: mpd stops communicating with ALSA after system upgrade

Post by delooper » January 26th, 2018, 9:23 pm

Progress: sudo fuser -v /dev/snd/* shows me mpd was using ALSA. So I turned off the mpd service and speaker-test works now.

Next step, to get mplayer working. I would think a command like: mplayer -ao alsa:device=plughw=USBStreamer.0 *.flac

would work. MPlayer runs, but it doesn't send sound to the speakers.

delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

Re: mpd stops communicating with ALSA after system upgrade

Post by delooper » January 26th, 2018, 10:19 pm

Okay! All my problems have been fixed. I set my mpd.conf audio_output to the minimalist:

Code: Select all

audio_output {
        type            "alsa"
        name            "USB Streamer - LX521.4"
}
And it appears to be using the default device. mpd works again.

Whew!

delooper
Posts: 20
Joined: August 9th, 2016, 8:20 am

Re: mpd stops communicating with ALSA after system upgrade

Post by delooper » January 27th, 2018, 12:21 am

My understanding of this problem is that my original asound.conf file was probably "broken" from the beginning (with the ctl remapping). But the old version of ALSA I was using must have been very forgiving.

After the system upgrade (where both mpd and alsa were upgraded) it was ALSA that became more fussy. But the error messages were too obtuse for me to figure it out, without a lot of help. . .

max
Forum team
Posts: 863
Joined: January 15th, 2013, 3:43 pm

Re: mpd stops communicating with ALSA after system upgrade

Post by max » January 31st, 2018, 12:55 pm

True, but these are ALSA error messages. MPD can't improve them.

Post Reply