# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgname=webrtc-audio-processing
pkgver=2.1
pkgrel=5.1
pkgdesc="AudioProcessing library based on Google's implementation of WebRTC"
url="https://freedesktop.org/software/pulseaudio/webrtc-audio-processing/"
arch=(x86_64 aarch64)
license=(BSD-3-Clause)
depends=(
  abseil-cpp
  gcc-libs
  glibc
)
makedepends=(
  git
  meson
)
provides=(
  libwebrtc-audio-processing-2.so
)
source=(
  "git+https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing.git?signed#tag=v$pkgver"
  0001-Fix-build-with-abseil-cpp-202508.patch
)
b2sums=('835d68d138f6081eee657d7d454c0c3fbb6389638da5d011020a25a20002ec6e1bc8a3fd756bdfd24c0060323cd52e99e9fece4f069852139aa2d2f274f93689'
        'ca8d456511818d36d32b17ba0e41f6f3738b8a8cee109caae67505e9f3df94f2159f9ced893baccfe284529e2ecbe05afd739a30924bdcccbaf7692942e72477')
validpgpkeys=(
  52DFA7B8BAC74687C8A88EF48165E3D1987E2132 # Arun Raghavan <arun@asymptotic.io>
)

prepare() {
  cd webrtc-audio-processing

  # Fix compilation with gcc 15
  git cherry-pick -n e9c78dc4712fa6362b0c839ad57b6b46dce1ba83

  # Fix compilation with abseil-cpp 20250814.0
  git apply -3 ../0001-Fix-build-with-abseil-cpp-202508.patch
}

build() {
  local meson_options=(
    # must match abseil
    -D cpp_std=c++17

    -D neon=disabled
  )

  arch-meson webrtc-audio-processing build "${meson_options[@]}"
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

package() {
  meson install -C build --destdir "$pkgdir"
  install -Dm644 webrtc-audio-processing/COPYING \
    -t "$pkgdir/usr/share/licenses/$pkgname"
}

# vim:set sw=2 sts=-1 et:
