pkgname=libpulse
pkgbase=pulseaudio
pkgver=17.0
pkgdesc="Libraries for PulseAudio clients"
homepage="https://www.freedesktop.org/wiki/Software/PulseAudio/"
licenses=("LGPL-2.1+")
_patches=("pulseaudio-17.0-backport-pr807.patch")
_patch_sums=("a03b46640c76ae2029374ee18cbb485a7d7866412b974c34f65a760525fc2346b39186fd0ac8ed905754547a775d7419844d07304aa36de73c29f9f4fd11acb7")
sources=("${pkgbase}-${pkgver}.tar.xz"
  ${_patches[@]}
)
urls=("https://freedesktop.org/software/pulseaudio/releases/${sources[0]}"
  ${_patches[@]}
)
sha512sums=("be0aec46204d9c9188a796fbe41b4cf6f0f5e6b16fa08ce359b8f0f51253f0ade364b89448bbf5faa2af7e59deb6c72194734c3233944250dcfd4f31968a5e97"
  ${_patch_sums[@]}
)

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  for _patch in ${_patches[@]}; do
    patch -p1 -i ${filedir}/${_patch}
  done
  sed -i -e 's:; autospawn = yes:autospawn = no:g' src/pulse/client.conf.in
}

src_build() {
  local meson_args=(
    --prefix=/usr
    --buildtype=release
    --wrap-mode=nodownload
    -D python.bytecompile=1
    --localstatedir=/usr
    -D daemon=false
    -D client=true
    -D doxygen=false
    -D gcov=false
    -D tests=false
    -D database=simple
    -D stream-restore-clear-old-devices=true
    -D running-from-build-tree=false
    -D modlibexecdir="/usr/lib/pulseaudio/modules"
    -D alsa=disabled
    -D asyncns=disabled
    -D avahi=disabled
    -D bluez5=disabled
    -D bluez5-gstreamer=disabled
    -D bluez5-native-headset=false
    -D bluez5-ofono-headset=false
    -D dbus=enabled
    -D elogind=disabled
    -D fftw=disabled
    -D glib=enabled
    -D gsettings=disabled
    -D gstreamer=disabled
    -D gtk=disabled
    -D hal-compat=false
    -D ipv6=true
    -D jack=disabled
    -D lirc=disabled
    -D openssl=disabled
    -D orc=disabled
    -D oss-output=disabled
    -D samplerate=disabled # Matches upstream
    -D soxr=disabled
    -D speex=disabled
    -D systemd=enabled
    -D tcpwrap=disabled
    -D udev=disabled
    -D valgrind=disabled
    -D x11=disabled
    -D adrian-aec=false
    -D webrtc-aec=disabled
  )
  meson setup build "${meson_args[@]}"
  meson compile -C build
}

src_install() {
  meson install -C build --destdir "$pkgdir"

  ln -svf pactl "${pkgdir}/usr/share/bash-completion/completions/pulseaudio"
  ln -svf pactl "${pkgdir}/usr/share/bash-completion/completions/pacmd"
  ln -svf pactl "${pkgdir}/usr/share/bash-completion/completions/pasuspender"
}

# vim:ft=sh syn=sh et sw=2:
