[Understood] mpd/alsa/usb: Xfce power management / light-locker locks sound issue

I'm using my laptop a.o. as an audio player, outputting to various external USB DACs (digital-to analog converters) in a bit-perfect way. I'm using mpd as music player (service enabled at boot in user mode), with mpd directed to do its output via alsa directly to the USB DACs. My mpd client of choice is Cantata. There is a number of USB DACs available, a Chord Hugo 2 (FPGA type), an AudioQuest DragonFly Red (PIC32MX receiver), and a miniDSP USB Streamer (XMOS receiver).

I am playing PCM only, coming from FLAC files (all flavors from 16 bits / 44.1 kHz to 24/192) and DSD files (DSF, from DSD64 to DSD256). Since neither Linux OS is able to handle native DSD, mpd is being directed to output such audio files as DoP. All my music is lossless, no mp3 or similar.

I am encountering reproducible issues with such an installation on Manjaro (fully updated, Stable branch). I do also run openSUSE Tumbleweed in multiboot on this laptop, same chain of mpd/alsa/usb. Tumbleweed doesn't give me any issue!

I have a playlist made up of a succession of albums, each album consisting of a number of tracks. All tracks within an album have the same bit depth and samplerate. I have Cantata ask mpd to play this playlist. The issue on Manjaro (ONLY, not on Tumbleweed) is: When advancing from the last track of album N to the first track of album N+1, mpd gets caught in an alsa error and gets paused, if the samplerates of album N and album N+1 are different. The mdp.log output from start to beyond that error is:

Jun 20 03:22 : exception: RTIOThread could not get realtime scheduling, continuing anyway: sched_setscheduler failed: Operation not permitted
Jun 20 03:22 : avahi: Service 'Music Player @ mylappy' successfully established.
Jun 20 03:24 : exception: Unsupported URI scheme
Jun 20 03:24 : exception: Failed to open '/home/myself/.config/mpd/playlists/[Radio Streams].m3u': No such file or directory
Jun 20 03:24 : exception: No such playlist
Jun 20 03:24 : exception: OutputThread could not get realtime scheduling, continuing anyway: sched_setscheduler failed: Operation not permitted
Jun 20 03:39 : player: played "LL/Loussier, Jacques/Play Bach aux Champs-Élysées [1995 CD]/Disc 1/02 - Italian Concerto in F major, BWV 971 - 1. Allegro - 2. Andante - 3. Finale. Presto.flac"
Jun 20 04:00 : player: played "LL/Loussier, Jacques/Play Bach aux Champs-Élysées [1995 CD]/Disc 1/03 - Partita No. 1 in B flat major, BWV 825 - 1. Prelude - 2. Allemande - 3. Courante - 4. Sarabande - 5. Minuetto I - 6. Minuetto II - 7. Gigue.flac"
Jun 20 04:05 : player: played "LL/Loussier, Jacques/Play Bach aux Champs-Élysées [1995 CD]/Disc 1/04 - Choral 'Jesus bleibet meine Freude' (Cantata No. 147 'Herz und Mund und Tat und Leben', BWV 147).flac"
Jun 20 04:18 : player: played "LL/Loussier, Jacques/Play Bach aux Champs-Élysées [1995 CD]/Disc 1/05 - Toccata & Fugue in D minor, BWV 565.flac"
Jun 20 04:27 : player: played "LL/Loussier, Jacques/Play Bach aux Champs-Élysées [1995 CD]/Disc 2/01 - Two-Part Invention No. 8 in F major, BWV 779.flac"
Jun 20 04:29 : player: played "LL/Loussier, Jacques/Play Bach aux Champs-Élysées [1995 CD]/Disc 2/02 - Prelude No. 2 in C minor, BWV 847 (The Well-Tempered Clavier, Book I).flac"
Jun 20 04:32 : player: played "LL/Loussier, Jacques/Play Bach aux Champs-Élysées [1995 CD]/Disc 2/03 - Prelude No. 12 in F minor, BWV 881 (The Well-Tempered Clavier, Book II).flac"
Jun 20 04:50 : player: played "LL/Loussier, Jacques/Play Bach aux Champs-Élysées [1995 CD]/Disc 2/04 - Harpsichord Concerto No. 1 in D minor, BWV 1052 - 1. Allegro - 2. Adagio - 3. Allegro.flac"
Jun 20 04:55 : player: played "LL/Loussier, Jacques/Play Bach aux Champs-Élysées [1995 CD]/Disc 2/05 - Aria (Orchestral Suite No. 3 in D major, BWV 1068).flac"
Jun 20 05:03 : player: played "LL/Loussier, Jacques/Play Bach aux Champs-Élysées [1995 CD]/Disc 2/06 - Choral No. 1 'Wachet auf, ruft uns die Stimme', BWV 645 (Schübler's Book).flac"
Jun 20 05:07 : player: played "LL/Loussier, Jacques/Play Bach aux Champs-Élysées [1995 CD]/Disc 2/07 - Sinfonia (Cantata No. 29 'Wir danken dir, Gott, wir danken dir', BWV 29).flac"
ALSA lib pcm_hw.c:1826:(_snd_pcm_hw_open) Invalid value for card
Jun 20 05:07 : exception: Failed to open "Optical USB Streamer - USB Audio" (alsa)
Jun 20 05:07 : exception: nested: Failed to open ALSA device "hw:CARD=USBStreamer,DEV=0": No such device
Jun 20 05:07 : exception: Failed to open "Optical USB Streamer - USB Audio" (alsa)
Jun 20 05:07 : exception: nested: Failed to open ALSA device "hw:CARD=USBStreamer,DEV=0": No such device
Jun 20 05:07 : player: problems opening audio device while playing "WR/Jarrett, Keith/Setting Standards - New York Sessions [CD & HiRes]/Album 1 - Standards Vol. 1/2015 HiRes HRA/01 Meaning of the Blues.flac"
Jun 20 07:29 : player: played "WR/Jarrett, Keith/Setting Standards - New York Sessions [CD & HiRes]/Album 1 - Standards Vol. 1/2015 HiRes HRA/01 Meaning of the Blues.flac"
Jun 20 07:37 : player: played "WR/Jarrett, Keith/Setting Standards - New York Sessions [CD & HiRes]/Album 1 - Standards Vol. 1/2015 HiRes HRA/02 All the Things You Are.flac"

