Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Pulseaudio --> Pipewire setup issues
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
62626368616e
n00b
n00b


Joined: 23 May 2020
Posts: 30

PostPosted: Wed Mar 03, 2021 6:06 am    Post subject: Pulseaudio --> Pipewire setup issues Reply with quote

Hi!

I am trying to convert from Pulseaudio to Pipewire. My system is using sddm + kde + X and OpenRC.When I run `pactl info` I get the following message:
Code:
sleepy@magi ~ $ pactl info
XDG_RUNTIME_DIR (/tmp) is not owned by us (uid 1000), but by uid 0! (This could e.g. happen if you try to connect to a non-root PulseAudio as a root user, over the native protocol. Don't do that.)
Connection failure: Connection refused
pa_context_connect() failed: Connection refused


Looking at my processes shows that pulse and pipewire are running under my user:
Code:
sleepy@magi ~ $ ps aux | grep pipewire
sleepy    4911  0.6  0.0 148108 17944 ?        S<l  19:57   0:01 pipewire
sleepy    4925  0.1  0.0 176652 25928 ?        S<l  19:57   0:00 /usr/bin/pipewire-media-session
sleepy    4926  0.7  0.0 103304  8052 ?        S<Ll 19:57   0:01 /usr/bin/pipewire -c pipewire-pulse.conf
sleepy    6645  0.0  0.0  10132   704 pts/1    S+   20:00   0:00 grep --colour=auto pipewire
sleepy@magi ~ $ ps aux | grep pulse
sleepy    4926  0.7  0.0 103304  8052 ?        S<Ll 19:57   0:01 /usr/bin/pipewire -c pipewire-pulse.conf
sleepy    5153  0.0  0.0 322548 25424 ?        S<l  19:57   0:00 pulseaudio --start
sleepy    5185  0.0  0.0 235288  6908 ?        Sl   19:57   0:00 /usr/libexec/pulse/gsettings-helper
sleepy    6647  0.0  0.0  10116  2216 pts/1    S+   20:00   0:00 grep --colour=auto pulse


/tmp has 1777 permissions:
Code:
sleepy@magi ~ $ ls -l / | grep tmp
drwxrwxrwt   7 root root 20480 Mar  2 20:02 tmp


Fwiw here's my .xinitrc and pipewire.conf and package info:
Code:
sleepy@magi ~ $ cat ~/.xinitrc
#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/Xresources
sysmodmap=/etc/X11/xinit/Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then







    xrdb -merge $sysresources

fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then







    xrdb -merge "$userresources"

fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs
/usr/bin/pipewire

Code:
sleepy@magi ~ $ cat /etc/pipewire/pipewire.conf
# Daemon config file for PipeWire version "0.3.22" #
context.properties = {
    ## Configure properties in the system.
    #library.name.system                   = support/libspa-support
    #context.data-loop.library.name.system = support/libspa-support
    #support.dbus                          = true
    #link.max-buffers                      = 64
    link.max-buffers                       = 16                       # version < 3 clients can't handle more
    #mem.warn-mlock                        = false
    #mem.allow-mlock                       = true
    #mem.mlock-all                         = false
    #log.level                             = 2

    core.daemon                            = true                     # listening for socket connections
    core.name                              = pipewire-0               # core name and socket name

    ## Properties for the DSP configuration.
    #default.clock.rate        = 48000
    #default.clock.quantum     = 1024
    #default.clock.min-quantum = 32
    #default.clock.max-quantum = 8192
    #default.video.width       = 640
    #default.video.height      = 480
    #default.video.rate.num    = 25
    #default.video.rate.denom  = 1
}

context.spa-libs = {
    #<factory-name regex> = <library-name>
    #
    # Used to find spa factory names. It maps an spa factory name
    # regular expression to a library name that should contain
    # that factory.
    #
    audio.convert.* = audioconvert/libspa-audioconvert
    api.alsa.*      = alsa/libspa-alsa
    api.v4l2.*      = v4l2/libspa-v4l2
    api.libcamera.* = libcamera/libspa-libcamera
    api.bluez5.*    = bluez5/libspa-bluez5
    api.vulkan.*    = vulkan/libspa-vulkan
    api.jack.*      = jack/libspa-jack
    support.*       = support/libspa-support
    #videotestsrc   = videotestsrc/libspa-videotestsrc
    #audiotestsrc   = audiotestsrc/libspa-audiotestsrc
}

context.modules = {
    #<module-name> = {
    #    [ args = { <key> = <value> ... } ]
    #    [ flags = [ [ ifexists ] [ nofail ] ]
    #}
    #
    # Loads a module with the given parameters.
    # If ifexists is given, the module is ignored when it is not found.
    # If nofail is given, module initialization failures are ignored.
    #

    # Uses RTKit to boost the data thread priority.
    libpipewire-module-rtkit = {
        args = {
            #nice.level   = -11
            #rt.prio      = 20
            #rt.time.soft = 200000
            #rt.time.hard = 200000
        }
        flags = [ ifexists nofail ]
    }

    # The native communication protocol.
    libpipewire-module-protocol-native = null

    # The profile module. Allows application to access profiler
    # and performance data. It provides an interface that is used
    # by pw-top and pw-profiler.
    libpipewire-module-profiler = null

    # Allows applications to create metadata objects. It creates
    # a factory for Metadata objects.
    libpipewire-module-metadata = null

    # Creates a factory for making devices that run in the
    # context of the PipeWire server.
    libpipewire-module-spa-device-factory = null

    # Creates a factory for making nodes that run in the
    # context of the PipeWire server.
    libpipewire-module-spa-node-factory = null

    # Allows creating nodes that run in the context of the
    # client. Is used by all clients that want to provide
    # data to PipeWire.
    libpipewire-module-client-node = null

    # Allows creating devices that run in the context of the
    # client. Is used by the session manager.
    libpipewire-module-client-device = null

    # The portal module monitors the PID of the portal process
    # and tags connections with the same PID as portal
    # connections.
    libpipewire-module-portal = null

    # The access module can perform access checks and block
    # new clients.
    libpipewire-module-access = {
        args = {
            # access.allowed to list an array of paths of allowed
            # apps.
            #access.allowed = [
            #    /usr/bin/pipewire-media-session
            #]

            # An array of rejected paths.
            #access.rejected = [ ]

            # An array of paths with restricted access.
            #access.restricted = [ ]

            # Anything not in the above lists gets assigned the
            # access.force permission.
            #access.force = flatpak
        }
    }

    # Makes a factory for wrapping nodes in an adapter with a
    # converter and resampler.
    libpipewire-module-adapter = null

    # Makes a factory for creating links between ports.
    libpipewire-module-link-factory = null

    # Provides factories to make session manager objects.
    libpipewire-module-session-manager = null
}

context.objects = {
    #<factory-name> = {
    #    [ args  = { <key> = <value> ... } ]
    #    [ flags = [ [ nofail ] ]
    #}
    #
    # Creates an object from a PipeWire factory with the given parameters.
    # If nofail is given, errors are ignored (and no object is created).
    #
    #spa-node-factory   = { args = { factory.name = videotestsrc node.name = videotestsrc Spa:Pod:Object:Param:Props:patternType = 1 } }
    #spa-device-factory = { args = { factory.name = api.jack.device foo=bar } flags = [ nofail ] }
    #spa-device-factory = { args = { factory.name = api.alsa.enum.udev } }
    #spa-device-factory = { args = { factory.name = api.alsa.seq.bridge node.name = Internal-MIDI-Bridge } }
    #adapter            = { args = { factory.name = audiotestsrc node.name = my-test } }
    #spa-node-factory   = { args = { factory.name = api.vulkan.compute.source node.name = my-compute-source } }

    # A default dummy driver. This handles nodes marked with the "node.always-driver"
    # property when no other driver is currently active. JACK clients need this.
    spa-node-factory = {
        args = {
            factory.name    = support.node.driver
            node.name       = Dummy-Driver
            priority.driver = 8000
        }
    }
    # This creates a new Source node. It will have input ports
    # that you can link, to provide audio for this source.
    #adapter = {
    #    args = {
    #        factory.name     = support.null-audio-sink
    #        node.name        = my-mic
    #        node.description = Microphone
    #        media.class      = Audio/Source/Virtual
    #        audio.position   = "FL,FR"
    #    }
    #}

    # This creates a single PCM source device for the given
    # alsa device path hw:0. You can change source to sink
    # to make a sink in the same way.
    #adapter = {
    #    args = {
    #        factory.name            = api.alsa.pcm.source
    #        node.name               = alsa-source
    #        node.description        = "PCM Source"
    #        media.class             = Audio/Source
    #        api.alsa.path           = hw:0
    #        #api.alsa.period-size   = 1024
    #        #api.alsa.headroom      = 0
    #        #api.alsa.disable-mmap  = false
    #        #api.alsa.disable-batch = false
    #        #audio.format           = "S16LE
    #        #audio.rate             = 48000
    #        #audio.channels         = 2
    #        #audio.position         = "FL,FR"
    #    }
    #}
}

context.exec = {
    #<program-name> = { [ args = "<arguments>" ] }
    #
    # Execute the given program with arguments.
    #
    # Start the session manager. Run the session manager with -h for
    # options.
    #
    "/usr/bin/pipewire-media-session" = { args = "" }
    #
    # You can optionally start the pulseaudio-server here as well
    # but it better to start it as a systemd service.
    # It can be interesting to start another daemon here that listens
    # on another address with the -a option (eg. -a tcp:4713).
    #
    "/usr/bin/pipewire" = { args = "-c pipewire-pulse.conf" }
}

Code:
[?] media-video/pipewire
     Available versions:  (~)0.2.7(0/0.2) {X bluetooth doc ffmpeg gstreamer sdl systemd vaapi}
     Installed versions:  0.3.22(0/0.3)^t(04:35:22 AM 02/22/2021)(X bluetooth ffmpeg sdl vulkan -debug -doc -gstreamer -jack -sndfile -systemd -test)
     Homepage:            https://pipewire.org/
     Description:         Multimedia processing graphs

Code:
[?] media-sound/pulseaudio
     Available versions:  13.0^t {+X +alsa +alsa-plugin +asyncns bluetooth +caps dbus doc elogind equalizer gconf +gdbm +glib gtk ipv6 jack libressl libsamplerate lirc native-headset ofono-headset +orc oss qt5 realtime selinux sox ssl system-wide systemd tcpd test +udev +webrtc-aec zeroconf ABI_MIPS="n32 n64 o32" ABI_RISCV="lp64 lp64d" ABI_S390="32 64" ABI_X86="32 64 x32" CPU_FLAGS_ARM="neon" KERNEL="linux"}
     Installed versions:  13.0-r1^t(02:48:18 AM 11/10/2020)(X alsa alsa-plugin asyncns bluetooth caps dbus elogind gdbm glib gtk ipv6 jack orc qt5 ssl tcpd udev webrtc-aec -doc -equalizer -gconf -libressl -libsamplerate -lirc -native-headset -ofono-headset -oss -realtime -selinux -sox -system-wide -systemd -test -zeroconf ABI_MIPS="-n32 -n64 -o32" ABI_S390="-32 -64" ABI_X86="32 64 -x32" CPU_FLAGS_ARM="-neon" KERNEL="linux")
     Homepage:            https://www.freedesktop.org/wiki/Software/PulseAudio/
     Description:         A networked sound server with an advanced plugin system

I am not really sure what's going wrong here and would appreciate the help to get this fixed! as always let me know if there's any more info needed...
Back to top
View user's profile Send private message
Perfect Gentleman
Veteran
Veteran


Joined: 18 May 2014
Posts: 1252

PostPosted: Wed Mar 03, 2021 10:53 am    Post subject: Reply with quote

Code:
~ $ grep -i spawn /etc/pulse/client.conf
autospawn = no
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21715

PostPosted: Wed Mar 03, 2021 4:28 pm    Post subject: Reply with quote

As I read that first message, it does not tolerate placing the runtime state in a directory owned by anyone other than the current user. You should be able to silence the XDG_RUNTIME_DIR warning by pointing that directory to one that is owned by you, and preferably mode 700.
Back to top
View user's profile Send private message
62626368616e
n00b
n00b


Joined: 23 May 2020
Posts: 30

PostPosted: Wed Mar 03, 2021 9:16 pm    Post subject: Reply with quote

Hu wrote:
As I read that first message, it does not tolerate placing the runtime state in a directory owned by anyone other than the current user. You should be able to silence the XDG_RUNTIME_DIR warning by pointing that directory to one that is owned by you, and preferably mode 700.


Ah, I see. I assume it is bad practice to point XDG_RUNTIME_DIR to /tmp then-- since chowning /tmp and setting mode 0700 would make things kind of wonky? Is there a proper directory I should set it to?
Back to top
View user's profile Send private message
62626368616e
n00b
n00b


Joined: 23 May 2020
Posts: 30

PostPosted: Wed Mar 03, 2021 9:29 pm    Post subject: Reply with quote

So I've tried exporting XDG_RUNTIME_DIR temporarily to a directory in /tmp owned by my user with mode 0700 but I'm still getting:
Code:
Connection failure: Connection refused
pa_context_connect() failed: Connection refused


Also set autospawn = no in /etc/pulse/client.conf. (from Perfect Gentleman's message above)

Audio is working just fine, I just can't use pactl (or pavucontrol) to connect to pulseaudio? Maybe there is an issue connecting to pulseaudio via pipewire? (see https://www.reddit.com/r/archlinux/comments/kxrrkv/issues_connecting_to_pipewirepulseaudio/)
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21715

PostPosted: Wed Mar 03, 2021 11:32 pm    Post subject: Reply with quote

Yes, leave /tmp as-is. Setting it to a subdirectory is fine. I am not aware of a specific recommended value, and would have expected that if there were one, the system should have set it up for you. I cannot comment on why your CLI is unable to manage audio. I had hoped, though without any evidence, that the XDG problem might be related. It appears that was just a warning, and not relevant to your real problem.
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Thu Mar 04, 2021 12:44 pm    Post subject: Reply with quote

you need XDG_RUNTIME_DIR set. This was confirmed in a couple of bugs on the pipewire tracker (took a bit to figure out what was causing issues... they didn't even know it was hard-needed set as it is being developed on a system that aligns to the XDG)

The wiki includes how to mitigate this if you are not running some session manager that will set these up for you

Code:
#-- ensure XDG_Runtime_dir is set
if test -z "${XDG_RUNTIME_DIR}"; then
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir
  if ! test -d "${XDG_RUNTIME_DIR}"; then
    mkdir "${XDG_RUNTIME_DIR}"
    chmod 0700 "${XDG_RUNTIME_DIR}"
    export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir
  fi
fi

_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
Perfect Gentleman
Veteran
Veteran


Joined: 18 May 2014
Posts: 1252

PostPosted: Thu Mar 04, 2021 1:12 pm    Post subject: Reply with quote

If you have pulseaudio still running that means you do it wrong.
It should smth like this:
Code:
 ~ $ ps aux | grep pulse
user+  6105  0.0  0.1  36816 22204 ?        SLl  18:00   0:03 /usr/bin/pipewire -c pipewire-pulse.conf
user+ 28365  0.0  0.0   8508  2196 pts/0    S+   20:13   0:00 grep --colour=auto pulse
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21715

PostPosted: Thu Mar 04, 2021 5:45 pm    Post subject: Reply with quote

Naib wrote:
The wiki includes how to mitigate this if you are not running some session manager that will set these up for you
Code:
#-- ensure XDG_Runtime_dir is set
if test -z "${XDG_RUNTIME_DIR}"; then
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir
  if ! test -d "${XDG_RUNTIME_DIR}"; then
    mkdir "${XDG_RUNTIME_DIR}"
    chmod 0700 "${XDG_RUNTIME_DIR}"
    export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir
  fi
fi
I suspect you are merely quoting from a Wiki here (which Wiki was it?), but I want to point out that this script could be improved:
  • The second export seems to be the same as the first, so it is unnecessary.
  • mkdir can create the directory with the right permissions: mkdir -m700 "${XDG_RUNTIME_DIR}"; this removes the need for an explicit chmod.
  • This creates the directory under a well-known and easily predicted name in a world-writable directory, which makes it subject to a denial-of-service if someone else created that directory first. Perhaps worse, since there are no error checks here, if someone else creates the directory, and gives you access to it, your programs might then create files in the directory the other person controls.
  • Testing for the directory and then creating it is racy, and could do the wrong thing if this script is running twice in parallel as the same user.
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Thu Mar 04, 2021 10:41 pm    Post subject: Reply with quote

Hu wrote:
Naib wrote:
The wiki includes how to mitigate this if you are not running some session manager that will set these up for you
Code:
#-- ensure XDG_Runtime_dir is set
if test -z "${XDG_RUNTIME_DIR}"; then
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir
  if ! test -d "${XDG_RUNTIME_DIR}"; then
    mkdir "${XDG_RUNTIME_DIR}"
    chmod 0700 "${XDG_RUNTIME_DIR}"
    export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir
  fi
fi
I suspect you are merely quoting from a Wiki here (which Wiki was it?), but I want to point out that this script could be improved:
  • The second export seems to be the same as the first, so it is unnecessary.
  • mkdir can create the directory with the right permissions: mkdir -m700 "${XDG_RUNTIME_DIR}"; this removes the need for an explicit chmod.
  • This creates the directory under a well-known and easily predicted name in a world-writable directory, which makes it subject to a denial-of-service if someone else created that directory first. Perhaps worse, since there are no error checks here, if someone else creates the directory, and gives you access to it, your programs might then create files in the directory the other person controls.
  • Testing for the directory and then creating it is racy, and could do the wrong thing if this script is running twice in parallel as the same user.

the Gentoo wiki and its the one I created and I recently added that there after digging into why pipewire was failing

I am sure it could be improved, I threw it together from snippets that attempted to do the same thing, to get it working and put it on the gentoo wiki incase other's needed help

Agreed 2nd export is redundant, it was a debug thing as the script grew
I forgot mkdir could do that
"well know" just as well known as /run/user/(id -u) so that isn't really valid. initially I tried to create it in /run/user but thats root writable. Now I have elogin so i am surprised that /run/user isn't created but who knows.
agreed racy, i could make aspects a singleton but well, thats part of the improvement
_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Thu Mar 04, 2021 10:57 pm    Post subject: Reply with quote

Code:
#-- ensure XDG_Runtime_dir is set
export XDG_RUNTIME_DIR=$(mktemp -d /tmp/$(id -u)-runtime-dir.XXX)

would spam-create multiple instances of these if multiple logics but that should resolve those concerns


either way the OP problem appears to be related to XDG and thus this user is not running a seat session manager and thus they will need to manage the creation of this directory themselves
_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
orbg1
n00b
n00b


Joined: 11 Mar 2021
Posts: 1

PostPosted: Thu Mar 11, 2021 12:19 pm    Post subject: Reply with quote

I had same issue with unable to connect(wiki article+unsetting autospawn pulseaudio server), in my case removing old configs such as ~/.config/pulse/* and /etc/pulse/* and reinstalling packages from source now works just good there.
You also shouldn't able to run both of it(pa and pw), run pipewire only, as it is have pa reimplementing already through itself

Code:
~ ps uax | grep -iE "pulse|pipew"
edge    2358  0.0  0.0 100520  9900 tty1     S<l  16:51   0:00 /usr/bin/pipewire
edge    2394  0.0  0.1 201644 27048 tty1     S<l  16:51   0:00 /usr/bin/pipewire-media-session
edge    2395  0.0  0.0  80164  4980 tty1     S<l  16:51   0:00 /usr/bin/pipewire -c pipewire-pulse.conf
edge   17793  0.0  0.0   8112   700 pts/14   S+   17:03   0:00 grep --colour=auto -iE pulse|pipew
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum