You are not logged in.

#1 2014-07-26 22:14:25

PlasmaSheep
Member
Registered: 2012-01-22
Posts: 25

[SOLVED] MPD isn't making any sound while running as its own user

I can't make MPD produce any sound when it runs as its own user.

- I'm running MPD from systemctl
- If I run MPD as my own user I get sound
- I am not using pulseaudio
- mpv, for example, plays sound fine
- speaker-test -c 2 -D hw:1 plays sound fine
- journalctl -u mpd gives errors of the following type:

Jul 26 15:08:25 alexei-desktop mpd[5951]: alsa_output: Failed to open "My ALSA Device" [alsa]: Failed to open ALSA device "default": No such file or directory
Jul 26 15:08:25 alexei-desktop mpd[5951]: output: Failed to open audio output
Jul 26 15:08:25 alexei-desktop mpd[5951]: player: problems opening audio device while playing "deep_medi/releases_volume_one/01-Kalawanji.flac"

/etc/mpd.conf for sound outputs:

audio_output {
        type            "alsa"
        name            "My ALSA Device"
#       device          "plughw:1"      # optional
#       format          "44100:16:2"    # optional
#       mixer_type      "hardware"      # optional
#       mixer_device    "default"       # optional
#       mixer_control   "PCM"           # optional
#       mixer_index     "0"             # optional
}

My ~/.asoundrc looks like this:

pcm.!default {
	type plug
	slave.pcm "dmixer"
}

pcm.dmixer  {
 	type dmix
 	ipc_key 1024
 	slave {
		pcm "hw:0,0"
		period_time 0
		period_size 1024
		buffer_size 4096
		rate 44100
	}
	bindings {
		0 0
		1 1
	}
}

ctl.dmixer {
	type hw
	card 0
}
> groups mpd
audio mpd
> aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: SB [HDA ATI SB], device 0: ALC888 Analog [ALC888 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: SB [HDA ATI SB], device 1: ALC888 Digital [ALC888 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Last edited by PlasmaSheep (2014-08-02 03:45:07)

Offline

#2 2014-07-26 22:24:13

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] MPD isn't making any sound while running as its own user

You did not specify the device in audio output definition. Do you know what using type hw means?

Alsa wiki wrote:

    Simply setting a type hw as default card is equivalent to addressing hardware directly, which leaves the device unavailable to other applications. This method is only recommended if it is a part of a more sophisticated setup ~/.asoundrc or if user deliberately wants to address sound card directly (digital output through eic958 or dedicated music server for example).

Do you really want that? Where do you have that pcm.dmixer definition from? Using both period_size and period_time makes no sense. Your setup is particular, since there is no card 0, which the dmixer is pointing to and which mpd very likely tries to use. You could change dmixer to the sound card you want to use, and then set audio output definition to use dmixer.

Other than that, you could simply set the SB to your default sound card by using modprobe options as stated on alsa wiki. Then no further mpd configuration should be necessary. Remember, if you do not do that, other applications might also try to use the default card 0, which is not specified on your system. I assume however, you already did set modprobe up.

Last edited by emeres (2014-07-26 22:30:32)

Offline

#3 2014-07-26 22:41:07

PlasmaSheep
Member
Registered: 2012-01-22
Posts: 25

Re: [SOLVED] MPD isn't making any sound while running as its own user

Do you really want that?

I'll be honest, I have no idea what I'm doing when it comes to configuring ALSA.

Your setup is particular, since there is no card 0, which the dmixer is pointing to.

When I started my computer, I had a DAC attached by USB... I'm guessing it was card 0, and disappeared when I removed it.

You could change dmixer to the soundcard you want to use, and then set audio output definition to use dmixer.

I was actually reading the arch wiki, and I saw this quote:

For ALSA 1.0.9rc2 and higher on analog sound outputs you do not need to setup dmix. Dmix is enabled as default for soundcards which do not support hardware mixing.

I have alsa k3.15.5-2-ARCH, so surely I should be able to not even bother with dmix?

Offline

#4 2014-07-26 22:52:07

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] MPD isn't making any sound while running as its own user

You actually used hw directly only with speaker-test so far, but that audio output was changed, and using plughw will also block other sound. In itself it is fine, but you need to understand that, before you wonder why no other sound source works.

Yes, that is a very plausible explanation for sudden disappearing of card 0. And yes, dmix as such already exists, so speaker-test -D dmix would work, if card 0 would be present, and speaker-test -D dmix:1 should work with the current setup.

Maybe you can describe how do you want to use those different sound cards, then we can figure out the optimal solution.

Last edited by emeres (2014-07-26 22:56:33)

Offline

#5 2014-07-26 22:57:42

PlasmaSheep
Member
Registered: 2012-01-22
Posts: 25

Re: [SOLVED] MPD isn't making any sound while running as its own user

I see, that makes sense.

Ideally, I'd like a setup that plays sound to line out if there's no usb DAC, and plays to the DAC if its connected.

Offline

#6 2014-07-26 23:11:13

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] MPD isn't making any sound while running as its own user

If you want this to be done automatically, it could be a little tricky, but should be feasible. The simplest and therefore less error prone solution would be, to set your SB card as card 0 using modprobe options as described on the wiki. Then set up two different mpd audio outputs, one for SB and one for the DAC. You could simply switch between them, maybe even using shortcuts, or write a udev rule, so that is will be switched automatically.

Should you want to follow this approach, stick the dac back in and post the output of 'aplay -l'. Then follow the wiki. After that, define two audio outputs, and here you can use dmix, but it may have some limitations with surround sound sources playing at the same time as other formats. So the mpd configuration for outputs could look like:

audio_output {
        type            "alsa"
        name            "Internal Sound Card"
       device          "dmix:SB"
#       format          "48000:24:2"
#       mixer_type      "software"
}

audio_output {
        type            "alsa"
        name            "Digital to Analog Converter - USB"
       device          "dmix:DAC"
#       format          "48000:24:2"
#       mixer_type      "software"
}

Use card name references instead of numbers.

Alsa configuration could be changed on the fly, but that could prove even more difficult, so I would stick to the approach presented.

Using dmix with runtime arguments could be problematic under some circumstances, so you could also define two dmix definitions for both card and use them instead. But try this first, maybe it will fully satisfy your needs with no negative effects.

Edit: Sorry for the many edits, but I am tired already.

Last edited by emeres (2014-07-26 23:33:46)

Offline

#7 2014-07-26 23:36:45

PlasmaSheep
Member
Registered: 2012-01-22
Posts: 25

Re: [SOLVED] MPD isn't making any sound while running as its own user

Sure, sounds good.

> aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: CODEC [USB Audio CODEC], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: SB [HDA ATI SB], device 0: ALC888 Analog [ALC888 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: SB [HDA ATI SB], device 1: ALC888 Digital [ALC888 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
> lsmod | grep snd
snd_hda_codec_realtek    54803  1 
snd_hda_codec_generic    56366  1 snd_hda_codec_realtek
snd_hda_codec_hdmi     40396  1 
snd_usb_audio         131860  2 
snd_usbmidi_lib        21428  1 snd_usb_audio
snd_rawmidi            20278  1 snd_usbmidi_lib
snd_hda_intel          22831  2 
snd_seq_device          5244  1 snd_rawmidi
snd_hda_controller     22911  1 snd_hda_intel
snd_hda_codec         104665  5 snd_hda_codec_realtek,snd_hda_codec_hdmi,snd_hda_codec_generic,snd_hda_intel,snd_hda_controller
snd_hwdep               6652  2 snd_usb_audio,snd_hda_codec
snd_pcm                83207  6 snd_usb_audio,snd_hda_codec_hdmi,snd_hda_codec,snd_hda_intel,snd_hda_controller
snd_timer              19294  2 snd_pcm
snd                    61276  18 snd_hda_codec_realtek,snd_usb_audio,snd_hwdep,snd_timer,snd_hda_codec_hdmi,snd_pcm,snd_rawmidi,snd_hda_codec_generic,snd_usbmidi_lib,snd_hda_codec,snd_hda_intel,snd_seq_device
soundcore               5551  2 snd,snd_hda_codec
usbcore               188381  7 snd_usb_audio,ohci_hcd,ohci_pci,snd_usbmidi_lib,ehci_hcd,ehci_pci,usbhid
> cat /etc/modprobe.d/alsa-base.conf
options snd slots=snd_usbaudio,snd_hda_intel
options snd_hda_intel index=0
options snd_hda_usbaudio index=1

I'm not exactly sure what to put in ~/.asoundrc, however...

Offline

#8 2014-07-26 23:43:55

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] MPD isn't making any sound while running as its own user

PlasmaSheep wrote:

I'm not exactly sure what to put in ~/.asoundrc, however...

Delete it.

Use CODEC instead of DAC for dmix runtime argument (dmix:CODEC).

Where did you read to use both slots and index options? I want a link. Found it, needs changing. Deleted that part for now from the wiki.

options snd_hda_intel index=0
options snd_usb_audio index=1

That might work, but you have two cards using snd-hda-intel. When someone refers you to the alsa wiki, follow. Read the whole chapter. You should use vid and pid. Alternatively use id parameter with sound card name references, but using vid and pid is a better approach.

And again where did you get this dmixer definition from?

Edit: Corrected module name

Last edited by emeres (2014-07-30 23:12:35)

Offline

#9 2014-07-26 23:50:34

PlasmaSheep
Member
Registered: 2012-01-22
Posts: 25

Re: [SOLVED] MPD isn't making any sound while running as its own user

Where did you read to use both slots and index options? I want a link. When someone refers you to the alsa wiki, follow.

The very first example in the linked section (which is the one I followed) has both slots and index options.

When I run `lspci -nn | grep -i audio`, I get this:

00:14.2 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] SBx00 Azalia (Intel HDA) [1002:4383]
01:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Redwood HDMI Audio [Radeon HD 5000 Series] [1002:aa60]