The Loussier album is 16/44.1, the Jarrett 24/192. The important piece is:

Jun 20 05:07 : player: played "LL/Loussier, Jacques/Play Bach aux Champs-Élysées [1995 CD]/Disc 2/07 - Sinfonia (Cantata No. 29 'Wir danken dir, Gott, wir danken dir', BWV 29).flac"
ALSA lib pcm_hw.c:1826:(_snd_pcm_hw_open) Invalid value for card
Jun 20 05:07 : exception: Failed to open "Optical USB Streamer - USB Audio" (alsa)
Jun 20 05:07 : exception: nested: Failed to open ALSA device "hw:CARD=USBStreamer,DEV=0": No such device
Jun 20 05:07 : exception: Failed to open "Optical USB Streamer - USB Audio" (alsa)
Jun 20 05:07 : exception: nested: Failed to open ALSA device "hw:CARD=USBStreamer,DEV=0": No such device
Jun 20 05:07 : player: problems opening audio device while playing "WR/Jarrett, Keith/Setting Standards - New York Sessions [CD & HiRes]/Album 1 - Standards Vol. 1/2015 HiRes HRA/01 Meaning of the Blues.flac"
Jun 20 07:29 : player: played "WR/Jarrett, Keith/Setting Standards - New York Sessions [CD & HiRes]/Album 1 - Standards Vol. 1/2015 HiRes HRA/01 Meaning of the Blues.flac"

It seems mpd needs to close and re-open the USB device when a samplerate change occurs. When the switch from one album to the next does not involve a samplerate change, mpd just keeps on playing fine. (Remark: I didn't check yet whether the same issue issue occurs at a bit depth change.)

At such a point in time on Manjaro only, mpd gets paused, and the USB DAC is left in a state where it shows the samplerate of the last track from album N. Hitting Play on Cantata lets mpd continue correctly at the first track of album N+1, as can be seen from the logs.

Remark: These logs were done in log-level default on mpd. log-level verbose could be shown, too, but it didn't reveal anything more to me.

My mpd user configuration is IDENTICAL on both Manjaro and Tumbleweed:

############################################################################
### This is the mpd configuration in a per-user setup.
### Local configuration stored in ~/.config/mpd (all files),
### where ~ is /home/myself
###
### Autostart of mpd with systemd, running the user unit (NO sudo priv's!):
### systemctl enable --user mpd.service
###
### Devices: Chord Hugo 2, AudioQuest DragonFly Red,
### miniDSP USB Streamer B, Internal Sound Cards,
### to be enabled/disabled individually/simultaneously from mpc, cantata,
### or via editing their respective blocks here.
### Laptop HP 8570w
###
### Hugo 2 DSD only via DoP, Linux quirks.c w/o native DSD patch for Chord
###
### Resampling is applied by mpd only to DragonFly,
### but doesn't adhere to the 44.1/48k ladders yet (feature request to mpd)
###
### mpd can't decode HDCD
###
############################################################################

## start processing `01_output-audio-alsa.conf'

#### Chord Hugo 2
audio_output {
	type                "alsa"
	name                "Hugo2 - USB Audio"
##	device              "hw:2,0"
	device              "hw:CARD=Hugo2,DEV=0"
	auto_resample       "no"
	auto_format         "no"
	auto_channels       "no"
	dop                 "yes"
	replay_gain_handler "none"
	mixer_type          "none"
}
#### end of Chord Hugo 2

#### miniDSP USB Streamer B (optical input to Hugo 2)
audio_output {
	type                "alsa"
	name                "Optical USB Streamer - USB Audio"
##	device              "hw:2,0"
	device              "hw:CARD=USBStreamer,DEV=0"
	auto_resample       "no"
	auto_format         "no"
	auto_channels       "no"
	dop                 "yes"
	replay_gain_handler "none"
	mixer_type          "none"
}
#### end of miniDSP USB Streamer B

#### AudioQuest DragonFly Red
audio_output {
	type                "alsa"
	name                "Dragonfly Red - USB Audio"
##	device              "hw:2,0"
	device              "hw:CARD=v10,DEV=0"
	auto_resample       "no"
	auto_format         "no"
	auto_channels       "no"
	dop                 "no"
	replay_gain_handler "none"
	mixer_type          "none"
}
#### end of AudioQuest DragonFly Red

#### Internal Sound Card - HP 8570w
audio_output {
	type                "alsa"
	name                "Internal Sound Card - HP 8570w"
##	device              "hw:0,0"
	device              "hw:CARD=PCH,DEV=0"
	auto_resample       "no"
	auto_format         "no"
	auto_channels       "no"
	dop                 "no"
	replay_gain_handler "none"
	mixer_type          "none"
}
#### end of Internal Sound Card - HP 8570w

#### general settings for all output devices
resampler {
	plugin              "libsamplerate"
	type                "0"
}
replaygain                  "off"

## done processing

## start processing `02_paths.conf'
music_directory        "~/AVs/I/Music"
db_file                "~/.config/mpd/database"
log_file               "~/.config/mpd/mpd.log"
playlist_directory     "~/.config/mpd/playlists"
pid_file               "~/.config/mpd/pid"
state_file             "~/.config/mpd/state"
sticker_file           "~/.config/mpd/sticker.sql"
save_absolute_paths_in_playlists  "no"
## done processing

## start processing `03_general.conf'
filesystem_charset     "UTF-8"
id3v1_encoding         "UTF-8"
log_level              "default"
## log_level              "verbose"
auto_update            "yes"
auto_update_depth      "4096"
## done processing

## start processing `04_client-limits.conf'
connection_timeout     "60"
max_connections        "10"
max_playlist_length    "16384"
max_command_list_size  "2048"
max_output_buffer_size "8192"
## done processing

## start processing `05_network.conf'
bind_to_address        "0.0.0.0"
## done processing

## start processing `06_zeroconf.conf'
zeroconf_enabled       "True"
## done processing

############################################################################
### end of mpd configuration file
############################################################################

I did also check the relevant package versions on the two distros:
alsa is identical: 1.1.9
mpd is different: 0.21.10 on Manjaro, 0.21.2 on Tumbleweed
Cantata is identical: 2.3.3
Manjaro has alsa-firmware installed which is a dependency of manjaro-alsa. Tumbleweed doesn't have alsa-firmware installed. alsa-firmware contains binary drivers for various third-party hardware. I did not try to uninstall alsa-firmware on Manjaro, since it would break manjaro-alsa which is described as an alsa metapackage. So I have no idea whether the observed issue is due to alsa-firmware and/or manjaro-alsa.
Regarding the mpd version difference: Of course, Manjaro's mpd could have introduced a regression as compared to Tumbleweed's mpd - I wouldn't know. I think to remember that Manjaro gave me the same problem more than a year ago, with some prior version of mpd.

Regarding the two alsa configurations: I did not change anything in any alsa config against what the two distros installed on their own, neither in the global /etc/asound.config, nor in the per-user ~/.asoundrc. In fact, there is no ~/.asoundrc on either distro.

My questions to the community are:

  1. Did anybody encounter the same or a similar issue?
  2. What more information could I provide for debugging?
  3. What else could I do? (e.g. uninstall alsa-firmware on Manjaro and break manjaro-alsa?)
  4. What could cause the different behaviors of Manjaro and Tumbleweed? Could I get the same lower mpd version number in a Manjaro package and install it?

The reason for me to start asking for help on this forum is obvious: Tumbleweed doesn't give me any issues with mpd/alsa/usb. So I don't feel like asking on the mpd forum or even the mpd bugzilla yet.

I did try to exclude a couple of possibilities:

The issue does not depend on the choice of the mpd client, be it Cantata, ncmpc, ncmpcpp or none at all.

The issue does also occur on my other laptop, though they are somewhat similar: Both HP EliteBooks, one 8570w, one 8560w.

The issue occurs with all three USB DACs I own.

I can simplify the a.m. ~/.config/mpd/mpd.conf to cater for one of the DACs only. No change.

All along the roads travelled with Manjaro, I have had this with a bunch of kernels. Over the last weekend, I ran the tests again with 4.19 LTS and 5.1.8 current.

There is one strong indication pointing to the samplerate change as the cause:

The Hugo is capable of up to 768 kHz, the miniDSP goes up to 192 k, the DragonFly only to 96 k. Now consider the following album sequence: 44.1, 192, 192, 96. Hugo 2 takes all these feeds as they are, no resampling is involved for this device; same for the miniDSP. I get two of the alsa errors, one at 44.1 > 192, one at 192 > 96. On the other hand, the DragonFly requires mpd to send a sequence with resampling for the two 192 k albums, i.e. 44.1, 96, 96, 96. With that I get only one of said errors, at 44.1 > 96.

Two approaches now:

(1) Please let me understand how the mpd package available in the Manjaro repo is created. Does Manjaro just copy the Arch Linux mpd package from their repo? Would the Arch PKGBUILD be the one in effect then? Or does Manjaro build its own mpd from source, using its own PKGBUILD?

Reason for asking this is to find a difference between the Manjaro mpd and the Tumbleweed one, other than the obvious mpd version difference (0.21.10 vs 0.21.2). Compiler switches?

(2) I could base another hypothesis on the fact that the code for mpd output to alsa was modified in mpd version 0.21.3; cf. the changelog of mpd:

ver 0.21.3 (2018/11/16)
* output
  - alsa: fix crash bug
  - alsa: fix stuttering at start of playback
  - alsa: fix discarded samples at end of song
  - alsa: clear error after reopening device
* log: default to journal if MPD was started as systemd service

Thus one could speculate that a regression was introduced in mpd 0.21.3 or later, and that such a regression might cause the issue I am hunting here. Of course, an mpd bug report or forum request would have to be filed then.

I guess it's copy/paste from Arch

Packager:    Gaetan Bisson bisson@archlinux.org

You can find basic information in package details (package>right click>Details) if you use Pamac GTK.

Thanks, will check.

Seems like I am doing audio in a not so common way, or maybe not many people on this forum have stumbled over the issue I have.

So, if Manjaro‘s mpd is Arch‘s, one could start asking on the Arch forum. Uhhh, both the Arch forum and the mpd forum/bugzilla to me seem a little bit frightening from an attitude POV... ...

If you tell on Arch forum that you're from Manjaro, they probably send you back to Manjaro forum, and probably they will not be polite :smile:

Do you have same configuration in .asoundrc on OpenSuse and Manjaro. Last time when I was playing with audio setup for music recording I hit in something similar. I set up ALSA to use external sound card instead of default '0'( which should be in theory the same) and Cmus don't work to the moment I open Ardour :smile:

Maybe it's related or not. I don't know. Didn't read all your posts yet, maybe tomorrow with fresh mind I'll be able to figure out something but I don't give you guarantee. I'm not much experienced audio user.

Agreed regarding forum attitudes...

Will check the alsa config files on both distros tomorrow, yes, fresh mind.

Any help is highly welcome, thanks.

I made some investigation and found that Cantata use own mpd configuration stored in .local/share/cantata/mpd/mpd.conf
so mpd configuration is not necessary (it is causing issues? idk) and maybe better idea is to configure DACs in Cantata mpd.conf config file. If you have the same default config like me, Cantata route audio signal to PulseAudio not to DAC directly.

...
audio_output { 
  type "pulse"
  name "Output"
}
mixer_type "software"
audio_buffer_size "8192"
filesystem_charset "UTF-8"
id3v1_encoding "UTF-8"

Also, I have some doubts about your device configuration:
device "hw:CARD=Hugo2,DEV=0"
As far as I know, it should be something like device "hw:ID number" like in example device "hw:2,0"

To check your DAC's ID open alsamixer via terminal and hit F6
RecBox_2019-06-28-54

BTW I tested Cantata (configured playlist and queue in Cantata) and it's working without issues. I don't have mpd configured.

Thanks for coming back and helping.

A few words on my configuration.

mpd runs as a user service, enabled as:

systemctl enable --user mpd.service

Thus it gets started at every boot, and it reads its configuration from ~/.config/mpd/mpd.conf.

The way how Cantata gets its basic configuration is being defined by a first-run setup screen. I think there are two setup routes: A simple one where Cantata configures mpd and stores the configuration as ~/.local/share/cantata/mpd/mpd.conf. With the other one Cantata is based on the existing mpd configuration, in my case the per-user ~/.config/mpd/mpd.conf. The latter is my setup, and there are two evidences for it: There is no mpd.conf in ~/.local/cantata, and mpd changes its behavior when ~/.config/mpd/mpd.conf is edited. Hope that clarifies a common pitfall with Cantata, cf. the openSUSE forum for example.

Regarding the audio device names: Do aplay -l and aplay -L in terminal to see all hardware numbers and names known to alsa. My understanding is that hardware ID numbers should be avoided since they depend e.g. on the order of inserting the devices.

Regarding pulseaudio: I want bit-perfect replay. Therefore the audio_output from mpd does NOT go via pulseaudio, but directly to alsa, no mixer.

There is a nice website by Ronald van Engelen which got me started with bit-perfect audio on Linux, cf. https://lacocina.nl. He has two scripts, one called alsa-capabilities (looking at the capabilities of all devices known to alsa), one called mpd-configure. The latter creates the initial mpd configuration for bit-perfect playback; this configuration can be extended as desired. That is where my mpd.conf came from.

Well, I think my configuration is quite correct, the main reason being that everything from mpd to alsa to Cantata is working well except for those incidents happening when the samplerate needs to be switched from one track to the next. Not to forget the fact that the very same configuration runs 100% perfect on Tumbleweed. Nevertheless, I will go ahead and follow your tips, e.g. put in hardware numbers and run the tests again on Manjaro. See above, the main exception error message from mpd reads "fails to open card ..." and then "nested: fails to open ...".

Unfortunately, I have to quit for now, sorry. Will continue for sure! Maybe some of the clarifications I put forward might help you. Please do correct me if I am wrong anywhere.

Thanks, now I understand it a bit better :slight_smile:

I'll try this on my recording setup :slight_smile:

This bothers me most. Maybe situation change after new update comes if there will be alsa or mpd package.

Sure, no problem. :slight_smile:

I had a quick look at Ronalds website and found that's interesting. Definitely need to read more about it :slight_smile:

Yep, the most obvious difference between my Manjaro and Tumbleweed is the mpd version, 0.21.10 versus 0.21.2. But, in order to get one‘s issue looked at by the mpd maintainer, one needs to assure to exclude as many possible causes as one can... Plus, he is not only the maintainer, but also the most active person on the forum, kind of a gatekeeper.

Ok, I've check setting ALSA via card name and its working fine, also I found that Arch wiki mentioning this as well. So this is 100% legit and you have right :slight_smile:

There is possibility to downgrade the package if you can't wait because it looks like there will not be mpd in coming update.

It's not the best solution and downgrading it's not recommended in general so making backup with Timeshift (or your fav backup tool) will be good idea in case somethings broke.

After some more experiments, I could narrow down on the circumstances producing this failure. It is related to laptop power management for the USB ports. In short:

Actions to reproduce: Set up a playlist for mpd (Music Player Daemon), consisting of a number of audio tracks with different samplerates. Let mpd output to an external USB-DAC via alsa.

Expected behavior: mpd plays the entire playlist, gaplessly, without fault.

Actual behavior:

(1) As long as the laptop screen remains ON, all is working as expected, mpd just keeps on playing. This ON can be achieved by moving the mouse every once in a while or anything similar, or setting the Xfce power manager for the screen to NEVER blank the screen, NEVER go into power saving mode, NEVER go into sleep mode.

(2) Things go wrong when the Xfce power manager is set to do something with the laptop screen, even the simplest thing like Blank the Screen after x minutes instead of never. (The other two actions Screen Power Saving and Sleep Mode should be set to Never anyway.) What happens then is: mpd plays one track until its end. If it needs to switch samplerate in order to play to next desired track, mpd has to re-open the USB-DAC via alsa with a different samplerate. Now, if the screen power management (blank the screen) has kicked in before that re-opening, mpd/alsa fail in two attempts and throw the a.m. error

exception: Failed to open "Optical USB Streamer - USB Audio" (alsa)
exception: nested: Failed to open ALSA device "hw:CARD=USBStreamer,DEV=0": No such device

To me, it looks like power management is "disengaging" the USB device right at that point in time, even though the only power management action switched on is "Blank the Screen". Then, just hitting the Play button on the mpd client lets mpd resume just fine and play the desired track. This failure occurs at every samplerate change if screen power management has kicked in and blanked the screen.

This failure and the a.m. circumstance are 100% reproducible. I did my best to eliminate as many other causes as possible, e.g. whether an mpd client is running or not, which client (Cantata here), whether my conky is running and checking status on mpd as well as the alsa output stream or not, which USB port is used (2.0 or 3.0).

This failure occurs on my Manjaro Xfce (4.14 pre2 as of now), mpd version 0.21.10. In the Xfce power manager applet, I tested both positions of the switch "let Xfce manage the power" to no avail. Manjaro is set up in the default way as per ISO 18.0.4, and updated to Stable 20190703; unfortunately, I don't understand enough about how power management actually works here.

As mentioned above, playing the same mpd playlist on my other Linux OS on that laptop (multiboot), openSUSE Tumbleweed KDE/Plasma, works just fine under every circumstance. There is a chance that my issue might be due to a regression between the two mpd versions in question, 0.21.2 on Tumbleweed, 0.21.10 on Manjaro. But I am more inclined to think that the failure on Manjaro versus the flawlessness on Tumbleweed is due to the different desktops and the respective power managements (Manjaro Xfce, Tumbleweed KDE/Plasma).

I should mention that I have added usbcore.autosuspend=-1 as kernel parameter to the Linux command line in my grub for Manjaro, following advice by @korealinux in order to let the OS recognize USB devices (esp. hard disks) on the fly. Of course, I did boot Manjaro without that parameter, too, but to no avail wrt the failure in question here.

@Mr_Glitch, this is as much as I could come up with by now. Maybe you have ideas starting from here, or maybe others might come in for further help. I edited the thread title and tags to show the words power management, too.

Thanks for all help up to now, happy to hear further ideas from anybody.

ADDENDUM: Using the Presentation Mode of the Xfce Power Management works to the same effect as switching all Screen Blanking off, thus keeping mpd running all along the playlist as desired. But the screen is always on, undesirable.

Just did another test. The same failure happens when mpd is outputting via alsa to the laptop's internal sound card instead of en external USB device (DAC). Same error at the point of the samplerate change:

Jul 05 16:13 : player: played "LL/Loussier, Jacques/Play Bach aux Champs-Élysées [1995 CD]/Disc 2/07 - Sinfonia (Cantata No. 29 'Wir danken dir, Gott, wir danken dir', BWV 29).flac"
ALSA lib pcm_hw.c:1826:(_snd_pcm_hw_open) Invalid value for card
Jul 05 16:13 : exception: Failed to open "Internal Sound Card - HP 8570w" (alsa)
Jul 05 16:13 : exception: nested: Failed to open ALSA device "hw:CARD=PCH,DEV=0": No such device
Jul 05 16:13 : exception: Failed to open "Internal Sound Card - HP 8570w" (alsa)
Jul 05 16:13 : exception: nested: Failed to open ALSA device "hw:CARD=PCH,DEV=0": No such device
Jul 05 16:13 : player: problems opening audio device while playing "WR/Brubeck, Dave/Time Out [2015 HiRes-PCM Edition]/03 - Take Five.flac"
Jul 05 16:14 : player: played "WR/Brubeck, Dave/Time Out [2015 HiRes-PCM Edition]/03 - Take Five.flac"

Any hints to make sense out of this are very welcome.

Next step tried now: Manjaro power management is done via tlp. So I blacklisted the USB device(s) in /etc/default/tlp.conf, like USB_BLACKLIST=”1234:5678“ to explicitly exclude them from USB autosuspend. NO SUCCESS, same failure as always.

Anyway, there is a little doubt that the USB-DAC(s) get suspended, since their physical samplerate lights remain on all the time. Don‘t know if power suspension would turn them off.

So now I am at a point where I need more help, a more general help than the thread title ”mpd/alsa“ suggests. I‘m on Manjaro Xfce, Stable.

Thing is: Similar story as that ”screen goes black whilst watching a DVD video“ phenomenon, which a long time ago lead to writing the caffeine program.

The USB audio devices and the internal soundcard get ”disengaged“ at once when mpd ”re-opens“ the digital sound stream in order to switch samplerate. This happens only when the laptop screen has gone black before this particular progressing to the next audio track. I use the word ”disengage“, since I don‘t know if it is really a suspension; the USB-DAC light remains on.

Figure a udev rule could help? Some config setting for tlp? Anybody? Thanks again in advance.

How does the kernel know that mpd is sending sound data to alsa to the physical devices? Possibly anything to be changed in the mpd code?

PS: Remarks, summarizing the a.m. findings: The workaround is to use Presentation Mode in the Xfce Power Manager Applet, or to turn all Screen Management to Never (blacken etc) in Xfce Power Manager Settings. My initial stab at blacklisting a USB-DAC in the tlp configuration didn‘t help, but maybe that was still done inadequately.

For my setup I'm using tlpui to manage power settings (mainly because battery charging in thinkpad and lack of knowlage :smiley: ) and here is my statistics. Hope it will help you.

Probably stupid idea but check if your tlp service is active:
systemctl status tlp.service

--- TLP 1.2.2 --------------------------------------------

+++ Configured Settings: /etc/default/tlp
TLP_ENABLE=1
TLP_DEFAULT_MODE=AC
TLP_PERSISTENT_DEFAULT=1
DISK_IDLE_SECS_ON_AC=0
DISK_IDLE_SECS_ON_BAT=2
MAX_LOST_WORK_SECS_ON_AC=15
MAX_LOST_WORK_SECS_ON_BAT=60
CPU_SCALING_GOVERNOR_ON_AC=performance
CPU_SCALING_GOVERNOR_ON_BAT=powersave
CPU_HWP_ON_AC=balance_performance
CPU_HWP_ON_BAT=balance_power
SCHED_POWERSAVE_ON_AC=0
SCHED_POWERSAVE_ON_BAT=1
NMI_WATCHDOG=0
ENERGY_PERF_POLICY_ON_AC=performance
ENERGY_PERF_POLICY_ON_BAT=power
DISK_DEVICES="sda sdb"
DISK_APM_LEVEL_ON_AC="254 254"
DISK_APM_LEVEL_ON_BAT="128 128"
SATA_LINKPWR_ON_AC="med_power_with_dipm max_performance"
SATA_LINKPWR_ON_BAT="med_power_with_dipm max_performance"
AHCI_RUNTIME_PM_TIMEOUT=15
PCIE_ASPM_ON_AC=performance
PCIE_ASPM_ON_BAT=powersave
RADEON_POWER_PROFILE_ON_AC=default
RADEON_POWER_PROFILE_ON_BAT=low
RADEON_DPM_STATE_ON_AC=performance
RADEON_DPM_STATE_ON_BAT=battery
RADEON_DPM_PERF_LEVEL_ON_AC=auto
RADEON_DPM_PERF_LEVEL_ON_BAT=auto
WIFI_PWR_ON_AC=off
WIFI_PWR_ON_BAT=on
WOL_DISABLE=Y
SOUND_POWER_SAVE_ON_AC=0
SOUND_POWER_SAVE_ON_BAT=1
SOUND_POWER_SAVE_CONTROLLER=Y
BAY_POWEROFF_ON_AC=0
BAY_POWEROFF_ON_BAT=0
BAY_DEVICE="sr0"
RUNTIME_PM_ON_AC=on
RUNTIME_PM_ON_BAT=auto
RUNTIME_PM_DRIVER_BLACKLIST="amdgpu nouveau nvidia radeon pcieport"
USB_AUTOSUSPEND=0
USB_BLACKLIST_BTUSB=0
USB_BLACKLIST_PHONE=0
USB_BLACKLIST_PRINTER=1
USB_BLACKLIST_WWAN=1
RESTORE_DEVICE_STATE_ON_STARTUP=0
START_CHARGE_THRESH_BAT0=45
STOP_CHARGE_THRESH_BAT0=85
START_CHARGE_THRESH_BAT1=45
STOP_CHARGE_THRESH_BAT1=85
RESTORE_THRESHOLDS_ON_BAT=1

+++ System Info
System         = LENOVO ThinkPad L440 20ASS11T00
BIOS           = J4ET65WW(1.65)
Release        = "Manjaro Linux"
Kernel         = 5.1.16-1-MANJARO #1 SMP PREEMPT Thu Jul 4 20:32:22 UTC 2019 x86_64
/proc/cmdline  = BOOT_IMAGE=/boot/vmlinuz-5.1-x86_64 root=UUID=f058c567-0081-4771-b20a-fef880c45251 rw quiet udev.log_priority=3 audit=0 resume=UUID=f8fdb6be-1bb9-4206-9df2-97f0a223dceb
Init system    = systemd 
Boot mode      = BIOS (CSM, Legacy)

+++ TLP Status
State          = enabled
RDW state      = not installed
Last run       = 01:10:16 PM,   4738 sec(s) ago
Mode           = AC
Power source   = AC

Notice: systemd-rfkill.service is not masked -- invoke "systemctl mask systemd-rfkill.service" to correct this!
Notice: systemd-rfkill.socket is not masked -- invoke "systemctl mask systemd-rfkill.socket" to correct this!

+++ Processor
CPU model      = Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz

/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver    = intel_pstate
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor  = performance
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq  =   800000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq  =  3100000 [kHz]

/sys/devices/system/cpu/cpu1/cpufreq/scaling_driver    = intel_pstate
/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor  = performance
/sys/devices/system/cpu/cpu1/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq  =   800000 [kHz]
/sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq  =  3100000 [kHz]

/sys/devices/system/cpu/cpu2/cpufreq/scaling_driver    = intel_pstate
/sys/devices/system/cpu/cpu2/cpufreq/scaling_governor  = performance
/sys/devices/system/cpu/cpu2/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq  =   800000 [kHz]
/sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq  =  3100000 [kHz]

/sys/devices/system/cpu/cpu3/cpufreq/scaling_driver    = intel_pstate
/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor  = performance
/sys/devices/system/cpu/cpu3/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq  =   800000 [kHz]
/sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq  =  3100000 [kHz]

/sys/devices/system/cpu/intel_pstate/min_perf_pct      =  25 [%]
/sys/devices/system/cpu/intel_pstate/max_perf_pct      = 100 [%]
/sys/devices/system/cpu/intel_pstate/no_turbo          =   0
/sys/devices/system/cpu/intel_pstate/turbo_pct         =  25 [%]
/sys/devices/system/cpu/intel_pstate/num_pstates       =  24

x86_energy_perf_policy.cpu0                            = performance 
x86_energy_perf_policy.cpu1                            = performance 
x86_energy_perf_policy.cpu2                            = performance 
x86_energy_perf_policy.cpu3                            = performance 

/sys/module/workqueue/parameters/power_efficient       = Y
/proc/sys/kernel/nmi_watchdog                          = 0

+++ Undervolting
PHC kernel not available.

+++ Temperatures
CPU temp               =    54 [°C]
/proc/acpi/ibm/fan     =     0 [/min]

+++ File System
/proc/sys/vm/laptop_mode               =     0
/proc/sys/vm/dirty_writeback_centisecs =  1500
/proc/sys/vm/dirty_expire_centisecs    =  1500
/proc/sys/vm/dirty_ratio               =    20
/proc/sys/vm/dirty_background_ratio    =    10

+++ Storage Devices
Devices = sda sdb

/dev/sda:
  Type      = ATA
  Model     = WDC WD3200BEKX-75B7WT0                  
  Firmware  = 01.01A01
  APM Level = 254
  Status    = active/idle
  Scheduler = [mq-deadline] kyber bfq none (multi queue)

  Runtime PM: control = on, autosuspend_delay_ms =   -1

  SMART info:
      4 Start_Stop_Count          =     2414 
      5 Reallocated_Sector_Ct     =        0 
      9 Power_On_Hours            =     9837 [h]
     12 Power_Cycle_Count         =     2402 
    191 G-Sense_Error_Rate        =     1387 
    193 Load_Cycle_Count          =    30941 
    194 Temperature_Celsius       =       40    [°C]
    241 Total_LBAs_Written        =   10.111 [TB]

/dev/sdb: not present.

+++ AHCI Link Power Management (ALPM)
/sys/class/scsi_host/host0/link_power_management_policy  = med_power_with_dipm
/sys/class/scsi_host/host1/link_power_management_policy  = med_power_with_dipm
/sys/class/scsi_host/host2/link_power_management_policy  = med_power_with_dipm
/sys/class/scsi_host/host3/link_power_management_policy  = med_power_with_dipm
/sys/class/scsi_host/host4/link_power_management_policy  = med_power_with_dipm

+++ AHCI Host Controller Runtime Power Management
/sys/bus/pci/devices/0000:00:1f.2/ata1/power/control = on
/sys/bus/pci/devices/0000:00:1f.2/ata2/power/control = on
/sys/bus/pci/devices/0000:00:1f.2/ata3/power/control = on
/sys/bus/pci/devices/0000:00:1f.2/ata4/power/control = on
/sys/bus/pci/devices/0000:00:1f.2/ata5/power/control = on

+++ Docks and Device Bays
/sys/devices/platform/dock.0: ata_bay       = drive present

+++ Intel Graphics
/sys/module/i915/parameters/enable_dc        = -1 (use per-chip default)
/sys/module/i915/parameters/enable_fbc       =  0 (disabled)
/sys/module/i915/parameters/enable_psr       = -1 (use per-chip default)
/sys/module/i915/parameters/modeset          = -1 (use per-chip default)

/sys/class/drm/card0/gt_min_freq_mhz         =   450 [MHz]
/sys/class/drm/card0/gt_max_freq_mhz         =  1150 [MHz]
/sys/class/drm/card0/gt_boost_freq_mhz       =  1150 [MHz]
/sys/kernel/debug/dri/0/i915_ring_freq_table: 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 1050 1100 1150 [MHz] 

+++ Wireless
bluetooth = off (software)
wifi      = on
wwan      = none (no device)

wlp2s0(iwlwifi)               : wifi, not connected, power management = off

+++ Audio
/sys/module/snd_hda_intel/parameters/power_save            = 0
/sys/module/snd_hda_intel/parameters/power_save_controller = N

+++ PCIe Active State Power Management
/sys/module/pcie_aspm/parameters/policy = default (using bios preferences)

+++ Runtime Power Management
Device blacklist = (not configured)
Driver blacklist = amdgpu nouveau nvidia radeon pcieport

/sys/bus/pci/devices/0000:00:00.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:02.0/power/control = on   (0x030000, VGA compatible controller, i915)
/sys/bus/pci/devices/0000:00:03.0/power/control = on   (0x040300, Audio device, snd_hda_intel)
/sys/bus/pci/devices/0000:00:14.0/power/control = on   (0x0c0330, USB controller, xhci_hcd)
/sys/bus/pci/devices/0000:00:16.0/power/control = on   (0x078000, Communication controller, mei_me)
/sys/bus/pci/devices/0000:00:19.0/power/control = on   (0x020000, Ethernet controller, e1000e)
/sys/bus/pci/devices/0000:00:1a.0/power/control = on   (0x0c0320, USB controller, ehci-pci)
/sys/bus/pci/devices/0000:00:1b.0/power/control = on   (0x040300, Audio device, snd_hda_intel)
/sys/bus/pci/devices/0000:00:1c.0/power/control = on   (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:1c.1/power/control = on   (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:1c.2/power/control = on   (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:1c.4/power/control = on   (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:1d.0/power/control = on   (0x0c0320, USB controller, ehci-pci)
/sys/bus/pci/devices/0000:00:1f.0/power/control = on   (0x060100, ISA bridge, lpc_ich)
/sys/bus/pci/devices/0000:00:1f.2/power/control = on   (0x010601, SATA controller, ahci)
/sys/bus/pci/devices/0000:00:1f.3/power/control = on   (0x0c0500, SMBus, i801_smbus)
/sys/bus/pci/devices/0000:02:00.0/power/control = on   (0x028000, Network controller, iwlwifi)
/sys/bus/pci/devices/0000:08:00.0/power/control = on   (0xff0000, Unassigned class [ff00], rtsx_pci)

+++ USB
Autosuspend         = disabled
Device whitelist    = (not configured)
Device blacklist    = (not configured)
Bluetooth blacklist = disabled
Phone blacklist     = disabled
WWAN blacklist      = enabled

Bus 004 Device 002 ID 8087:8000 control = auto, autosuspend_delay_ms =    0 -- Intel Corp.  (hub)
Bus 004 Device 001 ID 1d6b:0002 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)
Bus 001 Device 002 ID 8087:8008 control = auto, autosuspend_delay_ms =    0 -- Intel Corp.  (hub)
Bus 001 Device 001 ID 1d6b:0002 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)
Bus 003 Device 001 ID 1d6b:0003 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 3.0 root hub (hub)
Bus 002 Device 003 ID 04f2:b398 control = auto, autosuspend_delay_ms = 2000 -- Chicony Electronics Co., Ltd  (uvcvideo)
Bus 002 Device 001 ID 1d6b:0002 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)

+++ Battery Features: Charge Thresholds and Recalibrate
natacpi    = active (data, thresholds)
tpacpi-bat = active (recalibrate)
tp-smapi   = inactive (ThinkPad not supported)

+++ ThinkPad Battery Status: BAT0 (Main / Internal)
/sys/class/power_supply/BAT0/manufacturer                   = SANYO
/sys/class/power_supply/BAT0/model_name                     = 45N1159
/sys/class/power_supply/BAT0/cycle_count                    = (not supported)
/sys/class/power_supply/BAT0/energy_full_design             =  47520 [mWh]
/sys/class/power_supply/BAT0/energy_full                    =  39980 [mWh]
/sys/class/power_supply/BAT0/energy_now                     =  26140 [mWh]
/sys/class/power_supply/BAT0/power_now                      =      0 [mW]
/sys/class/power_supply/BAT0/status                         = Unknown (threshold effective)

/sys/class/power_supply/BAT0/charge_start_threshold         =     45 [%]
/sys/class/power_supply/BAT0/charge_stop_threshold          =     45 [%]
tpacpi-bat.BAT0.forceDischarge                              =      0

Charge                                                      =   65.4 [%]
Capacity                                                    =   84.1 [%]


Thanks for your persistence! BTW, maybe I overlooked it: Are you on Manjaro Xfce? I am. And my Tumbleweed where all is fine is on KDE/Plasma; don‘t know yet how Tmblwd does power management.

No, I'm on OpenBox (here is config I use) but configuration use pretty many components from XFCE. I guess it's not the case of distribution, but desktop environment. Plasma is doing many things in other way than other GTK DEs or at least XFCE. For example audio playback. Don't know how to explain this but XFCE is more straight forward in this manner. I'll try to find podcast where this subject was a bit explained :slight_smile:

Update: Did another test. Played the same playlist with Audacious instead of mpd, output configured to be bitperfect to ALSA. Guess what? Audacious gets stuck in the very same way as mpd when advancing from one track to the next if that involves a samplerate change. It throws ”ALSA error: snd_pcm_open failed: File or directory not found“. I guess it‘s the same as the ”unknown device“ from mpd/alsa.

So I do think now the root cause is somewhere in the settings of Manjaro, Xfce, tlp.

I still have to compare our tlp settings, @Mr_Glitch. What bothers me most now is that both USB-DACs and the internal sound card get disengaged when either audio player stumbles.

Forum kindly sponsored by