Working on pipewire integration.

This commit is contained in:
fewtarius 2023-08-06 23:10:30 +00:00
parent 2b16257b81
commit 4e4864342d
No known key found for this signature in database
GPG key ID: F4AE55305D1B8C1A
19 changed files with 234 additions and 229 deletions

View file

@ -38,7 +38,10 @@
GLIBC_LOCALES="yes" GLIBC_LOCALES="yes"
# build and install PulseAudio support (yes / no) # build and install PulseAudio support (yes / no)
PULSEAUDIO_SUPPORT="yes" PULSEAUDIO_SUPPORT="no"
# build and install pipewire support (yes / no)
PIPEWIRE_SUPPORT="yes"
# Define package sets to clean based on the type of build being executed. # Define package sets to clean based on the type of build being executed.
# This should be updated to be more dynamic in the future. # This should be updated to be more dynamic in the future.

View file

@ -1,42 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
tocon "Configuring audio..."
# Revert to stored setting when bluetooth was still selected at last shutdown.
# This is a workaround - headsets that auto-connect at boot tend to be
# unreliable, so for now it's better to force a manual reconnect.
LAST_AUDIO_DEVICE=$(set-audio get)
if [[ "${LAST_AUDIO_DEVICE}" =~ ^Device.* ]]
then
set-audio restore
fi
if [ ! -e "/storage/.config/asound.conf" ]
then
set-audio set "DEFAULT (SYSTEM PROVIDED)"
fi
if [ ! -e "/storage/.config/asound.state" ] && [ -e /usr/config/asound.state ]
then
cp /usr/config/asound.state /storage/.config
fi
# Initialize sound using the state if available.
if [ -e "/storage/.config/asound.state" ]
then
alsactl restore -f /storage/.config/asound.state
fi
PREAMP=$(get_setting "audio.preamp" 2>/dev/null)
if [ -z "${PREAMP}" ]
then
PREAMP=50
set_setting audio.preamp ${PREAMP}
fi
amixer -M set Pre-Amp -- ${PREAMP}%
VOL=$(get_setting "audio.volume" 2>/dev/null)
amixer -M set "${DEVICE_AUDIO_MIXER}" ${VOL}%

View file

@ -0,0 +1,19 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="ldacBT"
PKG_VERSION="2.0.2.3"
PKG_SHA256="c02998718f9c4620437d7594b4d121b3ab4c5cfeba8d41fa31dd5c71db09edca"
PKG_LICENSE="Apache"
PKG_SITE="https://github.com/EHfive/ldacBT"
PKG_URL="https://github.com/EHfive/ldacBT/archive/v${PKG_VERSION}.tar.gz"
PKG_DEPENDS_TARGET="toolchain"
PKG_DEPENDS_UNPACK="libldac"
PKG_LONGDESC="LDAC Bluetooth encoder library (build tools)"
PKG_CMAKE_OPTS_TARGET="-DLDAC_SOFT_FLOAT=OFF"
post_unpack() {
rm -rf ${PKG_BUILD}/libldac
ln -sf $(get_build_dir libldac) ${PKG_BUILD}/libldac
}

View file