Which seems to be my onboard line out and hdmi audio from my graphics card - but no DAC.

Offline

#10 2014-07-26 23:53:42

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] MPD isn't making any sound while running as its own user

As in the edit, I deleted that. The whole section needs rewriting. Dmixer?

The DAC uses usb, you listed pci devices. Use lsusb instead.

However, that part is not really necessary, since you want the SB to be default. The rest is cosmetic, unless you plan to address the DAC with number references or for other reasons.

Edit: I deleted the dmixer redundant key as well, should you have that definition from somewhere else on the wiki, please tell. Those need to be corrected.

Last edited by emeres (2014-07-27 00:08:30)

Offline

#11 2014-07-27 21:58:44

PlasmaSheep
Member
Registered: 2012-01-22
Posts: 25

Re: [SOLVED] MPD isn't making any sound while running as its own user

This isn't quite working. MPD can make sound, but no other application can make sound when playing into line out (my onboard sound card, which does not support hardware mixing).

> cat /etc/modprobe.d/alsa-base.conf 
options snd_hda_intel index=0 model=auto vid=1002 pid=4383
options snd_hda_usbaudio index=1 model=auto

I've deleted .asoundrc.

Offline

#12 2014-07-27 22:18:19

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] MPD isn't making any sound while running as its own user

I assume this should be snd_usb_audio not snd_hda_usbaudio.

PlasmaSheep wrote:

This isn't quite working. MPD can make sound, but no other application can make sound when playing into line out (my onboard sound card, which does not support hardware mixing).

Did you use dmix:SB or hw:SB?

