Skip to main content
Topic: Mpd, pipewire and dinit. Am I doing this right? (Read 968 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Mpd, pipewire and dinit. Am I doing this right?

Just wanted to share my experience and maybe get some feedback on my methods as I'm not sure if I did this at all right, it was hard to find documentation in many cases, everything seeming to be systemd-focused.

So first I installed mpd and mpd-dinit, as well as cantata for an interface with pacman.

I then took a lengthy detour trying to get mpd to run as a user service, which I could probably now due but I think having it run as the mpd user is better (?).

I was having a weird issue where I was getting no errors in the logs but when opening cantata and trying to play something I got no audio, only response I got was the volume in cantata would snap to 0% when clicking play.  Frustrating.

If I just ran mpd in a console (as my user) it would work no problem.

So I figured the issue was something along the lines of: pipewire-pulse is running as my user, so mpd won't have access to it... which doesn't really make sense I don't think, because I'm pretty sure by default mpd-dinit will run mpd as root.

Anyway, my solution in the end was as follows:

1) Edit /etc/mpd.conf, add the following:
Code: [Select]
user "mpd"
audio_output {
       type            "pulse"
       name            "My Pulse Output"
}
Would it be better to create a home directory for mpd and put the edited mpd.conf in /home/mpd/.mpdconf?
I'm assuming if mpd receives an update the mpd.conf in /etc/ will be overwritten.

2) Create tcp.conf in /etc/pipewire/pipewire-pulse.conf.d and put this in it:
Code: [Select]
pulse.properties = {
    # the addresses this server listens on
    server.address = [
        #"unix:native"
        #"unix:/tmp/something"              # absolute paths may be used
        "tcp:4713"                         # IPv4 and IPv6 on all addresses
        #"tcp:[::]:9999"                    # IPv6 on all addresses
        #"tcp:127.0.0.1:8888"               # IPv4 on a single address
        #
        #{ address = "tcp:4713"             # address
        #  max-clients = 64                 # maximum number of clients
        #  listen-backlog = 32              # backlog in the server listen queue
        #  client.access = "restricted"     # permissions for clients
        #}
    ]
    #pulse.min.req          = 256/48000     # 5ms
    #pulse.default.req      = 960/48000     # 20 milliseconds
    #pulse.min.frag         = 256/48000     # 5ms
    #pulse.default.frag     = 96000/48000   # 2 seconds
    #pulse.default.tlength  = 96000/48000   # 2 seconds
    #pulse.min.quantum      = 256/48000     # 5ms
    #pulse.idle.timeout     = 0             # don't pause after underruns
    #pulse.default.format   = F32
    #pulse.default.position = [ FL FR ]
    # These overrides are only applied when running in a vm.
    vm.overrides = {
        pulse.min.quantum = 1024/48000      # 22ms
    }
}

So at this point mpd seemed to be functioning properly.  I could start it with dinitctl and connect with cantata and play no problem.  And it was running as the mpd user.
However I then had an issue where pavucontrol wouldn't connect to pipewire-pulse at all.
So I found and edited /etc/pulse/client.conf and uncommented this line:
Code: [Select]
auto-connect-localhost = yes

And now everything seems to work fine.

I'm just wondering if anyone has any ideas on whether I really messed some stuff up here, or went about it in a dumb way.

Re: Mpd, pipewire and dinit. Am I doing this right?

Reply #1
It looks fine to me, but if you use pipewire anyway why not make mpd output JACK? Should be superior to the pulse backend. Just install pipewire-jack.

Maybe this way you won't even need the workaround above, since even if it fails running "pw-jack mpd" is pretty much failproof.

Re: Mpd, pipewire and dinit. Am I doing this right?

Reply #2
Hmm ya I'll look into that, I don't think I've used jack in 15 years or so - not since I was playing around with instruments and interfaces and mixers and junk.

Edit:

Even though I thought everything was working, it turns out even though pavucontrol seems to connect fine, no adjustment to volumes do anything, even though the meters bounce when an application is playing audio.  Not sure what's going on there.

Anyone have any ideas?

Edit2:

Okay I'm dumb.

In this section of the pipewire-pulse config:
Code: [Select]
pulse.properties = {
    # the addresses this server listens on
    server.address = [
        #"unix:native"
        #"unix:/tmp/something"              # absolute paths may be used
        "tcp:4713"                         # IPv4 and IPv6 on all addresses
        #"tcp:[::]:9999"                    # IPv6 on all addresses
        #"tcp:127.0.0.1:8888"               # IPv4 on a single address
        #
        #{ address = "tcp:4713"             # address
        #  max-clients = 64                 # maximum number of clients
        #  listen-backlog = 32              # backlog in the server listen queue
        #  client.access = "restricted"     # permissions for clients
        #}
    ]

I had commented out the line "unix:native" thinking I had to pick one, without reading it clearly and seeing it states "the addresses this server listens on" so I just uncommented "tcp:127.0.0.1:8888" and left "unix:native" available as well.  Now I can connect with mpd and also my pavucontrol functions as expected.