No ALSA output on MPD > 0.21.3

Need help with MPD?
Post Reply
DaveHarper
Posts: 3
Joined: September 19th, 2019, 9:22 pm

No ALSA output on MPD > 0.21.3

Post by DaveHarper » September 20th, 2019, 9:36 pm

Setup:
Hardware: Raspberry Pi Model 3B, Blackweb BWA18AA013 Bluetooth speaker
Software: Latest Raspbian Stretch, MPD v0.21.14

Last December I started an audio project on a Raspberry Pi and, after evaluating a number of players, selected MPD. At the time the latest version was 0.21.3. Since the project would be streaming over Bluetooth, I bought a Blackweb Bluetooth speaker to simulate the target environment during development. Compiling MPD is done by following the "Compiling from source" instructions in the manual (including all listed libraries) and no problems have ever been encountered during that process. All has gone well and I am approaching the end of the development phase. To minimize the introduction of new variables during development I continued to use 21.3. About a week ago I decided things were far enough along to bring MPD up to date with the latest (21.14). What I found is that I am no longer able to stream over ALSA (streaming over HDMI to speakers in the monitor works fine). Further, the included "aplay" and "omxplayer" are still able to stream over Bluetooth with no problems.

Here's what I've tried so far:

1) Running version 0.21.3 with verbose logging shows:

Sep 20 13:57 : client: [0] process command "play"
Sep 20 13:57 : playlist: play 0:"Rock/U2/Best of 1980-1990/Pride (In the Name of Love).mp3"
Sep 20 13:57 : decoder_thread: probing plugin mad
Sep 20 13:57 : client: [0] command returned 0
Sep 20 13:57 : playlist: queue song 1:"Rock/U2/Best of 1980-1990/New Year's Day.mp3"
Sep 20 13:57 : decoder: audio_format=44100:24:2, seekable=true
Sep 20 13:57 : exception: OutputThread could not get realtime scheduling, continuing anyway: sched_setscheduler failed: Operation not permitted
Sep 20 13:57 : alsa_output: opened default type=PLUG
Sep 20 13:57 : alsa_output: buffer: size=8820..3853516 time=200000..87381316
Sep 20 13:57 : alsa_output: period: size=441..3764 time=10000..85334
Sep 20 13:57 : alsa_output: default period_time = buffer_time/4 = 500000/4 = 125000
Sep 20 13:57 : alsa_output: format=S24_LE (Signed 24 bit Little Endian)
Sep 20 13:57 : alsa_output: buffer_size=22050 period_size=3675
Sep 20 13:57 : output: opened "Blackweb RGD A013" (alsa) audio_format=44100:24:2
Sep 20 13:57 : exception: Failed to open mixer for 'Blackweb RGD A013': no such mixer control: PCM
Sep 20 13:57 : state_file: Saving state file /home/pi/.config/mpd/state
Sep 20 13:57 : client: [0] process command "stop"
Sep 20 13:57 : playlist: stop
Sep 20 13:57 : player: played "Rock/U2/Best of 1980-1990/Pride (In the Name of Love).mp3"
Sep 20 13:57 : output: closed "Blackweb RGD A013" (alsa)

Since this works okay, I disregarded the two exceptions (scheduling / mixer) that also appear in the log files of the latest version.

2) Running version 0.21.14 with verbose logging:

Sep 20 14:18 : client: [1] process command "play"
Sep 20 14:18 : playlist: play 0:"Rock/U2/Best of 1980-1990/Pride (In the Name of Love).mp3"
Sep 20 14:18 : client: [1] command returned 0
Sep 20 14:18 : decoder_thread: probing plugin mad
Sep 20 14:18 : playlist: queue song 1:"Rock/U2/Best of 1980-1990/New Year's Day.mp3"
Sep 20 14:18 : decoder: audio_format=44100:24:2, seekable=true
Sep 20 14:18 : exception: OutputThread could not get realtime scheduling, continuing anyway: sched_setscheduler failed: Operation not permitted
Sep 20 14:18 : alsa_output: opened default type=PLUG
Sep 20 14:18 : alsa_output: buffer: size=8820..3853516 time=200000..87381316
Sep 20 14:18 : alsa_output: period: size=441..3764 time=10000..85334
Sep 20 14:18 : alsa_output: default period_time = buffer_time/4 = 500000/4 = 125000
Sep 20 14:18 : alsa_output: format=S24_LE (Signed 24 bit Little Endian)
Sep 20 14:18 : alsa_output: buffer_size=22050 period_size=3675
Sep 20 14:18 : output: opened "Blackweb RGD A013" (alsa) audio_format=44100:24:2
Sep 20 14:18 : exception: Failed to open mixer for 'Blackweb RGD A013': no such mixer control: PCM
Sep 20 14:18 : exception: Failed to play on "Blackweb RGD A013" (alsa): snd_pcm_poll_descriptors_revents() failed: Invalid argument
Sep 20 14:18 : output: closed "Blackweb RGD A013" (alsa)
Sep 20 14:18 : exception: Failed to open audio output
Sep 20 14:18 : client: [1] process command "status"
Sep 20 14:18 : client: [1] command returned 0
Sep 20 14:18 : state_file: Saving state file /home/pi/.config/mpd/state
Sep 20 14:18 : client: [1] closed

Here, there is a new exception line:
exception: Failed to play on "Blackweb RGD A013" (alsa): snd_pcm_poll_descriptors_revents() failed: Invalid argument

3) While I'm not a C++ programmer, I hacked around and modified the line in ~/src/lib/alsa/NonBlock.cxx to see if I could tell which of the arguments the function was having a problem with. This changed the output to:

exception: Failed to play on "Blackweb RGD A013" (alsa): snd_pcm_poll_descriptors_revents() failed: Invalid argument, pcm: 6cb0c700, pfds: 6e200560, i: 6e200568, &dummy: 6eb40ad6

Unfortunately, beyond the fact that there is indeed a value being passed for each parameter, this didn't tell me anything.

4) I decided to see on which version of MPD my problem first appeared and did a binary search between versions 0.21.3 and 0.21.14. As it turns out, my problem exhibits starting with the very next version (0.21.4) and appears in all versions I tried above that. Looking through the change log between 0.21.3 and 0.21.4 I didn't see anything that might relate to this problem.

5) I am far from being an audio expert on the Raspberry Pi (or Bluetooth, for that matter). However, I did some digging and it appears the ALSA information originates in a file called ".asoundrc" in the $HOME directory. This file does not exist until I do the initial pairing with the Bluetooth speaker and then appears to be created by the O.S. The contents of the file are:

Code: Select all

pcm.!default {
	type plug
	slave.pcm {
		type bluealsa
		device "1B:0F:A7:FC:B5:1A"
		profile "a2dp"
	}
}

ctl.!default {
	type bluealsa
}
In the mpd.conf file, the contents that define the audio_output are:

Code: Select all

audio_output {
        type            "alsa"
        name            "Blackweb RGD A013"
}
Both of the above files are the same when used with all versions of MPD that I've tried.

Since I haven't seen anything in the forums indicating anyone else with this problem, I suspect there's something in the configuration that I'm missing and just got "lucky" with version 0.21.3. Unfortunately, I'm starting to run out of ideas to try. If anyone can help me get past this problem, I'd really appreciate it. While I could continue to run with the earlier version, I'd much rather deploy with the latest version and take advantage of all the recent work that has gone into MPD development.

Thanks,
Dave

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

Re: No ALSA output on MPD > 0.21.3

Post by max » September 21st, 2019, 8:04 am


DaveHarper
Posts: 3
Joined: September 19th, 2019, 9:22 pm

Re: No ALSA output on MPD > 0.21.3

Post by DaveHarper » September 21st, 2019, 1:45 pm

Thanks for the response. In looking through the links, I get the impression that this might explain another issue I've seen intermittently (and rarely) since I've started development - things will be playing along fine and suddenly the music will simply stop. Doing a status command shows that MPD is still in play mode but there is no music and the elapsed timer is not advancing. Also, in reading through the comments in the links it appears that I (and possibly many others) are caught in the middle between two disparate points of view. Since this has been an issue for nearly 9 months now, I must assume that this is unlikely to get resolved anytime soon.

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

Re: No ALSA output on MPD > 0.21.3

Post by max » September 22nd, 2019, 10:38 am

I, too, fear this bluez-alsa bug will never be fixed. The bluez-alsa developer appeared to be unconvinced that this is really his bug. Pity.

DaveHarper
Posts: 3
Joined: September 19th, 2019, 9:22 pm

Re: No ALSA output on MPD > 0.21.3

Post by DaveHarper » September 22nd, 2019, 11:46 am

I have one last option to try with MPD. If the problem is related to the real time scheduling which was introduced in 0.21.x, I could try the last release of 0.20.x, which is available in the Download section. I lose everything new/fixed in 0.21.x, but if it works in my application then I have a solution. However, it appears that prior to 0.21 the meson approach was not used so the current build instructions in the User Manual do not apply. Unfortunately, while previous versions of MPD exist, previous versions of the User Manual do not. What are the steps necessary to compile a 0.20.x version of MPD?

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

Re: No ALSA output on MPD > 0.21.3

Post by max » September 22nd, 2019, 5:16 pm

Every MPD source tarball contains full documentation in the "doc" directory. The one on the MPD website is just a copy of that.

This has nothing to do with real-time scheduling (MPD 0.20 had that as well, added in v0.19) - this bluez-alsa bug was revealed by a different MPD change which switched the ALSA output plugin to non-blocking mode. This bluez-alsa bug only affects non-blocking mode, it's not implemented properly.

Post Reply