fuser -v /dev/snd/*

Maybe it will be necessary to create custom pcms for both cards, but since you set SB as default with modprobe comment the device line dmix:SB out and restart mpd. Dmix:SB could be blocking the usual path, I would have to test this. Can you run those speaker-test combinations?

# edit: all of those are not really suitable for testing,
# unless used with custom dmix
speaker-test -c 2 -t wav 
speaker-test -c 2 -t wav -D dmix:SB

speaker-test -c 2 -t wav 
speaker-test -c 2 -t wav -D dmix

speaker-test -c 2 -t wav -D dmix
speaker-test -c 2 -t wav -D dmix:SB

Edit: I have tested it. Pcm.dmix should not block the conventional path through pcm.default, which then points to dmix. I get simultaneous output using the defaults configuration from these commands (one of my cards is also an Azalia):

speaker-test -c 2 -t wav -p 4 -D plug:dmix:SB
speaker-test -c 2 -r 192000 -F S32_LE -p 4 -D default:SB

You could try using plug:dmix:SB for output device, since other applications might want to use other format settings and then fail, with this mpd should be recessive.

Last edited by emeres (2014-07-31 00:31:48)

Offline

#13 2014-07-30 19:25:17

PlasmaSheep
Member
Registered: 2012-01-22
Posts: 25

Re: [SOLVED] MPD isn't making any sound while running as its own user

I assume this should be snd_usb_audio not snd_hda_usbaudio.

Not according to your earlier post:

options snd_hda_intel index=0
options snd_hda_usbaudio index=1
> sudo fuser -v /dev/snd/*
                     USER        PID ACCESS COMMAND
/dev/snd/controlC0:  mpd         247 F.... mpd

speaker-test #1 works, #2 errors, #3 works,  #4 errors, #5 errors, #6 errors, #7 works, #8 works.



/etc/mpd.conf:

audio_output {
        type            "alsa"
        name            "Internal Sound Card"
#       device          "dmix:SB"
#       format          "48000:24:2"
#       mixer_type      "software"
}

audio_output {
        type            "alsa"
        name            "CODEC"
       device          "dmix:CODEC"
#       format          "48000:24:2"
#       mixer_type      "software"
}

Commenting the line does not fix the issue.

Configuring MPD like this does not fix the issue:

audio_output {
        type            "alsa"
        name            "Internal Sound Card"
       device          "plug:dmix:SB"
#       format          "48000:24:2"
#       mixer_type      "software"
}

audio_output {
        type            "alsa"
        name            "CODEC"
       device          "dmix:CODEC"
#       format          "48000:24:2"
#       mixer_type      "software"
}

Last edited by PlasmaSheep (2014-07-30 19:28:01)

Offline

#14 2014-07-30 19:40:09

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] MPD isn't making any sound while running as its own user

I 'quoted' your previous post, should have caught that though. There is no snd_hda_usbaudio module. You still should use vid and pid. You used vid and pid for SB, which is the relevant card in this case, should be good enough. Just remember, should you use another usb sound card at the same time, it might get index=1, when vid and pid are not specified. Please post 'aplay -L' (the big L).

Try uncommenting the mixer_type software lines, then restart mpd with no active sounds, although it seems hardware control is working judging from fuser output, at least for SB. Since the last two work for you, why not try using them: set both to default:card or both to plug:dmix:card. On my setup I can run dmix:SB and plug:dmix:SB as output devices without problems. It may be necessary to specify format for those outputs, you can use speaker-test with different options/switches to get the correct parameters, see 'man speaker-test'. The format for SB could be equivalent to what you already tested (192000:32:2). Did you use those mpd outputs separately or simultaneously? What client are you using for mpd?

Should the above still produce no sound through SB or CODEC, then just define new pcms in ~/.asoundrc and use it as output device inside mpds configuration:

# One possible definition set could be
pcm.sb { type plug;
slave.pcm "dmix:SB"; }

pcm.sb2 { type plug;
slave.pcm "default:SB"; }

pcm.codec { type plug;
slave.pcm "hw:CODEC"; }

Last edited by emeres (2014-07-31 00:30:57)

Offline

#15 2014-07-31 20:18:55

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: [SOLVED] MPD isn't making any sound while running as its own user


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#16 2014-08-02 03:44:53

PlasmaSheep
Member
Registered: 2012-01-22
Posts: 25

Re: [SOLVED] MPD isn't making any sound while running as its own user

I assume this should be snd_usb_audio not snd_hda_usbaudio.

This change seems to have fixed my problem. Thank you.

Offline

#17 2014-08-02 09:37:02

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [SOLVED] MPD isn't making any sound while running as its own user

So what is your current mpd configuration? Others might benefit from it.

PlasmaSheep wrote:

Thank you.

You are welcome.

Offline

#18 2014-08-02 20:20:30

PlasmaSheep
Member
Registered: 2012-01-22
Posts: 25

Re: [SOLVED] MPD isn't making any sound while running as its own user

audio_output {
        type            "alsa"
        name            "Internal Sound Card"
       device          "plug:dmix:SB"
#       format          "48000:24:2"
#       mixer_type      "software"
}

audio_output {
        type            "alsa"
        name            "CODEC"
       device          "dmix:CODEC"
#       format          "48000:24:2"
#       mixer_type      "software"
}

Offline

#19 2019-12-07 23:29:48

2ManyDogs
Forum Moderator
Registered: 2012-01-15
Posts: 4,645

Re: [SOLVED] MPD isn't making any sound while running as its own user

gimesketvirtadieni, welcome to the forum. This thread is very old, and the original poster has not been back since 2015. Please do not necrobump.

Closing.


How to post. A sincere effort to use modest and proper language and grammar is a sign of respect toward the community.

Offline

Board footer

Powered by FluxBB