@ -0,0 +1,40 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="libfreeaptx"
PKG_VERSION="0.1.1"
PKG_SHA256="7acf514446cae59585d9bc21e4f98f4a3856f4741c3a7a09d06e8ac5bf2f7315"
PKG_LICENSE="LGPL"
PKG_SITE="https://github.com/iamthehorker/libfreeaptx"
PKG_URL="https://github.com/iamthehorker/libfreeaptx/archive/${PKG_VERSION}.tar.gz"
PKG_DEPENDS_TARGET="toolchain"
PKG_LONGDESC="Open Source aptX codec library"
PKG_TOOLCHAIN="manual"
PKG_BUILD_FLAGS="+pic"
make_target() {
${CC} ${CFLAGS} -I${PKG_BUILD} -c -o ${PKG_NAME##*lib}.o ${PKG_NAME##*lib}.c
${AR} -rcs ${PKG_NAME}.a ${PKG_NAME##*lib}.o
}
makeinstall_target() {
mkdir -p ${SYSROOT_PREFIX}/usr/lib
cp -a ${PKG_NAME}.a ${SYSROOT_PREFIX}/usr/lib/
mkdir -p ${SYSROOT_PREFIX}/usr/include
cp -a ${PKG_NAME##*lib}.h ${SYSROOT_PREFIX}/usr/include/
mkdir -p ${SYSROOT_PREFIX}/usr/lib/pkgconfig
cat > ${SYSROOT_PREFIX}/usr/lib/pkgconfig/${PKG_NAME}.pc << EOF
prefix=/usr
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include
Name: ${PKG_NAME}
Description: Open Source aptX codec library
Version: ${PKG_VERSION}
Libs: -Wl,-rpath=\${libdir} -L\${libdir} -l${PKG_NAME##*lib}
Cflags: -I\${includedir}
EOF
}

View file

@ -1,18 +1,11 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2022-present Marek Moeckel (wansti@discarded-ideas.org) # Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="libldac" PKG_NAME="libldac"
PKG_VERSION="af2dd23979453bcd1cad7c4086af5fb421a955c5" PKG_VERSION="82b6a1abee84787b8fa167efe20290073f60db2d"
PKG_LICENSE="Apache2" PKG_SHA256="d61edcd3bfc4b71123136895fe71e7ba974f4a91f16a158f0ec8d5eb1913c51a"
PKG_SITE="https://github.com/EHfive/ldacBT" PKG_LICENSE="Apache"
PKG_URL="${PKG_SITE}.git" PKG_SITE="https://android.googlesource.com/platform/external/libldac"
PKG_DEPENDS_TARGET="toolchain" PKG_URL="https://github.com/brucehw/libldac/archive/${PKG_VERSION}.tar.gz"
PKG_LONGDESC="LDAC bluetooth audio codec" PKG_LONGDESC="LDAC Bluetooth encoder library"
PKG_TOOLCHAIN="cmake-make" PKG_TOOLCHAIN="manual"
GET_HANDLER_SUPPORT="git"
post_makeinstall_target() {
cp -P -r ${INSTALL}/usr/lib/* ${SYSROOT_PREFIX}/usr/lib/
cp -P -r ${INSTALL}/usr/include/* ${SYSROOT_PREFIX}/usr/include/
rm -rf ${INSTALL}/usr/lib/pkgconfig
}

View file

@ -0,0 +1,99 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="pipewire"
PKG_VERSION="0.3.74"
PKG_SHA256="901857530bfdb65a0282562ceeead28682e9aba2aefb4bbee10c74dcc333c72a"
PKG_LICENSE="LGPL"
PKG_SITE="https://pipewire.org"
PKG_URL="https://github.com/PipeWire/pipewire/archive/${PKG_VERSION}.tar.gz"
PKG_DEPENDS_TARGET="toolchain libpthread-stubs dbus ncurses alsa-lib systemd libsndfile libusb"
PKG_LONGDESC="PipeWire is a server and user space API to deal with multimedia pipeline"
if [ "${BLUETOOTH_SUPPORT}" = "yes" ]; then
PKG_DEPENDS_TARGET+=" bluez sbc ldacBT libfreeaptx"
PKG_PIPEWIRE_BLUETOOTH="-Dbluez5=enabled \
-Dbluez5-backend-hsp-native=disabled \
-Dbluez5-backend-hfp-native=disabled \
-Dbluez5-backend-ofono=disabled \
-Dbluez5-backend-hsphfpd=disabled \
-Dbluez5-codec-aptx=enabled \
-Dbluez5-codec-ldac=enabled \
-Dbluez5-codec-aac=disabled"
else
PKG_PIPEWIRE_BLUETOOTH="-Dbluez5=disabled"
fi
if [ "${VULKAN_SUPPORT}" = "yes" ]; then
PKG_PIPEWIRE_VULKAN+="-Dvulkan=enabled \
-Dx11=disabled \
-Dx11-xfixes=disabled"
fi
PKG_MESON_OPTS_TARGET="-Ddocs=disabled \
-Dexamples=disabled \
-Dman=disabled \
-Dtests=disabled \
-Dinstalled_tests=disabled \
-Dgstreamer=disabled \
-Dgstreamer-device-provider=disabled \
-Dsystemd=enabled \
-Dsystemd-system-service=enabled \
-Dsystemd-user-service=disabled \
-Dpipewire-alsa=enabled \
-Dpipewire-jack=disabled \
-Dpipewire-v4l2=disabled \
-Djack-devel=false
-Dspa-plugins=enabled \
-Dalsa=enabled \
-Daudiomixer=enabled \
-Daudioconvert=enabled \
${PKG_PIPEWIRE_BLUETOOTH} \
-Dcontrol=enabled \
-Daudiotestsrc=disabled \
-Dffmpeg=disabled \
-Djack=disabled \
-Dsupport=enabled \
-Devl=disabled \
-Dtest=disabled \
-Dv4l2=disabled \
-Ddbus=enabled \
-Dlibcamera=disabled \
-Dvideoconvert=disabled \
-Dvideotestsrc=disabled \
-Dvolume=enabled \
${PKG_PIPEWIRE_VULKAN} \
-Dpw-cat=enabled \
-Dudev=enabled \
-Dudevrulesdir=/usr/lib/udev/rules.d \
-Dsdl2=disabled \
-Dsndfile=enabled \
-Dlibpulse=enabled \
-Droc=disabled \
-Davahi=disabled \
-Decho-cancel-webrtc=disabled \
-Dlibusb=enabled \
-Dsession-managers=[] \
-Draop=disabled \
-Dlv2=disabled \
-Dlibcanberra=disabled \
-Dlegacy-rtkit=false"
pre_configure_target() {
export TARGET_LDFLAGS="${TARGET_LDFLAGS} -lncursesw -ltinfow"
}
post_makeinstall_target() {
# connect to the system bus
sed '/^\[Service\]/a Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket' -i ${INSTALL}/usr/lib/systemd/system/pipewire.service
}
post_install() {
add_user pipewire x 982 980 "pipewire-daemon" "/var/run/pipewire" "/bin/sh"
add_group pipewire 980
# note that the pipewire user is added to the audio and video groups in systemd/package.mk
# todo: maybe there is a better way to add users to groups in the future?
enable_service pipewire.socket
enable_service pipewire.service
}

View file

@ -0,0 +1,48 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2022-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="wireplumber"
PKG_VERSION="0.4.14"
PKG_SHA256="b160424ce7c3eeeccba388726f6a448f53501d25085e5fa1bf6c690c1bcd85ea"
PKG_LICENSE="MIT"
PKG_SITE="https://gitlab.freedesktop.org/pipewire/wireplumber"
PKG_URL="https://gitlab.freedesktop.org/pipewire/wireplumber/-/archive/${PKG_VERSION}/${PKG_NAME}-${PKG_VERSION}.tar.gz"
PKG_DEPENDS_TARGET="pipewire glib lua54 glib:host"
PKG_LONGDESC="Session / policy manager implementation for PipeWire"
PKG_MESON_OPTS_TARGET="-Dintrospection=disabled \
-Ddoc=disabled \
-Dsystem-lua=true \
-Delogind=disabled \
-Dsystemd=enabled \
-Dsystemd-system-service=true \
-Dsystemd-user-service=false \
-Dsystemd-system-unit-dir=/usr/lib/systemd/system \
-Dtests=false"
post_makeinstall_target() {
# connect to the system bus
sed '/^\[Service\]/a Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket' -i ${INSTALL}/usr/lib/systemd/system/wireplumber.service
# ref https://gitlab.freedesktop.org/pipewire/wireplumber/-/commit/0da29f38181e391160fa8702623050b8544ec775
cat > ${INSTALL}/usr/share/wireplumber/main.lua.d/89-disable-session-dbus-dependent-features.lua << EOF
alsa_monitor.properties["alsa.reserve"] = false
default_access.properties["enable-flatpak-portal"] = false
EOF
cat > ${INSTALL}/usr/share/wireplumber/main.lua.d/89-disable-v4l2.lua << EOF
v4l2_monitor.enabled = false
EOF
cat > ${INSTALL}/usr/share/wireplumber/bluetooth.lua.d/89-disable-session-dbus-dependent-features.lua << EOF
bluez_monitor.properties["with-logind"] = false
EOF
cat > ${INSTALL}/usr/share/wireplumber/bluetooth.lua.d/89-disable-bluez-hfphsp-backend.lua << EOF
bluez_monitor.properties["bluez5.hfphsp-backend"] = "none"
EOF
}
post_install() {
enable_service wireplumber.service
}

View file

@ -1,15 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
MYDEVICE=$(get_setting system.audiodevice)
if [ -z "${MYDEVICE}" ] || \
[ ! -e "/storage/.config/asound.conf" ]
then
### Set the audio device.
set-audio set "ALC269VB (1:0)"
set-audio esset "Master"
fi

View file

@ -1,13 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
MYDEVICE=$(get_setting system.audiodevice)
if [ -z "${MYDEVICE}" ] || \
[ ! -e "/storage/.config/asound.conf" ]
then
### Set the audio device
set-audio set "HDMI (0:3)"
fi

View file

@ -1,25 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
MYDEVICE=$(get_setting system.audiodevice)
if [ -z "${MYDEVICE}" ] || \
[ ! -e "/storage/.config/asound.conf" ]
then
### Set the audio device.
set-audio set "ALC269VB (1:0)"
set-audio esset "Master"
fi
### Only enable on 6800U Plus devices.
SUBSYSTEM=$(awk '/Subsystem Id:/ {print $3}' /proc/asound/card1/codec#0)
if [ "${SUBSYSTEM}" = "0x02f3f000" ]
then
### Disables speaker output when headphones are connected.
alsactl restore -f /storage/.config/asound.state
/usr/bin/amixer -c 1 sset "Auto-Mute Mode" Enabled
alsactl store -f /storage/.config/asound.state
fi

View file

@ -1,20 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
MYDEVICE=$(get_setting system.audiodevice)
if [ -z "${MYDEVICE}" ] || \
[ ! -e "/storage/.config/asound.conf" ]
then
### Set the audio device.
set-audio set "ALC269VB (1:0)"
set-audio esset "Master"
fi
### Disables speaker output when headphones are connected.
alsactl restore -f /storage/.config/asound.state
/usr/bin/amixer -c 1 sset "Auto-Mute Mode" Enabled
alsactl store -f /storage/.config/asound.state

View file

@ -1,15 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
MYDEVICE=$(get_setting system.audiodevice)
if [ -z "${MYDEVICE}" ] || \
[ ! -e "/storage/.config/asound.conf" ]
then
### Set the audio device.
set-audio set "ALC269VB (1:0)"
set-audio esset "Master"
fi

View file

@ -1,20 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
MYDEVICE=$(get_setting system.audiodevice)
if [ -z "${MYDEVICE}" ] || \
[ ! -e "/storage/.config/asound.conf" ]
then
### Set the audio device.
set-audio set "SN6140 (1:0)"
set-audio esset "Internal"
fi
### Disables speaker output when headphones are connected.
alsactl restore -f /storage/.config/asound.state
/usr/bin/amixer -c 1 sset "Auto-Mute Mode" Enabled
alsactl store -f /storage/.config/asound.state

View file

@ -1,43 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
### Set a custom device so we don't clobber it.
set-audio set "CUSTOM (UNMANAGED)"
set-audio esset "PCM"
### Temporary workaround until we can fix it correctly
cat <<EOF >/storage/.config/asound.conf
ctl.!default {
type hw
card 1
}
pcm.!default {
type plug
slave.pcm "softvol"
}
pcm.softvol {
type softvol
slave.pcm "dmixer"
control {
name "PCM"
card 1
}
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:1,1"
period_time 0
period_size 4096
buffer_size 131072
rate 176400
}
}
EOF

View file

@ -111,15 +111,16 @@ function set_setting() {
} }
function set_audio() { function set_audio() {
case ${1} in echo
"default") # case ${1} in
AUDIO="alsa" # "default")
;; # AUDIO="alsa"
*) # ;;
AUDIO=${1} # *)
;; # AUDIO=${1}
esac # ;;
/usr/bin/rr_audio.sh ${AUDIO} # esac
# /usr/bin/rr_audio.sh ${AUDIO}
} }
function battery_percent() { function battery_percent() {

View file

@ -28,10 +28,6 @@ volumectl() {
fi fi
} }
alsastate() {
alsactl ${1} -f /storage/.config/asound.state >/dev/null 2>&1
}
powerstate() { powerstate() {
if [ "$(get_setting system.powersave)" = 1 ] if [ "$(get_setting system.powersave)" = 1 ]
then then
@ -103,7 +99,6 @@ quirks() {
case $1 in case $1 in
pre) pre)
alsastate store
headphones stop headphones stop
volumectl stop volumectl stop
bluetooth stop bluetooth stop
@ -116,7 +111,6 @@ case $1 in
;; ;;
post) post)
ledcontrol ledcontrol
alsastate restore
modules start modules start
powerstate start powerstate start
headphones start headphones start

View file

@ -267,7 +267,7 @@ post_install() {
add_group systemd-network 193 add_group systemd-network 193
add_user systemd-network x 193 193 "systemd-network" "/" "/bin/sh" add_user systemd-network x 193 193 "systemd-network" "/" "/bin/sh"
add_group audio 63 add_group audio 63 pipewire
add_group cdrom 11 add_group cdrom 11
add_group dialout 18 add_group dialout 18
add_group disk 6 add_group disk 6
@ -278,7 +278,7 @@ post_install() {
add_group render 12 add_group render 12
add_group tape 33 add_group tape 33
add_group tty 5 add_group tty 5
add_group video 39 add_group video 39 pipewire
add_group utmp 22 add_group utmp 22
add_group input 199 add_group input 199

View file

@ -48,6 +48,7 @@ else
# Sound support # Sound support
[ "${ALSA_SUPPORT}" = "yes" ] && PKG_DEPENDS_TARGET+=" alsa" [ "${ALSA_SUPPORT}" = "yes" ] && PKG_DEPENDS_TARGET+=" alsa"
[ "${PIPEWIRE_SUPPORT}" = "yes" ] && PKG_DEPENDS_TARGET+=" pipewire wireplumber"
fi fi
[ "${DISPLAYSERVER}" = "wl" ] && PKG_DEPENDS_TARGET+=" weston" [ "${DISPLAYSERVER}" = "wl" ] && PKG_DEPENDS_TARGET+=" weston"

View file

@ -6,7 +6,7 @@ PKG_VERSION="10.0.3"
PKG_LICENSE="MIT" PKG_LICENSE="MIT"
PKG_SITE="https://wayland.freedesktop.org/" PKG_SITE="https://wayland.freedesktop.org/"
PKG_URL="https://gitlab.freedesktop.org/wayland/weston/-/archive/${PKG_VERSION}/${PKG_NAME}-${PKG_VERSION}.tar.gz" PKG_URL="https://gitlab.freedesktop.org/wayland/weston/-/archive/${PKG_VERSION}/${PKG_NAME}-${PKG_VERSION}.tar.gz"
PKG_DEPENDS_TARGET="toolchain wayland wayland-protocols libdrm libxkbcommon libinput cairo pango libjpeg-turbo dbus seatd glu ${OPENGL} libX11 xorg-server libXcursor xkbcomp setxkbmap cairo xterm splash" PKG_DEPENDS_TARGET="toolchain wayland wayland-protocols libdrm libxkbcommon libinput pipewire cairo pango libjpeg-turbo dbus seatd glu ${OPENGL} libX11 xorg-server libXcursor xkbcomp setxkbmap cairo xterm splash"
PKG_LONGDESC="Reference implementation of a Wayland compositor" PKG_LONGDESC="Reference implementation of a Wayland compositor"
PKG_MESON_OPTS_TARGET="-Dbackend-drm=true \ PKG_MESON_OPTS_TARGET="-Dbackend-drm=true \
@ -23,7 +23,7 @@ PKG_MESON_OPTS_TARGET="-Dbackend-drm=true \
-Dxwayland=true \ -Dxwayland=true \
-Dsystemd=true \ -Dsystemd=true \
-Dremoting=false \ -Dremoting=false \
-Dpipewire=false \ -Dpipewire=true \
-Dshell-desktop=true \ -Dshell-desktop=true \
-Dshell-fullscreen=true \ -Dshell-fullscreen=true \
-Dshell-ivi=false \ -Dshell-ivi=false \