Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] webrtc-audio-processing: update to 1.3; revbump dependents
@ 2024-02-23 23:04 cinerea0
  2024-02-23 23:11 ` cinerea0
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: cinerea0 @ 2024-02-23 23:04 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 527 bytes --]

There is a new pull request by cinerea0 against master on the void-packages repository

https://github.com/cinerea0/void-packages webrtc
https://github.com/void-linux/void-packages/pull/48902

webrtc-audio-processing: update to 1.3; revbump dependents
#### Testing the changes
- I tested the changes in this PR: **YES**

---

@ahesford Are there any potential negative consequences of forcing abseil to use C++17 you can think of?

A patch file from https://github.com/void-linux/void-packages/pull/48902.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-webrtc-48902.patch --]
[-- Type: text/x-diff, Size: 42838 bytes --]

From 58b616a3bed2606ca1e79e595b96d9e0083ee7f5 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Fri, 23 Feb 2024 17:06:34 -0500
Subject: [PATCH 1/6] abseil-cpp: use C++17

---
 srcpkgs/abseil-cpp/template | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/abseil-cpp/template b/srcpkgs/abseil-cpp/template
index 7909b5e19e0aa..b19c444a1fe4f 100644
--- a/srcpkgs/abseil-cpp/template
+++ b/srcpkgs/abseil-cpp/template
@@ -1,9 +1,10 @@
 # Template file for 'abseil-cpp'
 pkgname=abseil-cpp
 version=20240116.1
-revision=1
+revision=2
 build_style=cmake
-configure_args="-DBUILD_SHARED_LIBS=ON -DABSL_PROPAGATE_CXX_STD=ON"
+configure_args="-DBUILD_SHARED_LIBS=ON -DABSL_PROPAGATE_CXX_STD=ON
+ -DCMAKE_CXX_STANDARD=17"
 hostmakedepends="pkg-config"
 short_desc="Abseil common libraries"
 maintainer="Andrew J. Hesford <ajh@sideband.org>"

From a0fbd923faeae3cb607095b56edcda306426b2c3 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Fri, 23 Feb 2024 17:07:12 -0500
Subject: [PATCH 2/6] webrtc-audio-processing: update to 1.3

---
 common/shlibs                                 |   3 +-
 ...yte-order-and-pointer-size-detection.patch |  24 ++--
 .../patches/i686-no-sse.patch                 |  15 +++
 .../patches/mips.patch                        | 113 ------------------
 .../patches/musl.patch                        |  20 ----
 srcpkgs/webrtc-audio-processing/template      |  31 ++---
 6 files changed, 42 insertions(+), 164 deletions(-)
 create mode 100644 srcpkgs/webrtc-audio-processing/patches/i686-no-sse.patch
 delete mode 100644 srcpkgs/webrtc-audio-processing/patches/mips.patch
 delete mode 100644 srcpkgs/webrtc-audio-processing/patches/musl.patch

diff --git a/common/shlibs b/common/shlibs
index cde1106f7dbef..b6003ee4fbcc4 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1056,7 +1056,8 @@ libiptcdata.so.0 libiptcdata-1.0.4_1
 libutempter.so.0 libutempter-1.1.5_1
 libxatracker.so.2 libxatracker-10.0.0_2
 libtumbler-1.so.0 tumbler-4.9.2_1
-libwebrtc_audio_processing.so.1 webrtc-audio-processing-0.3_1
+libwebrtc-audio-coding-1.so.3 webrtc-audio-processing-1.3_1
+libwebrtc-audio-processing-1.so.3 webrtc-audio-processing-1.3_1
 libcupsmime.so.1 libcups-1.5.3_1
 libcupsppdc.so.1 libcups-1.5.3_1
 libcupscgi.so.1 libcups-1.5.3_1
diff --git a/srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.patch b/srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.patch
index 1338784e69ef8..28f1dbdcd8684 100644
--- a/srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.patch
+++ b/srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.patch
@@ -1,20 +1,20 @@
-From: Than <than@redhat.com>
-Date: Wed, 8 Jun 2016 19:10:08 -0400
-Subject: Add generic byte order and pointer size detection
+Taken from https://gitweb.gentoo.org/repo/gentoo.git/tree/media-libs/webrtc-audio-processing/files/webrtc-audio-processing-1.3-Add-generic-byte-order-and-pointer-size-detection.patch?id=29cd0e622b574df6adff5704ab4e220709619767
+https://bugs.gentoo.org/917493
+https://sources.debian.org/src/webrtc-audio-processing/1.0-0.2/debian/patches/Add-generic-byte-order-and-pointer-size-detection.patch/
 
+Description: Add generic byte order and pointer size detection
+Author: Than <than@redhat.com>
+Origin: https://bugs.freedesktop.org/show_bug.cgi?id=95738#c4
+Last-Update: 2022-02-01
 ---
- webrtc/typedefs.h | 14 +++++++++++++-
- 1 file changed, 13 insertions(+), 1 deletion(-)
-
-diff --git a/webrtc/typedefs.h b/webrtc/typedefs.h
-index d875490..dc074f1 100644
---- a/webrtc/typedefs.h
-+++ b/webrtc/typedefs.h
-@@ -48,7 +48,19 @@
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/webrtc/rtc_base/system/arch.h
++++ b/webrtc/rtc_base/system/arch.h
+@@ -58,7 +58,19 @@
  #define WEBRTC_ARCH_32_BITS
  #define WEBRTC_ARCH_LITTLE_ENDIAN
  #else
--#error Please add support for your architecture in typedefs.h
+-#error Please add support for your architecture in rtc_base/system/arch.h
 +/* instead of failing, use typical unix defines... */
 +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 +#define WEBRTC_ARCH_LITTLE_ENDIAN
diff --git a/srcpkgs/webrtc-audio-processing/patches/i686-no-sse.patch b/srcpkgs/webrtc-audio-processing/patches/i686-no-sse.patch
new file mode 100644
index 0000000000000..de145af208312
--- /dev/null
+++ b/srcpkgs/webrtc-audio-processing/patches/i686-no-sse.patch
@@ -0,0 +1,15 @@
+Taken from https://gitweb.gentoo.org/repo/gentoo.git/tree/media-libs/webrtc-audio-processing/files/webrtc-audio-processing-1.3-x86-no-sse.patch?id=29cd0e622b574df6adff5704ab4e220709619767
+https://bugs.gentoo.org/921140
+https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/issues/5
+--- a/webrtc/rtc_base/system/arch.h
++++ b/webrtc/rtc_base/system/arch.h
+@@ -34,7 +34,7 @@
+ #else
+ #define WEBRTC_ARCH_32_BITS
+ #endif
+-#elif defined(_M_IX86) || defined(__i386__)
++#elif defined(__SSE__) && (defined(_M_IX86) || defined(__i386__))
+ #define WEBRTC_ARCH_X86_FAMILY
+ #define WEBRTC_ARCH_X86
+ #define WEBRTC_ARCH_32_BITS
+
diff --git a/srcpkgs/webrtc-audio-processing/patches/mips.patch b/srcpkgs/webrtc-audio-processing/patches/mips.patch
deleted file mode 100644
index c99aaf3922082..0000000000000
--- a/srcpkgs/webrtc-audio-processing/patches/mips.patch
+++ /dev/null
@@ -1,113 +0,0 @@
---- webrtc-audio-processing-0.3_3/configure.ac	2017-11-22 20:26:54.207009881 +0100
-+++ webrtc-audio-processing-0.3_3/configure.ac	2017-11-22 20:37:57.472996521 +0100
-@@ -90,10 +90,14 @@
- 	[HAVE_NEON=1; ARCH_CFLAGS="${ARCH_CFLAGS} -DWEBRTC_HAS_NEON -DWEBRTC_ARCH_ARM64"])
- AC_CHECK_DECLS([__i386__], [HAVE_X86=1])
- AC_CHECK_DECLS([__x86_64__], [HAVE_X86=1])
-+AC_CHECK_DECLS([__MIPSEB__], [HAVE_MIPSEB=1])
-+AC_CHECK_DECLS([__MIPSEL__], [HAVE_MIPSEL=1])
- 
- AM_CONDITIONAL(HAVE_X86, [test "x${HAVE_X86}" = "x1"])
- AM_CONDITIONAL(HAVE_ARM, [test "x${HAVE_ARM}" = "x1"])
- AM_CONDITIONAL(HAVE_ARMV7, [test "x${HAVE_ARMV7}" = "x1"])
-+AM_CONDITIONAL(HAVE_MIPSEB, [test "x${HAVE_MIPSEB}" = "x1"])
-+AM_CONDITIONAL(HAVE_MIPSEL, [test "x${HAVE_MIPSEL}" = "x1"])
- 
- # Borrowed from pulseaudio's configure.ac
- AC_ARG_ENABLE([neon],
---- webrtc-audio-processing-0.3_3/webrtc/typedefs.h	2015-10-15 12:48:25.000000000 +0200
-+++ webrtc-audio-processing-0.3_3/webrtc/typedefs.h	2017-11-22 20:39:20.800994843 +0100
-@@ -47,6 +47,10 @@
- #elif defined(__pnacl__)
- #define WEBRTC_ARCH_32_BITS
- #define WEBRTC_ARCH_LITTLE_ENDIAN
-+#elif defined(__MIPSEL__)
-+#define WEBRTC_ARCH_LITTLE_ENDIAN
-+#elif defined(__MIPSEB__)
-+#define WEBRTC_ARCH_BIG_ENDIAN
- #else
- #error Please add support for your architecture in typedefs.h
- #endif
---- webrtc-audio-processing-0.3/webrtc/common_audio/wav_file.cc	2015-11-19 13:41:44.000000000 +0100
-+++ webrtc-audio-processing-0.3/webrtc/common_audio/wav_file.cc	2017-11-22 21:01:46.554967737 +0100
-@@ -64,9 +64,6 @@
- }
- 
- size_t WavReader::ReadSamples(size_t num_samples, int16_t* samples) {
--#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
--#error "Need to convert samples to big-endian when reading from WAV file"
--#endif
-   // There could be metadata after the audio; ensure we don't read it.
-   num_samples = std::min(rtc::checked_cast<uint32_t>(num_samples),
-                          num_samples_remaining_);
-@@ -76,6 +73,12 @@
-   RTC_CHECK(read == num_samples || feof(file_handle_));
-   RTC_CHECK_LE(read, num_samples_remaining_);
-   num_samples_remaining_ -= rtc::checked_cast<uint32_t>(read);
-+#ifdef WEBRTC_ARCH_BIG_ENDIAN
-+  for (size_t i = 0; i < read; i++) {
-+    uint16_t s = static_cast<uint16_t>(samples[i]);
-+    samples[i] = static_cast<int16_t>((s >> 8) | (s << 8));
-+  }
-+#endif
-   return read;
- }
- 
-@@ -119,11 +122,20 @@
- }
- 
- void WavWriter::WriteSamples(const int16_t* samples, size_t num_samples) {
--#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
--#error "Need to convert samples to little-endian when writing to WAV file"
--#endif
-+#ifdef WEBRTC_ARCH_LITTLE_ENDIAN
-   const size_t written =
-       fwrite(samples, sizeof(*samples), num_samples, file_handle_);
-+#else
-+  size_t written = 0;
-+  for (size_t i = 0; i < num_samples; i++) {
-+    uint16_t s = static_cast<uint16_t>(samples[i]);
-+    s = static_cast<int16_t>((s<<8) | (s>>8));
-+    size_t size = fwrite(&s, sizeof(s), 1, file_handle_);
-+    if (size < 1)
-+      break;
-+    written += size;
-+  }
-+#endif
-   RTC_CHECK_EQ(num_samples, written);
-   num_samples_ += static_cast<uint32_t>(written);
-   RTC_CHECK(written <= std::numeric_limits<uint32_t>::max() ||
---- webrtc-audio-processing-0.3/webrtc/common_audio/wav_header.cc	2015-10-15 12:48:44.000000000 +0200
-+++ webrtc-audio-processing-0.3/webrtc/common_audio/wav_header.cc	2017-11-22 21:11:36.291955859 +0100
-@@ -129,7 +129,30 @@
-   return std::string(reinterpret_cast<char*>(&x), 4);
- }
- #else
--#error "Write be-to-le conversion functions"
-+static inline void WriteLE16(uint16_t* f, uint16_t x) { *f = (x >> 8) | (x << 8); }
-+static inline void WriteLE32(uint32_t* f, uint32_t x) {
-+  *f = ((x & 0xff000000) >> 24) |
-+       ((x & 0x00ff0000) >>  8) |
-+       ((x & 0x0000ff00) <<  8) |
-+       ((x & 0x000000ff) << 24);
-+}
-+static inline void WriteFourCC(uint32_t* f, char a, char b, char c, char d) {
-+  *f = (static_cast<uint32_t>(a) << 24)
-+      | (static_cast<uint32_t>(b) << 16)
-+      | (static_cast<uint32_t>(c) << 8)
-+      | static_cast<uint32_t>(d);
-+}
-+static inline uint16_t ReadLE16(uint16_t x) { return (x >> 8) | (x << 8); }
-+static inline uint32_t ReadLE32(uint32_t x) {
-+  return ((x << 24) & 0xff000000) |
-+         ((x <<  8) & 0x00ff0000) |
-+         ((x >>  8) & 0x0000ff00) |
-+         ((x >> 24) & 0x000000ff);
-+}
-+static inline std::string ReadFourCC(uint32_t x) {
-+  uint32_t s = ReadLE32(x);
-+  return std::string(reinterpret_cast<char*>(&s), 4);
-+}
- #endif
- 
- static inline uint32_t RiffChunkSize(uint32_t bytes_in_payload) {
diff --git a/srcpkgs/webrtc-audio-processing/patches/musl.patch b/srcpkgs/webrtc-audio-processing/patches/musl.patch
deleted file mode 100644
index adca79b6b7486..0000000000000
--- a/srcpkgs/webrtc-audio-processing/patches/musl.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/webrtc/base/checks.cc.orig	2016-06-25 07:47:34.099515548 +0200
-+++ b/webrtc/base/checks.cc	2016-06-25 07:48:28.554122463 +0200
-@@ -16,7 +16,7 @@
- #include <cstdio>
- #include <cstdlib>
- 
--#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
-+#if defined(__GLIBC__) && defined(__GLIBCXX__)
- #include <cxxabi.h>
- #include <execinfo.h>
- #endif
-@@ -55,7 +55,7 @@ void PrintError(const char* format, ...)
- // to get usable symbols on Linux. This is copied from V8. Chromium has a more
- // advanced stace trace system; also more difficult to copy.
- void DumpBacktrace() {
--#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
-+#if defined(__GLIBC__) && defined(__GLIBCXX__)
-   void* trace[100];
-   int size = backtrace(trace, sizeof(trace) / sizeof(*trace));
-   char** symbols = backtrace_symbols(trace, size);
diff --git a/srcpkgs/webrtc-audio-processing/template b/srcpkgs/webrtc-audio-processing/template
index 30a420b28f575..e5277d17e0b9e 100644
--- a/srcpkgs/webrtc-audio-processing/template
+++ b/srcpkgs/webrtc-audio-processing/template
@@ -1,38 +1,33 @@
 # Template file for 'webrtc-audio-processing'
 pkgname=webrtc-audio-processing
-version=0.3.1
+version=1.3
 revision=1
-build_style=gnu-configure
-hostmakedepends="automake libtool"
+build_style=meson
+hostmakedepends="pkg-config"
+makedepends="abseil-cpp-devel"
 short_desc="AudioProcessing library based on Google's implementation of WebRTC"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="BSD-3-Clause"
-homepage="http://freedesktop.org/software/pulseaudio/webrtc-audio-processing"
-distfiles="${homepage}/${pkgname}-${version}.tar.xz"
-checksum=a0fdd938fd85272d67e81572c5a4d9e200a0c104753cb3c209ded175ce3c5dbf
+homepage="https://freedesktop.org/software/pulseaudio/webrtc-audio-processing"
+distfiles="${FREEDESKTOP_SITE}/pulseaudio/webrtc-audio-processing/webrtc-audio-processing-${version}.tar.gz"
+checksum=95552fc17faa0202133707bbb3727e8c2cf64d4266fe31bfdb2298d769c1db75
 
-case "$XBPS_TARGET_MACHINE" in
-	# Disable neon for the arm* architectures
-	arm*) configure_args+=" --enable-neon=no" ;;
-esac
-
-pre_configure() {
-	# Remove failing statement PKG_CHECK_MODULE(GNUSTL, gnustl)
-	sed -i configure.ac -e'/if test "x$with_gnustl" != "xno"; then/,+2d'
-	autoreconf -fi
-}
+# Upstream issue: https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/issues/5
+if [ "$XBPS_MACHINE" = "i686" ]; then
+	CXXFLAGS="-DPFFFT_SIMD_DISABLE=1"
+	CFLAGS="-DPFFFT_SIMD_DISABLE=1"
+fi
 
 post_install() {
 	vlicense COPYING
 }
 
 webrtc-audio-processing-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision}"
+	depends="${sourcepkg}>=${version}_${revision} abseil-cpp-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig
-		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }

From 6e7f18da7c9ace711d50a99a7644f11059ab57cb Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Fri, 23 Feb 2024 17:10:02 -0500
Subject: [PATCH 3/6] pulseaudio: revbump for webrtc-audio-processing-1.3

---
 .../patches/webrtc-audio-processing-1.patch   | 676 ++++++++++++++++++
 srcpkgs/pulseaudio/template                   |   5 +-
 2 files changed, 679 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/pulseaudio/patches/webrtc-audio-processing-1.patch

diff --git a/srcpkgs/pulseaudio/patches/webrtc-audio-processing-1.patch b/srcpkgs/pulseaudio/patches/webrtc-audio-processing-1.patch
new file mode 100644
index 0000000000000..12816416f0494
--- /dev/null
+++ b/srcpkgs/pulseaudio/patches/webrtc-audio-processing-1.patch
@@ -0,0 +1,676 @@
+# This can be dropped with PulseAudio 17
+
+From b16b107171f24f791f79c20730cf6eb3ad469944 Mon Sep 17 00:00:00 2001
+From: Arun Raghavan <arun@asymptotic.io>
+Date: Tue, 20 Oct 2020 16:18:57 -0400
+Subject: [PATCH 1/3] echo-cancel-test: Drop references to internal message
+ queue
+
+We don't actually initialise or use it in the test, and this just causes
+a crash at the end.
+
+Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/395>
+---
+ src/modules/echo-cancel/module-echo-cancel.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
+index 3d63ea6084..ae1bf9d684 100644
+--- a/src/modules/echo-cancel/module-echo-cancel.c
++++ b/src/modules/echo-cancel/module-echo-cancel.c
+@@ -2370,8 +2370,6 @@ int main(int argc, char* argv[]) {
+     }
+ 
+     u.ec->done(u.ec);
+-    u.ec->msg->dead = true;
+-    pa_echo_canceller_msg_unref(u.ec->msg);
+ 
+ out:
+     if (u.captured_file)
+-- 
+GitLab
+
+
+From 22bbb5b3ba0d28d630b10944fe19d7f9eee3a00f Mon Sep 17 00:00:00 2001
+From: Eero Nurkkala <eero.nurkkala@offcode.fi>
+Date: Tue, 20 Oct 2020 16:20:23 -0400
+Subject: [PATCH 2/3] echo-cancel: add webrtc AEC3 support
+
+Drop a number of now unsupported features, and add new parameters for
+pre-/post-amplification.
+
+Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/395>
+---
+ src/modules/echo-cancel/webrtc.cc | 433 ++++++++----------------------
+ 1 file changed, 113 insertions(+), 320 deletions(-)
+
+diff --git a/src/modules/echo-cancel/webrtc.cc b/src/modules/echo-cancel/webrtc.cc
+index 56daab0fd0..ed4bb65a56 100644
+--- a/src/modules/echo-cancel/webrtc.cc
++++ b/src/modules/echo-cancel/webrtc.cc
+@@ -3,8 +3,8 @@
+ 
+     Copyright 2011 Collabora Ltd.
+               2015 Aldebaran SoftBank Group
+-
+-    Contributor: Arun Raghavan <mail@arunraghavan.net>
++              2020 Arun Raghavan <arun@asymptotic.io>
++              2020 Eero Nurkkala <eero.nurkkala@offcode.fi>
+ 
+     PulseAudio is free software; you can redistribute it and/or modify
+     it under the terms of the GNU Lesser General Public License as published
+@@ -34,80 +34,47 @@ PA_C_DECL_BEGIN
+ #include "echo-cancel.h"
+ PA_C_DECL_END
+ 
+-#include <webrtc/modules/audio_processing/include/audio_processing.h>
+-#include <webrtc/modules/interface/module_common_types.h>
+-#include <webrtc/system_wrappers/include/trace.h>
++#define WEBRTC_APM_DEBUG_DUMP 0
++
++#include <modules/audio_processing/include/audio_processing.h>
+ 
+ #define BLOCK_SIZE_US 10000
+ 
+ #define DEFAULT_HIGH_PASS_FILTER true
+ #define DEFAULT_NOISE_SUPPRESSION true
++#define DEFAULT_TRANSIENT_NOISE_SUPPRESSION true
+ #define DEFAULT_ANALOG_GAIN_CONTROL true
+ #define DEFAULT_DIGITAL_GAIN_CONTROL false
+ #define DEFAULT_MOBILE false
+-#define DEFAULT_ROUTING_MODE "speakerphone"
+ #define DEFAULT_COMFORT_NOISE true
+ #define DEFAULT_DRIFT_COMPENSATION false
+-#define DEFAULT_VAD true
+-#define DEFAULT_EXTENDED_FILTER false
+-#define DEFAULT_INTELLIGIBILITY_ENHANCER false
+-#define DEFAULT_EXPERIMENTAL_AGC false
++#define DEFAULT_VAD false
+ #define DEFAULT_AGC_START_VOLUME 85
+-#define DEFAULT_BEAMFORMING false
+-#define DEFAULT_TRACE false
++#define DEFAULT_POSTAMP_ENABLE false
++#define DEFAULT_POSTAMP_GAIN_DB 0
++#define DEFAULT_PREAMP_ENABLE false
++#define DEFAULT_PREAMP_GAIN_DB 0
+ 
+ #define WEBRTC_AGC_MAX_VOLUME 255
++#define WEBRTC_POSTAMP_GAIN_MAX_DB 90
++#define WEBRTC_PREAMP_GAIN_MAX_DB 90
+ 
+ static const char* const valid_modargs[] = {
+-    "high_pass_filter",
+-    "noise_suppression",
++    "agc_start_volume",
+     "analog_gain_control",
+     "digital_gain_control",
++    "high_pass_filter",
+     "mobile",
+-    "routing_mode",
+-    "comfort_noise",
+-    "drift_compensation",
++    "noise_suppression",
++    "post_amplifier",
++    "post_amplifier_gain",
++    "pre_amplifier",
++    "pre_amplifier_gain",
++    "transient_noise_suppression",
+     "voice_detection",
+-    "extended_filter",
+-    "intelligibility_enhancer",
+-    "experimental_agc",
+-    "agc_start_volume",
+-    "beamforming",
+-    "mic_geometry", /* documented in parse_mic_geometry() */
+-    "target_direction", /* documented in parse_mic_geometry() */
+-    "trace",
+     NULL
+ };
+ 
+-static int routing_mode_from_string(const char *rmode) {
+-    if (pa_streq(rmode, "quiet-earpiece-or-headset"))
+-        return webrtc::EchoControlMobile::kQuietEarpieceOrHeadset;
+-    else if (pa_streq(rmode, "earpiece"))
+-        return webrtc::EchoControlMobile::kEarpiece;
+-    else if (pa_streq(rmode, "loud-earpiece"))
+-        return webrtc::EchoControlMobile::kLoudEarpiece;
+-    else if (pa_streq(rmode, "speakerphone"))
+-        return webrtc::EchoControlMobile::kSpeakerphone;
+-    else if (pa_streq(rmode, "loud-speakerphone"))
+-        return webrtc::EchoControlMobile::kLoudSpeakerphone;
+-    else
+-        return -1;
+-}
+-
+-class PaWebrtcTraceCallback : public webrtc::TraceCallback {
+-    void Print(webrtc::TraceLevel level, const char *message, int length)
+-    {
+-        if (level & webrtc::kTraceError || level & webrtc::kTraceCritical)
+-            pa_log("%s", message);
+-        else if (level & webrtc::kTraceWarning)
+-            pa_log_warn("%s", message);
+-        else if (level & webrtc::kTraceInfo)
+-            pa_log_info("%s", message);
+-        else
+-            pa_log_debug("%s", message);
+-    }
+-};
+-
+ static int webrtc_volume_from_pa(pa_volume_t v)
+ {
+     return (v * WEBRTC_AGC_MAX_VOLUME) / PA_VOLUME_NORM;
+@@ -120,8 +87,7 @@ static pa_volume_t webrtc_volume_to_pa(int v)
+ 
+ static void webrtc_ec_fixate_spec(pa_sample_spec *rec_ss, pa_channel_map *rec_map,
+                                   pa_sample_spec *play_ss, pa_channel_map *play_map,
+-                                  pa_sample_spec *out_ss, pa_channel_map *out_map,
+-                                  bool beamforming)
++                                  pa_sample_spec *out_ss, pa_channel_map *out_map)
+ {
+     rec_ss->format = PA_SAMPLE_FLOAT32NE;
+     play_ss->format = PA_SAMPLE_FLOAT32NE;
+@@ -139,110 +105,22 @@ static void webrtc_ec_fixate_spec(pa_sample_spec *rec_ss, pa_channel_map *rec_ma
+     *out_ss = *rec_ss;
+     *out_map = *rec_map;
+ 
+-    if (beamforming) {
+-        /* The beamformer gives us a single channel */
+-        out_ss->channels = 1;
+-        pa_channel_map_init_mono(out_map);
+-    }
+-
+     /* Playback stream rate needs to be the same as capture */
+     play_ss->rate = rec_ss->rate;
+ }
+ 
+-static bool parse_point(const char **point, float (&f)[3]) {
+-    int ret, length;
+-
+-    ret = sscanf(*point, "%g,%g,%g%n", &f[0], &f[1], &f[2], &length);
+-    if (ret != 3)
+-        return false;
+-
+-    /* Consume the bytes we've read so far */
+-    *point += length;
+-
+-    return true;
+-}
+-
+-static bool parse_mic_geometry(const char **mic_geometry, std::vector<webrtc::Point>& geometry) {
+-    /* The microphone geometry is expressed as cartesian point form:
+-     *   x1,y1,z1,x2,y2,z2,...
+-     *
+-     * Where x1,y1,z1 is the position of the first microphone with regards to
+-     * the array's "center", x2,y2,z2 the position of the second, and so on.
+-     *
+-     * 'x' is the horizontal coordinate, with positive values being to the
+-     * right from the mic array's perspective.
+-     *
+-     * 'y' is the depth coordinate, with positive values being in front of the
+-     * array.
+-     *
+-     * 'z' is the vertical coordinate, with positive values being above the
+-     * array.
+-     *
+-     * All distances are in meters.
+-     */
+-
+-    /* The target direction is expected to be in spherical point form:
+-     *   a,e,r
+-     *
+-     * Where 'a' is the azimuth of the target point relative to the center of
+-     * the array, 'e' its elevation, and 'r' the radius.
+-     *
+-     * 0 radians azimuth is to the right of the array, and positive angles
+-     * move in a counter-clockwise direction.
+-     *
+-     * 0 radians elevation is horizontal w.r.t. the array, and positive
+-     * angles go upwards.
+-     *
+-     * radius is distance from the array center in meters.
+-     */
+-
+-    long unsigned int i;
+-    float f[3];
+-
+-    for (i = 0; i < geometry.size(); i++) {
+-        if (!parse_point(mic_geometry, f)) {
+-            pa_log("Failed to parse channel %lu in mic_geometry", i);
+-            return false;
+-        }
+-
+-        /* Except for the last point, we should have a trailing comma */
+-        if (i != geometry.size() - 1) {
+-            if (**mic_geometry != ',') {
+-                pa_log("Failed to parse channel %lu in mic_geometry", i);
+-                return false;
+-            }
+-
+-            (*mic_geometry)++;
+-        }
+-
+-        pa_log_debug("Got mic #%lu position: (%g, %g, %g)", i, f[0], f[1], f[2]);
+-
+-        geometry[i].c[0] = f[0];
+-        geometry[i].c[1] = f[1];
+-        geometry[i].c[2] = f[2];
+-    }
+-
+-    if (**mic_geometry != '\0') {
+-        pa_log("Failed to parse mic_geometry value: more parameters than expected");
+-        return false;
+-    }
+-
+-    return true;
+-}
+-
+ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+                        pa_sample_spec *rec_ss, pa_channel_map *rec_map,
+                        pa_sample_spec *play_ss, pa_channel_map *play_map,
+                        pa_sample_spec *out_ss, pa_channel_map *out_map,
+                        uint32_t *nframes, const char *args) {
+-    webrtc::AudioProcessing *apm = NULL;
++    webrtc::AudioProcessing *apm = webrtc::AudioProcessingBuilder().Create();
+     webrtc::ProcessingConfig pconfig;
+-    webrtc::Config config;
+-    bool hpf, ns, agc, dgc, mobile, cn, vad, ext_filter, intelligibility, experimental_agc, beamforming;
+-    int rm = -1, i;
+-    uint32_t agc_start_volume;
++    webrtc::AudioProcessing::Config config;
++    bool hpf, ns, tns, agc, dgc, mobile, pre_amp, vad, post_amp;
++    int i;
++    uint32_t agc_start_volume, pre_amp_gain, post_amp_gain;
+     pa_modargs *ma;
+-    bool trace = false;
+ 
+     if (!(ma = pa_modargs_new(args, valid_modargs))) {
+         pa_log("Failed to parse submodule arguments.");
+@@ -261,6 +139,12 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+         goto fail;
+     }
+ 
++    tns = DEFAULT_TRANSIENT_NOISE_SUPPRESSION;
++    if (pa_modargs_get_value_boolean(ma, "transient_noise_suppression", &tns) < 0) {
++        pa_log("Failed to parse transient_noise_suppression value");
++        goto fail;
++    }
++
+     agc = DEFAULT_ANALOG_GAIN_CONTROL;
+     if (pa_modargs_get_value_boolean(ma, "analog_gain_control", &agc) < 0) {
+         pa_log("Failed to parse analog_gain_control value");
+@@ -278,62 +162,47 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+         goto fail;
+     }
+ 
+-    mobile = DEFAULT_MOBILE;
+-    if (pa_modargs_get_value_boolean(ma, "mobile", &mobile) < 0) {
+-        pa_log("Failed to parse mobile value");
++    pre_amp = DEFAULT_PREAMP_ENABLE;
++    if (pa_modargs_get_value_boolean(ma, "pre_amplifier", &pre_amp) < 0) {
++        pa_log("Failed to parse pre_amplifier value");
+         goto fail;
+     }
+-
+-    ec->params.drift_compensation = DEFAULT_DRIFT_COMPENSATION;
+-    if (pa_modargs_get_value_boolean(ma, "drift_compensation", &ec->params.drift_compensation) < 0) {
+-        pa_log("Failed to parse drift_compensation value");
++    pre_amp_gain = DEFAULT_PREAMP_GAIN_DB;
++    if (pa_modargs_get_value_u32(ma, "pre_amplifier_gain", &pre_amp_gain) < 0) {
++        pa_log("Failed to parse pre_amplifier_gain value");
+         goto fail;
+     }
+-
+-    if (mobile) {
+-        if (ec->params.drift_compensation) {
+-            pa_log("Can't use drift_compensation in mobile mode");
+-            goto fail;
+-        }
+-
+-        if ((rm = routing_mode_from_string(pa_modargs_get_value(ma, "routing_mode", DEFAULT_ROUTING_MODE))) < 0) {
+-            pa_log("Failed to parse routing_mode value");
+-            goto fail;
+-        }
+-
+-        cn = DEFAULT_COMFORT_NOISE;
+-        if (pa_modargs_get_value_boolean(ma, "comfort_noise", &cn) < 0) {
+-            pa_log("Failed to parse cn value");
+-            goto fail;
+-        }
+-    } else {
+-        if (pa_modargs_get_value(ma, "comfort_noise", NULL) || pa_modargs_get_value(ma, "routing_mode", NULL)) {
+-            pa_log("The routing_mode and comfort_noise options are only valid with mobile=true");
+-            goto fail;
+-        }
++    if (pre_amp_gain > WEBRTC_PREAMP_GAIN_MAX_DB) {
++        pa_log("Preamp gain must not exceed %u", WEBRTC_PREAMP_GAIN_MAX_DB);
++        goto fail;
+     }
+ 
+-    vad = DEFAULT_VAD;
+-    if (pa_modargs_get_value_boolean(ma, "voice_detection", &vad) < 0) {
+-        pa_log("Failed to parse voice_detection value");
++    post_amp = DEFAULT_POSTAMP_ENABLE;
++    if (pa_modargs_get_value_boolean(ma, "post_amplifier", &post_amp) < 0) {
++        pa_log("Failed to parse post_amplifier value");
+         goto fail;
+     }
+-
+-    ext_filter = DEFAULT_EXTENDED_FILTER;
+-    if (pa_modargs_get_value_boolean(ma, "extended_filter", &ext_filter) < 0) {
+-        pa_log("Failed to parse extended_filter value");
++    post_amp_gain = DEFAULT_POSTAMP_GAIN_DB;
++    if (pa_modargs_get_value_u32(ma, "post_amplifier_gain", &post_amp_gain) < 0) {
++        pa_log("Failed to parse post_amplifier_gain value");
++        goto fail;
++    }
++    if (post_amp_gain > WEBRTC_POSTAMP_GAIN_MAX_DB) {
++        pa_log("Postamp gain must not exceed %u", WEBRTC_POSTAMP_GAIN_MAX_DB);
+         goto fail;
+     }
+ 
+-    intelligibility = DEFAULT_INTELLIGIBILITY_ENHANCER;
+-    if (pa_modargs_get_value_boolean(ma, "intelligibility_enhancer", &intelligibility) < 0) {
+-        pa_log("Failed to parse intelligibility_enhancer value");
++    mobile = DEFAULT_MOBILE;
++    if (pa_modargs_get_value_boolean(ma, "mobile", &mobile) < 0) {
++        pa_log("Failed to parse mobile value");
+         goto fail;
+     }
+ 
+-    experimental_agc = DEFAULT_EXPERIMENTAL_AGC;
+-    if (pa_modargs_get_value_boolean(ma, "experimental_agc", &experimental_agc) < 0) {
+-        pa_log("Failed to parse experimental_agc value");
++    ec->params.drift_compensation = DEFAULT_DRIFT_COMPENSATION;
++
++    vad = DEFAULT_VAD;
++    if (pa_modargs_get_value_boolean(ma, "voice_detection", &vad) < 0) {
++        pa_log("Failed to parse voice_detection value");
+         goto fail;
+     }
+ 
+@@ -348,82 +217,7 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+     }
+     ec->params.webrtc.agc_start_volume = agc_start_volume;
+ 
+-    beamforming = DEFAULT_BEAMFORMING;
+-    if (pa_modargs_get_value_boolean(ma, "beamforming", &beamforming) < 0) {
+-        pa_log("Failed to parse beamforming value");
+-        goto fail;
+-    }
+-
+-    if (ext_filter)
+-        config.Set<webrtc::ExtendedFilter>(new webrtc::ExtendedFilter(true));
+-    if (intelligibility)
+-        pa_log_warn("The intelligibility enhancer is not currently supported");
+-    if (experimental_agc)
+-        config.Set<webrtc::ExperimentalAgc>(new webrtc::ExperimentalAgc(true, ec->params.webrtc.agc_start_volume));
+-
+-    trace = DEFAULT_TRACE;
+-    if (pa_modargs_get_value_boolean(ma, "trace", &trace) < 0) {
+-        pa_log("Failed to parse trace value");
+-        goto fail;
+-    }
+-
+-    if (trace) {
+-        webrtc::Trace::CreateTrace();
+-        webrtc::Trace::set_level_filter(webrtc::kTraceAll);
+-        ec->params.webrtc.trace_callback = new PaWebrtcTraceCallback();
+-        webrtc::Trace::SetTraceCallback((PaWebrtcTraceCallback *) ec->params.webrtc.trace_callback);
+-    }
+-
+-    webrtc_ec_fixate_spec(rec_ss, rec_map, play_ss, play_map, out_ss, out_map, beamforming);
+-
+-    /* We do this after fixate because we need the capture channel count */
+-    if (beamforming) {
+-        std::vector<webrtc::Point> geometry(rec_ss->channels);
+-        webrtc::SphericalPointf direction(0.0f, 0.0f, 0.0f);
+-        const char *mic_geometry, *target_direction;
+-
+-        if (!(mic_geometry = pa_modargs_get_value(ma, "mic_geometry", NULL))) {
+-            pa_log("mic_geometry must be set if beamforming is enabled");
+-            goto fail;
+-        }
+-
+-        if (!parse_mic_geometry(&mic_geometry, geometry)) {
+-            pa_log("Failed to parse mic_geometry value");
+-            goto fail;
+-        }
+-
+-        if ((target_direction = pa_modargs_get_value(ma, "target_direction", NULL))) {
+-            float f[3];
+-
+-            if (!parse_point(&target_direction, f)) {
+-                pa_log("Failed to parse target_direction value");
+-                goto fail;
+-            }
+-
+-            if (*target_direction != '\0') {
+-                pa_log("Failed to parse target_direction value: more parameters than expected");
+-                goto fail;
+-            }
+-
+-#define IS_ZERO(f) ((f) < 0.000001 && (f) > -0.000001)
+-
+-            if (!IS_ZERO(f[1]) || !IS_ZERO(f[2])) {
+-                pa_log("The beamformer currently only supports targeting along the azimuth");
+-                goto fail;
+-            }
+-
+-            direction.s[0] = f[0];
+-            direction.s[1] = f[1];
+-            direction.s[2] = f[2];
+-        }
+-
+-        if (!target_direction)
+-            config.Set<webrtc::Beamforming>(new webrtc::Beamforming(true, geometry));
+-        else
+-            config.Set<webrtc::Beamforming>(new webrtc::Beamforming(true, geometry, direction));
+-    }
+-
+-    apm = webrtc::AudioProcessing::Create(config);
++    webrtc_ec_fixate_spec(rec_ss, rec_map, play_ss, play_map, out_ss, out_map);
+ 
+     pconfig = {
+         webrtc::StreamConfig(rec_ss->rate, rec_ss->channels, false), /* input stream */
+@@ -436,46 +230,60 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+         goto fail;
+     }
+ 
++    if (pre_amp) {
++       config.pre_amplifier.enabled = true;
++       config.pre_amplifier.fixed_gain_factor = (float)pre_amp_gain;
++    } else
++       config.pre_amplifier.enabled = false;
++
+     if (hpf)
+-        apm->high_pass_filter()->Enable(true);
+-
+-    if (!mobile) {
+-        apm->echo_cancellation()->enable_drift_compensation(ec->params.drift_compensation);
+-        apm->echo_cancellation()->Enable(true);
+-    } else {
+-        apm->echo_control_mobile()->set_routing_mode(static_cast<webrtc::EchoControlMobile::RoutingMode>(rm));
+-        apm->echo_control_mobile()->enable_comfort_noise(cn);
+-        apm->echo_control_mobile()->Enable(true);
+-    }
++        config.high_pass_filter.enabled = true;
++    else
++        config.high_pass_filter.enabled = false;
+ 
+-    if (ns) {
+-        apm->noise_suppression()->set_level(webrtc::NoiseSuppression::kHigh);
+-        apm->noise_suppression()->Enable(true);
+-    }
++    config.echo_canceller.enabled = true;
+ 
+-    if (agc || dgc) {
+-        if (mobile && rm <= webrtc::EchoControlMobile::kEarpiece) {
+-            /* Maybe this should be a knob, but we've got a lot of knobs already */
+-            apm->gain_control()->set_mode(webrtc::GainControl::kFixedDigital);
+-            ec->params.webrtc.agc = false;
+-        } else if (dgc) {
+-            apm->gain_control()->set_mode(webrtc::GainControl::kAdaptiveDigital);
+-            ec->params.webrtc.agc = false;
+-        } else {
+-            apm->gain_control()->set_mode(webrtc::GainControl::kAdaptiveAnalog);
+-            if (apm->gain_control()->set_analog_level_limits(0, WEBRTC_AGC_MAX_VOLUME) !=
+-                    webrtc::AudioProcessing::kNoError) {
+-                pa_log("Failed to initialise AGC");
+-                goto fail;
+-            }
+-            ec->params.webrtc.agc = true;
+-        }
++    if (!mobile)
++        config.echo_canceller.mobile_mode = false;
++    else
++        config.echo_canceller.mobile_mode = true;
++
++    if (ns)
++       config.noise_suppression.enabled = true;
++    else
++       config.noise_suppression.enabled = false;
+ 
+-        apm->gain_control()->Enable(true);
++    if (tns)
++       config.transient_suppression.enabled = true;
++    else
++       config.transient_suppression.enabled = false;
++
++    if (dgc) {
++        ec->params.webrtc.agc = false;
++        config.gain_controller1.enabled = true;
++        if (mobile)
++            config.gain_controller1.mode = webrtc::AudioProcessing::Config::GainController1::kFixedDigital;
++        else
++            config.gain_controller1.mode = webrtc::AudioProcessing::Config::GainController1::kAdaptiveDigital;
++    } else if (agc) {
++        ec->params.webrtc.agc = true;
++        config.gain_controller1.enabled = true;
++        config.gain_controller1.mode = webrtc::AudioProcessing::Config::GainController1::kAdaptiveAnalog;
++        config.gain_controller1.analog_level_minimum = 0;
++        config.gain_controller1.analog_level_maximum = WEBRTC_AGC_MAX_VOLUME;
+     }
+ 
+     if (vad)
+-        apm->voice_detection()->Enable(true);
++        config.voice_detection.enabled = true;
++    else
++        config.voice_detection.enabled = false;
++
++    if (post_amp) {
++        config.gain_controller2.enabled = true;
++        config.gain_controller2.fixed_digital.gain_db = (float)post_amp_gain;
++        config.gain_controller2.adaptive_digital.enabled = false;
++    } else
++        config.gain_controller2.enabled = false;
+ 
+     ec->params.webrtc.apm = apm;
+     ec->params.webrtc.rec_ss = *rec_ss;
+@@ -485,6 +293,8 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+     *nframes = ec->params.webrtc.blocksize;
+     ec->params.webrtc.first = true;
+ 
++    apm->ApplyConfig(config);
++
+     for (i = 0; i < rec_ss->channels; i++)
+         ec->params.webrtc.rec_buffer[i] = pa_xnew(float, *nframes);
+     for (i = 0; i < play_ss->channels; i++)
+@@ -496,10 +306,7 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+ fail:
+     if (ma)
+         pa_modargs_free(ma);
+-    if (ec->params.webrtc.trace_callback) {
+-        webrtc::Trace::ReturnTrace();
+-        delete ((PaWebrtcTraceCallback *) ec->params.webrtc.trace_callback);
+-    } if (apm)
++    if (apm)
+         delete apm;
+ 
+     return false;
+@@ -515,12 +322,6 @@ void pa_webrtc_ec_play(pa_echo_canceller *ec, const uint8_t *play) {
+     pa_deinterleave(play, (void **) buf, ss->channels, pa_sample_size(ss), n);
+ 
+     pa_assert_se(apm->ProcessReverseStream(buf, config, config, buf) == webrtc::AudioProcessing::kNoError);
+-
+-    /* FIXME: If ProcessReverseStream() makes any changes to the audio, such as
+-     * applying intelligibility enhancement, those changes don't have any
+-     * effect. This function is called at the source side, but the processing
+-     * would have to be done in the sink to be able to feed the processed audio
+-     * to speakers. */
+ }
+ 
+ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out) {
+@@ -538,7 +339,7 @@ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out
+     if (ec->params.webrtc.agc) {
+         pa_volume_t v = pa_echo_canceller_get_capture_volume(ec);
+         old_volume = webrtc_volume_from_pa(v);
+-        apm->gain_control()->set_stream_analog_level(old_volume);
++        apm->set_stream_analog_level(old_volume);
+     }
+ 
+     apm->set_stream_delay_ms(0);
+@@ -553,7 +354,7 @@ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out
+             ec->params.webrtc.first = false;
+             new_volume = ec->params.webrtc.agc_start_volume;
+         } else {
+-            new_volume = apm->gain_control()->stream_analog_level();
++            new_volume = apm->recommended_stream_analog_level();
+         }
+ 
+         if (old_volume != new_volume)
+@@ -564,9 +365,6 @@ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out
+ }
+ 
+ void pa_webrtc_ec_set_drift(pa_echo_canceller *ec, float drift) {
+-    webrtc::AudioProcessing *apm = (webrtc::AudioProcessing*)ec->params.webrtc.apm;
+-
+-    apm->echo_cancellation()->set_stream_drift_samples(drift * ec->params.webrtc.blocksize);
+ }
+ 
+ void pa_webrtc_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out) {
+@@ -577,11 +375,6 @@ void pa_webrtc_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *
+ void pa_webrtc_ec_done(pa_echo_canceller *ec) {
+     int i;
+ 
+-    if (ec->params.webrtc.trace_callback) {
+-        webrtc::Trace::ReturnTrace();
+-        delete ((PaWebrtcTraceCallback *) ec->params.webrtc.trace_callback);
+-    }
+-
+     if (ec->params.webrtc.apm) {
+         delete (webrtc::AudioProcessing*)ec->params.webrtc.apm;
+         ec->params.webrtc.apm = NULL;
+-- 
+GitLab
+
+
+From 84c53066c65439deb42d29bba8c6899a4fa0e318 Mon Sep 17 00:00:00 2001
+From: Arun Raghavan <arun@asymptotic.io>
+Date: Tue, 20 Oct 2020 17:29:55 -0400
+Subject: [PATCH 3/3] build-sys: Bump webrtc-audio-processing dependency
+
+The package name and versioning are changing upstream, so prepare for
+that.
+
+Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/395>
+---
+ meson.build | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index b678bb531a..a1652e4d30 100644
+--- a/meson.build
++++ b/meson.build
+@@ -728,7 +728,7 @@ if get_option('daemon')
+     cdata.set('HAVE_SOXR', 1)
+   endif
+ 
+-  webrtc_dep = dependency('webrtc-audio-processing', version : '>= 0.2', required : get_option('webrtc-aec'))
++  webrtc_dep = dependency('webrtc-audio-processing-1', version : '>= 1.0', required : get_option('webrtc-aec'))
+   if webrtc_dep.found()
+     cdata.set('HAVE_WEBRTC', 1)
+   endif
+-- 
+GitLab
+
+
diff --git a/srcpkgs/pulseaudio/template b/srcpkgs/pulseaudio/template
index 30f0a4cc23a9c..4b0dbd4cef08b 100644
--- a/srcpkgs/pulseaudio/template
+++ b/srcpkgs/pulseaudio/template
@@ -1,14 +1,15 @@
 # Template file for 'pulseaudio'
 pkgname=pulseaudio
 version=16.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Djack=enabled -Dlirc=disabled -Dhal-compat=false -Dorc=enabled
  -Dgtk=disabled -Dsystemd=disabled -Dwebrtc-aec=enabled
  -Dgsettings=enabled -Dbluez5=enabled
  -Dbluez5-ofono-headset=false -Dbluez5-native-headset=true
  -Delogind=enabled -Dudevrulesdir=/usr/lib/udev/rules.d
- -Dbashcompletiondir=/usr/share/bash-completion/completions"
+ -Dbashcompletiondir=/usr/share/bash-completion/completions
+ -Dcpp_std=c++17"
 hostmakedepends="cmake m4 gettext libtool orc-devel perl-XML-Parser pkg-config
  doxygen"
 makedepends="$(vopt_if avahi avahi-libs-devel) eudev-libudev-devel fftw-devel jack-devel

From 7240ac88ebaae974f3a0ce4d2a2e18278b3b94f1 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Fri, 23 Feb 2024 17:10:40 -0500
Subject: [PATCH 4/6] pipewire: revbump for webrtc-audio-processing-1.3

---
 srcpkgs/pipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index d23956e13e3a7..4848292c1d840 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'pipewire'
 pkgname=pipewire
 version=1.0.3
-revision=1
+revision=2
 build_style=meson
 configure_args="
  --auto-features=enabled

From b4636824e783e4c609fa47ea7a6c1a638efd8a82 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Fri, 23 Feb 2024 17:11:10 -0500
Subject: [PATCH 5/6] gst-plugins-bad1: revbump for webrtc-audio-processing-1.3

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 10dc49f4c151b..dc4db910c43e8 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From ae5ff202d7e03ba5ea0c00fd9cd96f7b9c29f725 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Fri, 23 Feb 2024 17:11:47 -0500
Subject: [PATCH 6/6] baresip: revbump for webrtc-audio-processing-1.3

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: webrtc-audio-processing: update to 1.3; revbump dependents
  2024-02-23 23:04 [PR PATCH] webrtc-audio-processing: update to 1.3; revbump dependents cinerea0
@ 2024-02-23 23:11 ` cinerea0
  2024-02-23 23:21 ` [PR PATCH] [Updated] " cinerea0
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cinerea0 @ 2024-02-23 23:11 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 182 bytes --]

New comment by cinerea0 on void-packages repository

https://github.com/void-linux/void-packages/pull/48902#issuecomment-1962119716

Comment:
Guess I need that musl patch after all.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PR PATCH] [Updated] webrtc-audio-processing: update to 1.3; revbump dependents
  2024-02-23 23:04 [PR PATCH] webrtc-audio-processing: update to 1.3; revbump dependents cinerea0
  2024-02-23 23:11 ` cinerea0
@ 2024-02-23 23:21 ` cinerea0
  2024-02-24  0:16 ` ahesford
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cinerea0 @ 2024-02-23 23:21 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 532 bytes --]

There is an updated pull request by cinerea0 against master on the void-packages repository

https://github.com/cinerea0/void-packages webrtc
https://github.com/void-linux/void-packages/pull/48902

webrtc-audio-processing: update to 1.3; revbump dependents
#### Testing the changes
- I tested the changes in this PR: **YES**

---

@ahesford Are there any potential negative consequences of forcing abseil to use C++17 you can think of?

A patch file from https://github.com/void-linux/void-packages/pull/48902.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-webrtc-48902.patch --]
[-- Type: text/x-diff, Size: 43927 bytes --]

From 6925ee460c186f9d23e95317e2328cbe88a19fa6 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Fri, 23 Feb 2024 18:18:50 -0500
Subject: [PATCH 1/6] abseil-cpp: use C++17

---
 srcpkgs/abseil-cpp/template | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/abseil-cpp/template b/srcpkgs/abseil-cpp/template
index 7909b5e19e0aa..b19c444a1fe4f 100644
--- a/srcpkgs/abseil-cpp/template
+++ b/srcpkgs/abseil-cpp/template
@@ -1,9 +1,10 @@
 # Template file for 'abseil-cpp'
 pkgname=abseil-cpp
 version=20240116.1
-revision=1
+revision=2
 build_style=cmake
-configure_args="-DBUILD_SHARED_LIBS=ON -DABSL_PROPAGATE_CXX_STD=ON"
+configure_args="-DBUILD_SHARED_LIBS=ON -DABSL_PROPAGATE_CXX_STD=ON
+ -DCMAKE_CXX_STANDARD=17"
 hostmakedepends="pkg-config"
 short_desc="Abseil common libraries"
 maintainer="Andrew J. Hesford <ajh@sideband.org>"

From ee6ad5ba5d21ba79d53a5d373c4b48b1f2c5b638 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Fri, 23 Feb 2024 18:19:24 -0500
Subject: [PATCH 2/6] webrtc-audio-processing: update to 1.3

---
 common/shlibs                                 |   3 +-
 ...yte-order-and-pointer-size-detection.patch |  24 ++--
 .../patches/i686-no-sse.patch                 |  15 +++
 .../patches/mips.patch                        | 113 ------------------
 .../patches/musl.patch                        |  51 +++++---
 srcpkgs/webrtc-audio-processing/template      |  31 ++---
 6 files changed, 74 insertions(+), 163 deletions(-)
 create mode 100644 srcpkgs/webrtc-audio-processing/patches/i686-no-sse.patch
 delete mode 100644 srcpkgs/webrtc-audio-processing/patches/mips.patch

diff --git a/common/shlibs b/common/shlibs
index cde1106f7dbef..b6003ee4fbcc4 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1056,7 +1056,8 @@ libiptcdata.so.0 libiptcdata-1.0.4_1
 libutempter.so.0 libutempter-1.1.5_1
 libxatracker.so.2 libxatracker-10.0.0_2
 libtumbler-1.so.0 tumbler-4.9.2_1
-libwebrtc_audio_processing.so.1 webrtc-audio-processing-0.3_1
+libwebrtc-audio-coding-1.so.3 webrtc-audio-processing-1.3_1
+libwebrtc-audio-processing-1.so.3 webrtc-audio-processing-1.3_1
 libcupsmime.so.1 libcups-1.5.3_1
 libcupsppdc.so.1 libcups-1.5.3_1
 libcupscgi.so.1 libcups-1.5.3_1
diff --git a/srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.patch b/srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.patch
index 1338784e69ef8..28f1dbdcd8684 100644
--- a/srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.patch
+++ b/srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.patch
@@ -1,20 +1,20 @@
-From: Than <than@redhat.com>
-Date: Wed, 8 Jun 2016 19:10:08 -0400
-Subject: Add generic byte order and pointer size detection
+Taken from https://gitweb.gentoo.org/repo/gentoo.git/tree/media-libs/webrtc-audio-processing/files/webrtc-audio-processing-1.3-Add-generic-byte-order-and-pointer-size-detection.patch?id=29cd0e622b574df6adff5704ab4e220709619767
+https://bugs.gentoo.org/917493
+https://sources.debian.org/src/webrtc-audio-processing/1.0-0.2/debian/patches/Add-generic-byte-order-and-pointer-size-detection.patch/
 
+Description: Add generic byte order and pointer size detection
+Author: Than <than@redhat.com>
+Origin: https://bugs.freedesktop.org/show_bug.cgi?id=95738#c4
+Last-Update: 2022-02-01
 ---
- webrtc/typedefs.h | 14 +++++++++++++-
- 1 file changed, 13 insertions(+), 1 deletion(-)
-
-diff --git a/webrtc/typedefs.h b/webrtc/typedefs.h
-index d875490..dc074f1 100644
---- a/webrtc/typedefs.h
-+++ b/webrtc/typedefs.h
-@@ -48,7 +48,19 @@
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/webrtc/rtc_base/system/arch.h
++++ b/webrtc/rtc_base/system/arch.h
+@@ -58,7 +58,19 @@
  #define WEBRTC_ARCH_32_BITS
  #define WEBRTC_ARCH_LITTLE_ENDIAN
  #else
--#error Please add support for your architecture in typedefs.h
+-#error Please add support for your architecture in rtc_base/system/arch.h
 +/* instead of failing, use typical unix defines... */
 +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 +#define WEBRTC_ARCH_LITTLE_ENDIAN
diff --git a/srcpkgs/webrtc-audio-processing/patches/i686-no-sse.patch b/srcpkgs/webrtc-audio-processing/patches/i686-no-sse.patch
new file mode 100644
index 0000000000000..de145af208312
--- /dev/null
+++ b/srcpkgs/webrtc-audio-processing/patches/i686-no-sse.patch
@@ -0,0 +1,15 @@
+Taken from https://gitweb.gentoo.org/repo/gentoo.git/tree/media-libs/webrtc-audio-processing/files/webrtc-audio-processing-1.3-x86-no-sse.patch?id=29cd0e622b574df6adff5704ab4e220709619767
+https://bugs.gentoo.org/921140
+https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/issues/5
+--- a/webrtc/rtc_base/system/arch.h
++++ b/webrtc/rtc_base/system/arch.h
+@@ -34,7 +34,7 @@
+ #else
+ #define WEBRTC_ARCH_32_BITS
+ #endif
+-#elif defined(_M_IX86) || defined(__i386__)
++#elif defined(__SSE__) && (defined(_M_IX86) || defined(__i386__))
+ #define WEBRTC_ARCH_X86_FAMILY
+ #define WEBRTC_ARCH_X86
+ #define WEBRTC_ARCH_32_BITS
+
diff --git a/srcpkgs/webrtc-audio-processing/patches/mips.patch b/srcpkgs/webrtc-audio-processing/patches/mips.patch
deleted file mode 100644
index c99aaf3922082..0000000000000
--- a/srcpkgs/webrtc-audio-processing/patches/mips.patch
+++ /dev/null
@@ -1,113 +0,0 @@
---- webrtc-audio-processing-0.3_3/configure.ac	2017-11-22 20:26:54.207009881 +0100
-+++ webrtc-audio-processing-0.3_3/configure.ac	2017-11-22 20:37:57.472996521 +0100
-@@ -90,10 +90,14 @@
- 	[HAVE_NEON=1; ARCH_CFLAGS="${ARCH_CFLAGS} -DWEBRTC_HAS_NEON -DWEBRTC_ARCH_ARM64"])
- AC_CHECK_DECLS([__i386__], [HAVE_X86=1])
- AC_CHECK_DECLS([__x86_64__], [HAVE_X86=1])
-+AC_CHECK_DECLS([__MIPSEB__], [HAVE_MIPSEB=1])
-+AC_CHECK_DECLS([__MIPSEL__], [HAVE_MIPSEL=1])
- 
- AM_CONDITIONAL(HAVE_X86, [test "x${HAVE_X86}" = "x1"])
- AM_CONDITIONAL(HAVE_ARM, [test "x${HAVE_ARM}" = "x1"])
- AM_CONDITIONAL(HAVE_ARMV7, [test "x${HAVE_ARMV7}" = "x1"])
-+AM_CONDITIONAL(HAVE_MIPSEB, [test "x${HAVE_MIPSEB}" = "x1"])
-+AM_CONDITIONAL(HAVE_MIPSEL, [test "x${HAVE_MIPSEL}" = "x1"])
- 
- # Borrowed from pulseaudio's configure.ac
- AC_ARG_ENABLE([neon],
---- webrtc-audio-processing-0.3_3/webrtc/typedefs.h	2015-10-15 12:48:25.000000000 +0200
-+++ webrtc-audio-processing-0.3_3/webrtc/typedefs.h	2017-11-22 20:39:20.800994843 +0100
-@@ -47,6 +47,10 @@
- #elif defined(__pnacl__)
- #define WEBRTC_ARCH_32_BITS
- #define WEBRTC_ARCH_LITTLE_ENDIAN
-+#elif defined(__MIPSEL__)
-+#define WEBRTC_ARCH_LITTLE_ENDIAN
-+#elif defined(__MIPSEB__)
-+#define WEBRTC_ARCH_BIG_ENDIAN
- #else
- #error Please add support for your architecture in typedefs.h
- #endif
---- webrtc-audio-processing-0.3/webrtc/common_audio/wav_file.cc	2015-11-19 13:41:44.000000000 +0100
-+++ webrtc-audio-processing-0.3/webrtc/common_audio/wav_file.cc	2017-11-22 21:01:46.554967737 +0100
-@@ -64,9 +64,6 @@
- }
- 
- size_t WavReader::ReadSamples(size_t num_samples, int16_t* samples) {
--#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
--#error "Need to convert samples to big-endian when reading from WAV file"
--#endif
-   // There could be metadata after the audio; ensure we don't read it.
-   num_samples = std::min(rtc::checked_cast<uint32_t>(num_samples),
-                          num_samples_remaining_);
-@@ -76,6 +73,12 @@
-   RTC_CHECK(read == num_samples || feof(file_handle_));
-   RTC_CHECK_LE(read, num_samples_remaining_);
-   num_samples_remaining_ -= rtc::checked_cast<uint32_t>(read);
-+#ifdef WEBRTC_ARCH_BIG_ENDIAN
-+  for (size_t i = 0; i < read; i++) {
-+    uint16_t s = static_cast<uint16_t>(samples[i]);
-+    samples[i] = static_cast<int16_t>((s >> 8) | (s << 8));
-+  }
-+#endif
-   return read;
- }
- 
-@@ -119,11 +122,20 @@
- }
- 
- void WavWriter::WriteSamples(const int16_t* samples, size_t num_samples) {
--#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
--#error "Need to convert samples to little-endian when writing to WAV file"
--#endif
-+#ifdef WEBRTC_ARCH_LITTLE_ENDIAN
-   const size_t written =
-       fwrite(samples, sizeof(*samples), num_samples, file_handle_);
-+#else
-+  size_t written = 0;
-+  for (size_t i = 0; i < num_samples; i++) {
-+    uint16_t s = static_cast<uint16_t>(samples[i]);
-+    s = static_cast<int16_t>((s<<8) | (s>>8));
-+    size_t size = fwrite(&s, sizeof(s), 1, file_handle_);
-+    if (size < 1)
-+      break;
-+    written += size;
-+  }
-+#endif
-   RTC_CHECK_EQ(num_samples, written);
-   num_samples_ += static_cast<uint32_t>(written);
-   RTC_CHECK(written <= std::numeric_limits<uint32_t>::max() ||
---- webrtc-audio-processing-0.3/webrtc/common_audio/wav_header.cc	2015-10-15 12:48:44.000000000 +0200
-+++ webrtc-audio-processing-0.3/webrtc/common_audio/wav_header.cc	2017-11-22 21:11:36.291955859 +0100
-@@ -129,7 +129,30 @@
-   return std::string(reinterpret_cast<char*>(&x), 4);
- }
- #else
--#error "Write be-to-le conversion functions"
-+static inline void WriteLE16(uint16_t* f, uint16_t x) { *f = (x >> 8) | (x << 8); }
-+static inline void WriteLE32(uint32_t* f, uint32_t x) {
-+  *f = ((x & 0xff000000) >> 24) |
-+       ((x & 0x00ff0000) >>  8) |
-+       ((x & 0x0000ff00) <<  8) |
-+       ((x & 0x000000ff) << 24);
-+}
-+static inline void WriteFourCC(uint32_t* f, char a, char b, char c, char d) {
-+  *f = (static_cast<uint32_t>(a) << 24)
-+      | (static_cast<uint32_t>(b) << 16)
-+      | (static_cast<uint32_t>(c) << 8)
-+      | static_cast<uint32_t>(d);
-+}
-+static inline uint16_t ReadLE16(uint16_t x) { return (x >> 8) | (x << 8); }
-+static inline uint32_t ReadLE32(uint32_t x) {
-+  return ((x << 24) & 0xff000000) |
-+         ((x <<  8) & 0x00ff0000) |
-+         ((x >>  8) & 0x0000ff00) |
-+         ((x >> 24) & 0x000000ff);
-+}
-+static inline std::string ReadFourCC(uint32_t x) {
-+  uint32_t s = ReadLE32(x);
-+  return std::string(reinterpret_cast<char*>(&s), 4);
-+}
- #endif
- 
- static inline uint32_t RiffChunkSize(uint32_t bytes_in_payload) {
diff --git a/srcpkgs/webrtc-audio-processing/patches/musl.patch b/srcpkgs/webrtc-audio-processing/patches/musl.patch
index adca79b6b7486..335a449686bf6 100644
--- a/srcpkgs/webrtc-audio-processing/patches/musl.patch
+++ b/srcpkgs/webrtc-audio-processing/patches/musl.patch
@@ -1,20 +1,33 @@
---- a/webrtc/base/checks.cc.orig	2016-06-25 07:47:34.099515548 +0200
-+++ b/webrtc/base/checks.cc	2016-06-25 07:48:28.554122463 +0200
-@@ -16,7 +16,7 @@
- #include <cstdio>
- #include <cstdlib>
+https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/merge_requests/37
+(see also https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/merge_requests/38)
+
+From de1b9c444df1ed66d72a4ab3d0e4dd2151037934 Mon Sep 17 00:00:00 2001
+From: Markus Volk <f_l_k@t-online.de>
+Date: Thu, 14 Sep 2023 16:12:32 +0200
+Subject: [PATCH] file_wrapper.h: add missing include for musl
+
+this fixes:
+| In file included from ../webrtc-audio-processing-1.3/webrtc/rtc_base/system/file_wrapper.cc:11:
+| ../webrtc-audio-processing-1.3/webrtc/rtc_base/system/file_wrapper.h:86:21: error: 'int64_t' has not been declared
+
+if built with musl libc
+
+Signed-off-by: Markus Volk <f_l_k@t-online.de>
+---
+ webrtc/rtc_base/system/file_wrapper.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/webrtc/rtc_base/system/file_wrapper.h b/webrtc/rtc_base/system/file_wrapper.h
+index 42c463c..c34d366 100644
+--- a/webrtc/rtc_base/system/file_wrapper.h
++++ b/webrtc/rtc_base/system/file_wrapper.h
+@@ -13,6 +13,7 @@
  
--#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
-+#if defined(__GLIBC__) && defined(__GLIBCXX__)
- #include <cxxabi.h>
- #include <execinfo.h>
- #endif
-@@ -55,7 +55,7 @@ void PrintError(const char* format, ...)
- // to get usable symbols on Linux. This is copied from V8. Chromium has a more
- // advanced stace trace system; also more difficult to copy.
- void DumpBacktrace() {
--#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
-+#if defined(__GLIBC__) && defined(__GLIBCXX__)
-   void* trace[100];
-   int size = backtrace(trace, sizeof(trace) / sizeof(*trace));
-   char** symbols = backtrace_symbols(trace, size);
+ #include <stddef.h>
+ #include <stdio.h>
++#include <cstdint>
+ 
+ #include <string>
+ 
+-- 
+GitLab
diff --git a/srcpkgs/webrtc-audio-processing/template b/srcpkgs/webrtc-audio-processing/template
index 30a420b28f575..e5277d17e0b9e 100644
--- a/srcpkgs/webrtc-audio-processing/template
+++ b/srcpkgs/webrtc-audio-processing/template
@@ -1,38 +1,33 @@
 # Template file for 'webrtc-audio-processing'
 pkgname=webrtc-audio-processing
-version=0.3.1
+version=1.3
 revision=1
-build_style=gnu-configure
-hostmakedepends="automake libtool"
+build_style=meson
+hostmakedepends="pkg-config"
+makedepends="abseil-cpp-devel"
 short_desc="AudioProcessing library based on Google's implementation of WebRTC"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="BSD-3-Clause"
-homepage="http://freedesktop.org/software/pulseaudio/webrtc-audio-processing"
-distfiles="${homepage}/${pkgname}-${version}.tar.xz"
-checksum=a0fdd938fd85272d67e81572c5a4d9e200a0c104753cb3c209ded175ce3c5dbf
+homepage="https://freedesktop.org/software/pulseaudio/webrtc-audio-processing"
+distfiles="${FREEDESKTOP_SITE}/pulseaudio/webrtc-audio-processing/webrtc-audio-processing-${version}.tar.gz"
+checksum=95552fc17faa0202133707bbb3727e8c2cf64d4266fe31bfdb2298d769c1db75
 
-case "$XBPS_TARGET_MACHINE" in
-	# Disable neon for the arm* architectures
-	arm*) configure_args+=" --enable-neon=no" ;;
-esac
-
-pre_configure() {
-	# Remove failing statement PKG_CHECK_MODULE(GNUSTL, gnustl)
-	sed -i configure.ac -e'/if test "x$with_gnustl" != "xno"; then/,+2d'
-	autoreconf -fi
-}
+# Upstream issue: https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/issues/5
+if [ "$XBPS_MACHINE" = "i686" ]; then
+	CXXFLAGS="-DPFFFT_SIMD_DISABLE=1"
+	CFLAGS="-DPFFFT_SIMD_DISABLE=1"
+fi
 
 post_install() {
 	vlicense COPYING
 }
 
 webrtc-audio-processing-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision}"
+	depends="${sourcepkg}>=${version}_${revision} abseil-cpp-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig
-		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }

From e0a9b3b95aaa8f1fc163956d7a83a4ed9185dc72 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Fri, 23 Feb 2024 18:20:10 -0500
Subject: [PATCH 3/6] pulseaudio: revbump for webrtc-audio-processing-1.3

---
 .../patches/webrtc-audio-processing-1.patch   | 676 ++++++++++++++++++
 srcpkgs/pulseaudio/template                   |   5 +-
 2 files changed, 679 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/pulseaudio/patches/webrtc-audio-processing-1.patch

diff --git a/srcpkgs/pulseaudio/patches/webrtc-audio-processing-1.patch b/srcpkgs/pulseaudio/patches/webrtc-audio-processing-1.patch
new file mode 100644
index 0000000000000..12816416f0494
--- /dev/null
+++ b/srcpkgs/pulseaudio/patches/webrtc-audio-processing-1.patch
@@ -0,0 +1,676 @@
+# This can be dropped with PulseAudio 17
+
+From b16b107171f24f791f79c20730cf6eb3ad469944 Mon Sep 17 00:00:00 2001
+From: Arun Raghavan <arun@asymptotic.io>
+Date: Tue, 20 Oct 2020 16:18:57 -0400
+Subject: [PATCH 1/3] echo-cancel-test: Drop references to internal message
+ queue
+
+We don't actually initialise or use it in the test, and this just causes
+a crash at the end.
+
+Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/395>
+---
+ src/modules/echo-cancel/module-echo-cancel.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
+index 3d63ea6084..ae1bf9d684 100644
+--- a/src/modules/echo-cancel/module-echo-cancel.c
++++ b/src/modules/echo-cancel/module-echo-cancel.c
+@@ -2370,8 +2370,6 @@ int main(int argc, char* argv[]) {
+     }
+ 
+     u.ec->done(u.ec);
+-    u.ec->msg->dead = true;
+-    pa_echo_canceller_msg_unref(u.ec->msg);
+ 
+ out:
+     if (u.captured_file)
+-- 
+GitLab
+
+
+From 22bbb5b3ba0d28d630b10944fe19d7f9eee3a00f Mon Sep 17 00:00:00 2001
+From: Eero Nurkkala <eero.nurkkala@offcode.fi>
+Date: Tue, 20 Oct 2020 16:20:23 -0400
+Subject: [PATCH 2/3] echo-cancel: add webrtc AEC3 support
+
+Drop a number of now unsupported features, and add new parameters for
+pre-/post-amplification.
+
+Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/395>
+---
+ src/modules/echo-cancel/webrtc.cc | 433 ++++++++----------------------
+ 1 file changed, 113 insertions(+), 320 deletions(-)
+
+diff --git a/src/modules/echo-cancel/webrtc.cc b/src/modules/echo-cancel/webrtc.cc
+index 56daab0fd0..ed4bb65a56 100644
+--- a/src/modules/echo-cancel/webrtc.cc
++++ b/src/modules/echo-cancel/webrtc.cc
+@@ -3,8 +3,8 @@
+ 
+     Copyright 2011 Collabora Ltd.
+               2015 Aldebaran SoftBank Group
+-
+-    Contributor: Arun Raghavan <mail@arunraghavan.net>
++              2020 Arun Raghavan <arun@asymptotic.io>
++              2020 Eero Nurkkala <eero.nurkkala@offcode.fi>
+ 
+     PulseAudio is free software; you can redistribute it and/or modify
+     it under the terms of the GNU Lesser General Public License as published
+@@ -34,80 +34,47 @@ PA_C_DECL_BEGIN
+ #include "echo-cancel.h"
+ PA_C_DECL_END
+ 
+-#include <webrtc/modules/audio_processing/include/audio_processing.h>
+-#include <webrtc/modules/interface/module_common_types.h>
+-#include <webrtc/system_wrappers/include/trace.h>
++#define WEBRTC_APM_DEBUG_DUMP 0
++
++#include <modules/audio_processing/include/audio_processing.h>
+ 
+ #define BLOCK_SIZE_US 10000
+ 
+ #define DEFAULT_HIGH_PASS_FILTER true
+ #define DEFAULT_NOISE_SUPPRESSION true
++#define DEFAULT_TRANSIENT_NOISE_SUPPRESSION true
+ #define DEFAULT_ANALOG_GAIN_CONTROL true
+ #define DEFAULT_DIGITAL_GAIN_CONTROL false
+ #define DEFAULT_MOBILE false
+-#define DEFAULT_ROUTING_MODE "speakerphone"
+ #define DEFAULT_COMFORT_NOISE true
+ #define DEFAULT_DRIFT_COMPENSATION false
+-#define DEFAULT_VAD true
+-#define DEFAULT_EXTENDED_FILTER false
+-#define DEFAULT_INTELLIGIBILITY_ENHANCER false
+-#define DEFAULT_EXPERIMENTAL_AGC false
++#define DEFAULT_VAD false
+ #define DEFAULT_AGC_START_VOLUME 85
+-#define DEFAULT_BEAMFORMING false
+-#define DEFAULT_TRACE false
++#define DEFAULT_POSTAMP_ENABLE false
++#define DEFAULT_POSTAMP_GAIN_DB 0
++#define DEFAULT_PREAMP_ENABLE false
++#define DEFAULT_PREAMP_GAIN_DB 0
+ 
+ #define WEBRTC_AGC_MAX_VOLUME 255
++#define WEBRTC_POSTAMP_GAIN_MAX_DB 90
++#define WEBRTC_PREAMP_GAIN_MAX_DB 90
+ 
+ static const char* const valid_modargs[] = {
+-    "high_pass_filter",
+-    "noise_suppression",
++    "agc_start_volume",
+     "analog_gain_control",
+     "digital_gain_control",
++    "high_pass_filter",
+     "mobile",
+-    "routing_mode",
+-    "comfort_noise",
+-    "drift_compensation",
++    "noise_suppression",
++    "post_amplifier",
++    "post_amplifier_gain",
++    "pre_amplifier",
++    "pre_amplifier_gain",
++    "transient_noise_suppression",
+     "voice_detection",
+-    "extended_filter",
+-    "intelligibility_enhancer",
+-    "experimental_agc",
+-    "agc_start_volume",
+-    "beamforming",
+-    "mic_geometry", /* documented in parse_mic_geometry() */
+-    "target_direction", /* documented in parse_mic_geometry() */
+-    "trace",
+     NULL
+ };
+ 
+-static int routing_mode_from_string(const char *rmode) {
+-    if (pa_streq(rmode, "quiet-earpiece-or-headset"))
+-        return webrtc::EchoControlMobile::kQuietEarpieceOrHeadset;
+-    else if (pa_streq(rmode, "earpiece"))
+-        return webrtc::EchoControlMobile::kEarpiece;
+-    else if (pa_streq(rmode, "loud-earpiece"))
+-        return webrtc::EchoControlMobile::kLoudEarpiece;
+-    else if (pa_streq(rmode, "speakerphone"))
+-        return webrtc::EchoControlMobile::kSpeakerphone;
+-    else if (pa_streq(rmode, "loud-speakerphone"))
+-        return webrtc::EchoControlMobile::kLoudSpeakerphone;
+-    else
+-        return -1;
+-}
+-
+-class PaWebrtcTraceCallback : public webrtc::TraceCallback {
+-    void Print(webrtc::TraceLevel level, const char *message, int length)
+-    {
+-        if (level & webrtc::kTraceError || level & webrtc::kTraceCritical)
+-            pa_log("%s", message);
+-        else if (level & webrtc::kTraceWarning)
+-            pa_log_warn("%s", message);
+-        else if (level & webrtc::kTraceInfo)
+-            pa_log_info("%s", message);
+-        else
+-            pa_log_debug("%s", message);
+-    }
+-};
+-
+ static int webrtc_volume_from_pa(pa_volume_t v)
+ {
+     return (v * WEBRTC_AGC_MAX_VOLUME) / PA_VOLUME_NORM;
+@@ -120,8 +87,7 @@ static pa_volume_t webrtc_volume_to_pa(int v)
+ 
+ static void webrtc_ec_fixate_spec(pa_sample_spec *rec_ss, pa_channel_map *rec_map,
+                                   pa_sample_spec *play_ss, pa_channel_map *play_map,
+-                                  pa_sample_spec *out_ss, pa_channel_map *out_map,
+-                                  bool beamforming)
++                                  pa_sample_spec *out_ss, pa_channel_map *out_map)
+ {
+     rec_ss->format = PA_SAMPLE_FLOAT32NE;
+     play_ss->format = PA_SAMPLE_FLOAT32NE;
+@@ -139,110 +105,22 @@ static void webrtc_ec_fixate_spec(pa_sample_spec *rec_ss, pa_channel_map *rec_ma
+     *out_ss = *rec_ss;
+     *out_map = *rec_map;
+ 
+-    if (beamforming) {
+-        /* The beamformer gives us a single channel */
+-        out_ss->channels = 1;
+-        pa_channel_map_init_mono(out_map);
+-    }
+-
+     /* Playback stream rate needs to be the same as capture */
+     play_ss->rate = rec_ss->rate;
+ }
+ 
+-static bool parse_point(const char **point, float (&f)[3]) {
+-    int ret, length;
+-
+-    ret = sscanf(*point, "%g,%g,%g%n", &f[0], &f[1], &f[2], &length);
+-    if (ret != 3)
+-        return false;
+-
+-    /* Consume the bytes we've read so far */
+-    *point += length;
+-
+-    return true;
+-}
+-
+-static bool parse_mic_geometry(const char **mic_geometry, std::vector<webrtc::Point>& geometry) {
+-    /* The microphone geometry is expressed as cartesian point form:
+-     *   x1,y1,z1,x2,y2,z2,...
+-     *
+-     * Where x1,y1,z1 is the position of the first microphone with regards to
+-     * the array's "center", x2,y2,z2 the position of the second, and so on.
+-     *
+-     * 'x' is the horizontal coordinate, with positive values being to the
+-     * right from the mic array's perspective.
+-     *
+-     * 'y' is the depth coordinate, with positive values being in front of the
+-     * array.
+-     *
+-     * 'z' is the vertical coordinate, with positive values being above the
+-     * array.
+-     *
+-     * All distances are in meters.
+-     */
+-
+-    /* The target direction is expected to be in spherical point form:
+-     *   a,e,r
+-     *
+-     * Where 'a' is the azimuth of the target point relative to the center of
+-     * the array, 'e' its elevation, and 'r' the radius.
+-     *
+-     * 0 radians azimuth is to the right of the array, and positive angles
+-     * move in a counter-clockwise direction.
+-     *
+-     * 0 radians elevation is horizontal w.r.t. the array, and positive
+-     * angles go upwards.
+-     *
+-     * radius is distance from the array center in meters.
+-     */
+-
+-    long unsigned int i;
+-    float f[3];
+-
+-    for (i = 0; i < geometry.size(); i++) {
+-        if (!parse_point(mic_geometry, f)) {
+-            pa_log("Failed to parse channel %lu in mic_geometry", i);
+-            return false;
+-        }
+-
+-        /* Except for the last point, we should have a trailing comma */
+-        if (i != geometry.size() - 1) {
+-            if (**mic_geometry != ',') {
+-                pa_log("Failed to parse channel %lu in mic_geometry", i);
+-                return false;
+-            }
+-
+-            (*mic_geometry)++;
+-        }
+-
+-        pa_log_debug("Got mic #%lu position: (%g, %g, %g)", i, f[0], f[1], f[2]);
+-
+-        geometry[i].c[0] = f[0];
+-        geometry[i].c[1] = f[1];
+-        geometry[i].c[2] = f[2];
+-    }
+-
+-    if (**mic_geometry != '\0') {
+-        pa_log("Failed to parse mic_geometry value: more parameters than expected");
+-        return false;
+-    }
+-
+-    return true;
+-}
+-
+ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+                        pa_sample_spec *rec_ss, pa_channel_map *rec_map,
+                        pa_sample_spec *play_ss, pa_channel_map *play_map,
+                        pa_sample_spec *out_ss, pa_channel_map *out_map,
+                        uint32_t *nframes, const char *args) {
+-    webrtc::AudioProcessing *apm = NULL;
++    webrtc::AudioProcessing *apm = webrtc::AudioProcessingBuilder().Create();
+     webrtc::ProcessingConfig pconfig;
+-    webrtc::Config config;
+-    bool hpf, ns, agc, dgc, mobile, cn, vad, ext_filter, intelligibility, experimental_agc, beamforming;
+-    int rm = -1, i;
+-    uint32_t agc_start_volume;
++    webrtc::AudioProcessing::Config config;
++    bool hpf, ns, tns, agc, dgc, mobile, pre_amp, vad, post_amp;
++    int i;
++    uint32_t agc_start_volume, pre_amp_gain, post_amp_gain;
+     pa_modargs *ma;
+-    bool trace = false;
+ 
+     if (!(ma = pa_modargs_new(args, valid_modargs))) {
+         pa_log("Failed to parse submodule arguments.");
+@@ -261,6 +139,12 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+         goto fail;
+     }
+ 
++    tns = DEFAULT_TRANSIENT_NOISE_SUPPRESSION;
++    if (pa_modargs_get_value_boolean(ma, "transient_noise_suppression", &tns) < 0) {
++        pa_log("Failed to parse transient_noise_suppression value");
++        goto fail;
++    }
++
+     agc = DEFAULT_ANALOG_GAIN_CONTROL;
+     if (pa_modargs_get_value_boolean(ma, "analog_gain_control", &agc) < 0) {
+         pa_log("Failed to parse analog_gain_control value");
+@@ -278,62 +162,47 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+         goto fail;
+     }
+ 
+-    mobile = DEFAULT_MOBILE;
+-    if (pa_modargs_get_value_boolean(ma, "mobile", &mobile) < 0) {
+-        pa_log("Failed to parse mobile value");
++    pre_amp = DEFAULT_PREAMP_ENABLE;
++    if (pa_modargs_get_value_boolean(ma, "pre_amplifier", &pre_amp) < 0) {
++        pa_log("Failed to parse pre_amplifier value");
+         goto fail;
+     }
+-
+-    ec->params.drift_compensation = DEFAULT_DRIFT_COMPENSATION;
+-    if (pa_modargs_get_value_boolean(ma, "drift_compensation", &ec->params.drift_compensation) < 0) {
+-        pa_log("Failed to parse drift_compensation value");
++    pre_amp_gain = DEFAULT_PREAMP_GAIN_DB;
++    if (pa_modargs_get_value_u32(ma, "pre_amplifier_gain", &pre_amp_gain) < 0) {
++        pa_log("Failed to parse pre_amplifier_gain value");
+         goto fail;
+     }
+-
+-    if (mobile) {
+-        if (ec->params.drift_compensation) {
+-            pa_log("Can't use drift_compensation in mobile mode");
+-            goto fail;
+-        }
+-
+-        if ((rm = routing_mode_from_string(pa_modargs_get_value(ma, "routing_mode", DEFAULT_ROUTING_MODE))) < 0) {
+-            pa_log("Failed to parse routing_mode value");
+-            goto fail;
+-        }
+-
+-        cn = DEFAULT_COMFORT_NOISE;
+-        if (pa_modargs_get_value_boolean(ma, "comfort_noise", &cn) < 0) {
+-            pa_log("Failed to parse cn value");
+-            goto fail;
+-        }
+-    } else {
+-        if (pa_modargs_get_value(ma, "comfort_noise", NULL) || pa_modargs_get_value(ma, "routing_mode", NULL)) {
+-            pa_log("The routing_mode and comfort_noise options are only valid with mobile=true");
+-            goto fail;
+-        }
++    if (pre_amp_gain > WEBRTC_PREAMP_GAIN_MAX_DB) {
++        pa_log("Preamp gain must not exceed %u", WEBRTC_PREAMP_GAIN_MAX_DB);
++        goto fail;
+     }
+ 
+-    vad = DEFAULT_VAD;
+-    if (pa_modargs_get_value_boolean(ma, "voice_detection", &vad) < 0) {
+-        pa_log("Failed to parse voice_detection value");
++    post_amp = DEFAULT_POSTAMP_ENABLE;
++    if (pa_modargs_get_value_boolean(ma, "post_amplifier", &post_amp) < 0) {
++        pa_log("Failed to parse post_amplifier value");
+         goto fail;
+     }
+-
+-    ext_filter = DEFAULT_EXTENDED_FILTER;
+-    if (pa_modargs_get_value_boolean(ma, "extended_filter", &ext_filter) < 0) {
+-        pa_log("Failed to parse extended_filter value");
++    post_amp_gain = DEFAULT_POSTAMP_GAIN_DB;
++    if (pa_modargs_get_value_u32(ma, "post_amplifier_gain", &post_amp_gain) < 0) {
++        pa_log("Failed to parse post_amplifier_gain value");
++        goto fail;
++    }
++    if (post_amp_gain > WEBRTC_POSTAMP_GAIN_MAX_DB) {
++        pa_log("Postamp gain must not exceed %u", WEBRTC_POSTAMP_GAIN_MAX_DB);
+         goto fail;
+     }
+ 
+-    intelligibility = DEFAULT_INTELLIGIBILITY_ENHANCER;
+-    if (pa_modargs_get_value_boolean(ma, "intelligibility_enhancer", &intelligibility) < 0) {
+-        pa_log("Failed to parse intelligibility_enhancer value");
++    mobile = DEFAULT_MOBILE;
++    if (pa_modargs_get_value_boolean(ma, "mobile", &mobile) < 0) {
++        pa_log("Failed to parse mobile value");
+         goto fail;
+     }
+ 
+-    experimental_agc = DEFAULT_EXPERIMENTAL_AGC;
+-    if (pa_modargs_get_value_boolean(ma, "experimental_agc", &experimental_agc) < 0) {
+-        pa_log("Failed to parse experimental_agc value");
++    ec->params.drift_compensation = DEFAULT_DRIFT_COMPENSATION;
++
++    vad = DEFAULT_VAD;
++    if (pa_modargs_get_value_boolean(ma, "voice_detection", &vad) < 0) {
++        pa_log("Failed to parse voice_detection value");
+         goto fail;
+     }
+ 
+@@ -348,82 +217,7 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+     }
+     ec->params.webrtc.agc_start_volume = agc_start_volume;
+ 
+-    beamforming = DEFAULT_BEAMFORMING;
+-    if (pa_modargs_get_value_boolean(ma, "beamforming", &beamforming) < 0) {
+-        pa_log("Failed to parse beamforming value");
+-        goto fail;
+-    }
+-
+-    if (ext_filter)
+-        config.Set<webrtc::ExtendedFilter>(new webrtc::ExtendedFilter(true));
+-    if (intelligibility)
+-        pa_log_warn("The intelligibility enhancer is not currently supported");
+-    if (experimental_agc)
+-        config.Set<webrtc::ExperimentalAgc>(new webrtc::ExperimentalAgc(true, ec->params.webrtc.agc_start_volume));
+-
+-    trace = DEFAULT_TRACE;
+-    if (pa_modargs_get_value_boolean(ma, "trace", &trace) < 0) {
+-        pa_log("Failed to parse trace value");
+-        goto fail;
+-    }
+-
+-    if (trace) {
+-        webrtc::Trace::CreateTrace();
+-        webrtc::Trace::set_level_filter(webrtc::kTraceAll);
+-        ec->params.webrtc.trace_callback = new PaWebrtcTraceCallback();
+-        webrtc::Trace::SetTraceCallback((PaWebrtcTraceCallback *) ec->params.webrtc.trace_callback);
+-    }
+-
+-    webrtc_ec_fixate_spec(rec_ss, rec_map, play_ss, play_map, out_ss, out_map, beamforming);
+-
+-    /* We do this after fixate because we need the capture channel count */
+-    if (beamforming) {
+-        std::vector<webrtc::Point> geometry(rec_ss->channels);
+-        webrtc::SphericalPointf direction(0.0f, 0.0f, 0.0f);
+-        const char *mic_geometry, *target_direction;
+-
+-        if (!(mic_geometry = pa_modargs_get_value(ma, "mic_geometry", NULL))) {
+-            pa_log("mic_geometry must be set if beamforming is enabled");
+-            goto fail;
+-        }
+-
+-        if (!parse_mic_geometry(&mic_geometry, geometry)) {
+-            pa_log("Failed to parse mic_geometry value");
+-            goto fail;
+-        }
+-
+-        if ((target_direction = pa_modargs_get_value(ma, "target_direction", NULL))) {
+-            float f[3];
+-
+-            if (!parse_point(&target_direction, f)) {
+-                pa_log("Failed to parse target_direction value");
+-                goto fail;
+-            }
+-
+-            if (*target_direction != '\0') {
+-                pa_log("Failed to parse target_direction value: more parameters than expected");
+-                goto fail;
+-            }
+-
+-#define IS_ZERO(f) ((f) < 0.000001 && (f) > -0.000001)
+-
+-            if (!IS_ZERO(f[1]) || !IS_ZERO(f[2])) {
+-                pa_log("The beamformer currently only supports targeting along the azimuth");
+-                goto fail;
+-            }
+-
+-            direction.s[0] = f[0];
+-            direction.s[1] = f[1];
+-            direction.s[2] = f[2];
+-        }
+-
+-        if (!target_direction)
+-            config.Set<webrtc::Beamforming>(new webrtc::Beamforming(true, geometry));
+-        else
+-            config.Set<webrtc::Beamforming>(new webrtc::Beamforming(true, geometry, direction));
+-    }
+-
+-    apm = webrtc::AudioProcessing::Create(config);
++    webrtc_ec_fixate_spec(rec_ss, rec_map, play_ss, play_map, out_ss, out_map);
+ 
+     pconfig = {
+         webrtc::StreamConfig(rec_ss->rate, rec_ss->channels, false), /* input stream */
+@@ -436,46 +230,60 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+         goto fail;
+     }
+ 
++    if (pre_amp) {
++       config.pre_amplifier.enabled = true;
++       config.pre_amplifier.fixed_gain_factor = (float)pre_amp_gain;
++    } else
++       config.pre_amplifier.enabled = false;
++
+     if (hpf)
+-        apm->high_pass_filter()->Enable(true);
+-
+-    if (!mobile) {
+-        apm->echo_cancellation()->enable_drift_compensation(ec->params.drift_compensation);
+-        apm->echo_cancellation()->Enable(true);
+-    } else {
+-        apm->echo_control_mobile()->set_routing_mode(static_cast<webrtc::EchoControlMobile::RoutingMode>(rm));
+-        apm->echo_control_mobile()->enable_comfort_noise(cn);
+-        apm->echo_control_mobile()->Enable(true);
+-    }
++        config.high_pass_filter.enabled = true;
++    else
++        config.high_pass_filter.enabled = false;
+ 
+-    if (ns) {
+-        apm->noise_suppression()->set_level(webrtc::NoiseSuppression::kHigh);
+-        apm->noise_suppression()->Enable(true);
+-    }
++    config.echo_canceller.enabled = true;
+ 
+-    if (agc || dgc) {
+-        if (mobile && rm <= webrtc::EchoControlMobile::kEarpiece) {
+-            /* Maybe this should be a knob, but we've got a lot of knobs already */
+-            apm->gain_control()->set_mode(webrtc::GainControl::kFixedDigital);
+-            ec->params.webrtc.agc = false;
+-        } else if (dgc) {
+-            apm->gain_control()->set_mode(webrtc::GainControl::kAdaptiveDigital);
+-            ec->params.webrtc.agc = false;
+-        } else {
+-            apm->gain_control()->set_mode(webrtc::GainControl::kAdaptiveAnalog);
+-            if (apm->gain_control()->set_analog_level_limits(0, WEBRTC_AGC_MAX_VOLUME) !=
+-                    webrtc::AudioProcessing::kNoError) {
+-                pa_log("Failed to initialise AGC");
+-                goto fail;
+-            }
+-            ec->params.webrtc.agc = true;
+-        }
++    if (!mobile)
++        config.echo_canceller.mobile_mode = false;
++    else
++        config.echo_canceller.mobile_mode = true;
++
++    if (ns)
++       config.noise_suppression.enabled = true;
++    else
++       config.noise_suppression.enabled = false;
+ 
+-        apm->gain_control()->Enable(true);
++    if (tns)
++       config.transient_suppression.enabled = true;
++    else
++       config.transient_suppression.enabled = false;
++
++    if (dgc) {
++        ec->params.webrtc.agc = false;
++        config.gain_controller1.enabled = true;
++        if (mobile)
++            config.gain_controller1.mode = webrtc::AudioProcessing::Config::GainController1::kFixedDigital;
++        else
++            config.gain_controller1.mode = webrtc::AudioProcessing::Config::GainController1::kAdaptiveDigital;
++    } else if (agc) {
++        ec->params.webrtc.agc = true;
++        config.gain_controller1.enabled = true;
++        config.gain_controller1.mode = webrtc::AudioProcessing::Config::GainController1::kAdaptiveAnalog;
++        config.gain_controller1.analog_level_minimum = 0;
++        config.gain_controller1.analog_level_maximum = WEBRTC_AGC_MAX_VOLUME;
+     }
+ 
+     if (vad)
+-        apm->voice_detection()->Enable(true);
++        config.voice_detection.enabled = true;
++    else
++        config.voice_detection.enabled = false;
++
++    if (post_amp) {
++        config.gain_controller2.enabled = true;
++        config.gain_controller2.fixed_digital.gain_db = (float)post_amp_gain;
++        config.gain_controller2.adaptive_digital.enabled = false;
++    } else
++        config.gain_controller2.enabled = false;
+ 
+     ec->params.webrtc.apm = apm;
+     ec->params.webrtc.rec_ss = *rec_ss;
+@@ -485,6 +293,8 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+     *nframes = ec->params.webrtc.blocksize;
+     ec->params.webrtc.first = true;
+ 
++    apm->ApplyConfig(config);
++
+     for (i = 0; i < rec_ss->channels; i++)
+         ec->params.webrtc.rec_buffer[i] = pa_xnew(float, *nframes);
+     for (i = 0; i < play_ss->channels; i++)
+@@ -496,10 +306,7 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+ fail:
+     if (ma)
+         pa_modargs_free(ma);
+-    if (ec->params.webrtc.trace_callback) {
+-        webrtc::Trace::ReturnTrace();
+-        delete ((PaWebrtcTraceCallback *) ec->params.webrtc.trace_callback);
+-    } if (apm)
++    if (apm)
+         delete apm;
+ 
+     return false;
+@@ -515,12 +322,6 @@ void pa_webrtc_ec_play(pa_echo_canceller *ec, const uint8_t *play) {
+     pa_deinterleave(play, (void **) buf, ss->channels, pa_sample_size(ss), n);
+ 
+     pa_assert_se(apm->ProcessReverseStream(buf, config, config, buf) == webrtc::AudioProcessing::kNoError);
+-
+-    /* FIXME: If ProcessReverseStream() makes any changes to the audio, such as
+-     * applying intelligibility enhancement, those changes don't have any
+-     * effect. This function is called at the source side, but the processing
+-     * would have to be done in the sink to be able to feed the processed audio
+-     * to speakers. */
+ }
+ 
+ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out) {
+@@ -538,7 +339,7 @@ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out
+     if (ec->params.webrtc.agc) {
+         pa_volume_t v = pa_echo_canceller_get_capture_volume(ec);
+         old_volume = webrtc_volume_from_pa(v);
+-        apm->gain_control()->set_stream_analog_level(old_volume);
++        apm->set_stream_analog_level(old_volume);
+     }
+ 
+     apm->set_stream_delay_ms(0);
+@@ -553,7 +354,7 @@ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out
+             ec->params.webrtc.first = false;
+             new_volume = ec->params.webrtc.agc_start_volume;
+         } else {
+-            new_volume = apm->gain_control()->stream_analog_level();
++            new_volume = apm->recommended_stream_analog_level();
+         }
+ 
+         if (old_volume != new_volume)
+@@ -564,9 +365,6 @@ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out
+ }
+ 
+ void pa_webrtc_ec_set_drift(pa_echo_canceller *ec, float drift) {
+-    webrtc::AudioProcessing *apm = (webrtc::AudioProcessing*)ec->params.webrtc.apm;
+-
+-    apm->echo_cancellation()->set_stream_drift_samples(drift * ec->params.webrtc.blocksize);
+ }
+ 
+ void pa_webrtc_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out) {
+@@ -577,11 +375,6 @@ void pa_webrtc_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *
+ void pa_webrtc_ec_done(pa_echo_canceller *ec) {
+     int i;
+ 
+-    if (ec->params.webrtc.trace_callback) {
+-        webrtc::Trace::ReturnTrace();
+-        delete ((PaWebrtcTraceCallback *) ec->params.webrtc.trace_callback);
+-    }
+-
+     if (ec->params.webrtc.apm) {
+         delete (webrtc::AudioProcessing*)ec->params.webrtc.apm;
+         ec->params.webrtc.apm = NULL;
+-- 
+GitLab
+
+
+From 84c53066c65439deb42d29bba8c6899a4fa0e318 Mon Sep 17 00:00:00 2001
+From: Arun Raghavan <arun@asymptotic.io>
+Date: Tue, 20 Oct 2020 17:29:55 -0400
+Subject: [PATCH 3/3] build-sys: Bump webrtc-audio-processing dependency
+
+The package name and versioning are changing upstream, so prepare for
+that.
+
+Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/395>
+---
+ meson.build | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index b678bb531a..a1652e4d30 100644
+--- a/meson.build
++++ b/meson.build
+@@ -728,7 +728,7 @@ if get_option('daemon')
+     cdata.set('HAVE_SOXR', 1)
+   endif
+ 
+-  webrtc_dep = dependency('webrtc-audio-processing', version : '>= 0.2', required : get_option('webrtc-aec'))
++  webrtc_dep = dependency('webrtc-audio-processing-1', version : '>= 1.0', required : get_option('webrtc-aec'))
+   if webrtc_dep.found()
+     cdata.set('HAVE_WEBRTC', 1)
+   endif
+-- 
+GitLab
+
+
diff --git a/srcpkgs/pulseaudio/template b/srcpkgs/pulseaudio/template
index 30f0a4cc23a9c..4b0dbd4cef08b 100644
--- a/srcpkgs/pulseaudio/template
+++ b/srcpkgs/pulseaudio/template
@@ -1,14 +1,15 @@
 # Template file for 'pulseaudio'
 pkgname=pulseaudio
 version=16.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Djack=enabled -Dlirc=disabled -Dhal-compat=false -Dorc=enabled
  -Dgtk=disabled -Dsystemd=disabled -Dwebrtc-aec=enabled
  -Dgsettings=enabled -Dbluez5=enabled
  -Dbluez5-ofono-headset=false -Dbluez5-native-headset=true
  -Delogind=enabled -Dudevrulesdir=/usr/lib/udev/rules.d
- -Dbashcompletiondir=/usr/share/bash-completion/completions"
+ -Dbashcompletiondir=/usr/share/bash-completion/completions
+ -Dcpp_std=c++17"
 hostmakedepends="cmake m4 gettext libtool orc-devel perl-XML-Parser pkg-config
  doxygen"
 makedepends="$(vopt_if avahi avahi-libs-devel) eudev-libudev-devel fftw-devel jack-devel

From 0acc1f557313a44054d2c0573cd7ea828c7cfcf6 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Fri, 23 Feb 2024 18:20:36 -0500
Subject: [PATCH 4/6] pipewire: revbump for webrtc-audio-processing-1.3

---
 srcpkgs/pipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index d23956e13e3a7..4848292c1d840 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'pipewire'
 pkgname=pipewire
 version=1.0.3
-revision=1
+revision=2
 build_style=meson
 configure_args="
  --auto-features=enabled

From 0a71242142e489a6cd5e4127553680181838cf09 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Fri, 23 Feb 2024 18:21:10 -0500
Subject: [PATCH 5/6] gst-plugins-bad1: revbump for webrtc-audio-processing-1.3

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 10dc49f4c151b..dc4db910c43e8 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 8602ac3ba8d73ff807cc92e9efa7b169fc586c84 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Fri, 23 Feb 2024 18:21:36 -0500
Subject: [PATCH 6/6] baresip: revbump for webrtc-audio-processing-1.3

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: webrtc-audio-processing: update to 1.3; revbump dependents
  2024-02-23 23:04 [PR PATCH] webrtc-audio-processing: update to 1.3; revbump dependents cinerea0
  2024-02-23 23:11 ` cinerea0
  2024-02-23 23:21 ` [PR PATCH] [Updated] " cinerea0
@ 2024-02-24  0:16 ` ahesford
  2024-03-07 21:26 ` [PR PATCH] [Updated] " cinerea0
  2024-03-09 20:17 ` [PR PATCH] [Merged]: " cinerea0
  4 siblings, 0 replies; 6+ messages in thread
From: ahesford @ 2024-02-24  0:16 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/48902#issuecomment-1962164717

Comment:
The only issue I foresee would be some dependant refusing to build with C++17. If all of the dependants of abseil build, we should be fine. 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PR PATCH] [Updated] webrtc-audio-processing: update to 1.3; revbump dependents
  2024-02-23 23:04 [PR PATCH] webrtc-audio-processing: update to 1.3; revbump dependents cinerea0
                   ` (2 preceding siblings ...)
  2024-02-24  0:16 ` ahesford
@ 2024-03-07 21:26 ` cinerea0
  2024-03-09 20:17 ` [PR PATCH] [Merged]: " cinerea0
  4 siblings, 0 replies; 6+ messages in thread
From: cinerea0 @ 2024-03-07 21:26 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 532 bytes --]

There is an updated pull request by cinerea0 against master on the void-packages repository

https://github.com/cinerea0/void-packages webrtc
https://github.com/void-linux/void-packages/pull/48902

webrtc-audio-processing: update to 1.3; revbump dependents
#### Testing the changes
- I tested the changes in this PR: **YES**

---

@ahesford Are there any potential negative consequences of forcing abseil to use C++17 you can think of?

A patch file from https://github.com/void-linux/void-packages/pull/48902.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-webrtc-48902.patch --]
[-- Type: text/x-diff, Size: 43939 bytes --]

From 3f5c3ad879db49adb7e5c2573d992da3a965c5a0 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Thu, 7 Mar 2024 10:33:25 -0500
Subject: [PATCH 1/6] abseil-cpp: use C++17

---
 srcpkgs/abseil-cpp/template | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/abseil-cpp/template b/srcpkgs/abseil-cpp/template
index 7909b5e19e0aa9..b19c444a1fe4f1 100644
--- a/srcpkgs/abseil-cpp/template
+++ b/srcpkgs/abseil-cpp/template
@@ -1,9 +1,10 @@
 # Template file for 'abseil-cpp'
 pkgname=abseil-cpp
 version=20240116.1
-revision=1
+revision=2
 build_style=cmake
-configure_args="-DBUILD_SHARED_LIBS=ON -DABSL_PROPAGATE_CXX_STD=ON"
+configure_args="-DBUILD_SHARED_LIBS=ON -DABSL_PROPAGATE_CXX_STD=ON
+ -DCMAKE_CXX_STANDARD=17"
 hostmakedepends="pkg-config"
 short_desc="Abseil common libraries"
 maintainer="Andrew J. Hesford <ajh@sideband.org>"

From 0938f03c8be7218d971b5712ff86ac20292a11f9 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Thu, 7 Mar 2024 10:33:52 -0500
Subject: [PATCH 2/6] webrtc-audio-processing: update to 1.3

---
 common/shlibs                                 |   3 +-
 ...yte-order-and-pointer-size-detection.patch |  24 ++--
 .../patches/i686-no-sse.patch                 |  15 +++
 .../patches/mips.patch                        | 113 ------------------
 .../patches/musl.patch                        |  51 +++++---
 srcpkgs/webrtc-audio-processing/template      |  31 ++---
 6 files changed, 74 insertions(+), 163 deletions(-)
 create mode 100644 srcpkgs/webrtc-audio-processing/patches/i686-no-sse.patch
 delete mode 100644 srcpkgs/webrtc-audio-processing/patches/mips.patch

diff --git a/common/shlibs b/common/shlibs
index 9bcf0c5756b8fd..ea92fa075f71f5 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1057,7 +1057,8 @@ libiptcdata.so.0 libiptcdata-1.0.4_1
 libutempter.so.0 libutempter-1.1.5_1
 libxatracker.so.2 libxatracker-10.0.0_2
 libtumbler-1.so.0 tumbler-4.9.2_1
-libwebrtc_audio_processing.so.1 webrtc-audio-processing-0.3_1
+libwebrtc-audio-coding-1.so.3 webrtc-audio-processing-1.3_1
+libwebrtc-audio-processing-1.so.3 webrtc-audio-processing-1.3_1
 libcupsmime.so.1 libcups-1.5.3_1
 libcupsppdc.so.1 libcups-1.5.3_1
 libcupscgi.so.1 libcups-1.5.3_1
diff --git a/srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.patch b/srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.patch
index 1338784e69ef88..28f1dbdcd86844 100644
--- a/srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.patch
+++ b/srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.patch
@@ -1,20 +1,20 @@
-From: Than <than@redhat.com>
-Date: Wed, 8 Jun 2016 19:10:08 -0400
-Subject: Add generic byte order and pointer size detection
+Taken from https://gitweb.gentoo.org/repo/gentoo.git/tree/media-libs/webrtc-audio-processing/files/webrtc-audio-processing-1.3-Add-generic-byte-order-and-pointer-size-detection.patch?id=29cd0e622b574df6adff5704ab4e220709619767
+https://bugs.gentoo.org/917493
+https://sources.debian.org/src/webrtc-audio-processing/1.0-0.2/debian/patches/Add-generic-byte-order-and-pointer-size-detection.patch/
 
+Description: Add generic byte order and pointer size detection
+Author: Than <than@redhat.com>
+Origin: https://bugs.freedesktop.org/show_bug.cgi?id=95738#c4
+Last-Update: 2022-02-01
 ---
- webrtc/typedefs.h | 14 +++++++++++++-
- 1 file changed, 13 insertions(+), 1 deletion(-)
-
-diff --git a/webrtc/typedefs.h b/webrtc/typedefs.h
-index d875490..dc074f1 100644
---- a/webrtc/typedefs.h
-+++ b/webrtc/typedefs.h
-@@ -48,7 +48,19 @@
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/webrtc/rtc_base/system/arch.h
++++ b/webrtc/rtc_base/system/arch.h
+@@ -58,7 +58,19 @@
  #define WEBRTC_ARCH_32_BITS
  #define WEBRTC_ARCH_LITTLE_ENDIAN
  #else
--#error Please add support for your architecture in typedefs.h
+-#error Please add support for your architecture in rtc_base/system/arch.h
 +/* instead of failing, use typical unix defines... */
 +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 +#define WEBRTC_ARCH_LITTLE_ENDIAN
diff --git a/srcpkgs/webrtc-audio-processing/patches/i686-no-sse.patch b/srcpkgs/webrtc-audio-processing/patches/i686-no-sse.patch
new file mode 100644
index 00000000000000..de145af2083122
--- /dev/null
+++ b/srcpkgs/webrtc-audio-processing/patches/i686-no-sse.patch
@@ -0,0 +1,15 @@
+Taken from https://gitweb.gentoo.org/repo/gentoo.git/tree/media-libs/webrtc-audio-processing/files/webrtc-audio-processing-1.3-x86-no-sse.patch?id=29cd0e622b574df6adff5704ab4e220709619767
+https://bugs.gentoo.org/921140
+https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/issues/5
+--- a/webrtc/rtc_base/system/arch.h
++++ b/webrtc/rtc_base/system/arch.h
+@@ -34,7 +34,7 @@
+ #else
+ #define WEBRTC_ARCH_32_BITS
+ #endif
+-#elif defined(_M_IX86) || defined(__i386__)
++#elif defined(__SSE__) && (defined(_M_IX86) || defined(__i386__))
+ #define WEBRTC_ARCH_X86_FAMILY
+ #define WEBRTC_ARCH_X86
+ #define WEBRTC_ARCH_32_BITS
+
diff --git a/srcpkgs/webrtc-audio-processing/patches/mips.patch b/srcpkgs/webrtc-audio-processing/patches/mips.patch
deleted file mode 100644
index c99aaf39220829..00000000000000
--- a/srcpkgs/webrtc-audio-processing/patches/mips.patch
+++ /dev/null
@@ -1,113 +0,0 @@
---- webrtc-audio-processing-0.3_3/configure.ac	2017-11-22 20:26:54.207009881 +0100
-+++ webrtc-audio-processing-0.3_3/configure.ac	2017-11-22 20:37:57.472996521 +0100
-@@ -90,10 +90,14 @@
- 	[HAVE_NEON=1; ARCH_CFLAGS="${ARCH_CFLAGS} -DWEBRTC_HAS_NEON -DWEBRTC_ARCH_ARM64"])
- AC_CHECK_DECLS([__i386__], [HAVE_X86=1])
- AC_CHECK_DECLS([__x86_64__], [HAVE_X86=1])
-+AC_CHECK_DECLS([__MIPSEB__], [HAVE_MIPSEB=1])
-+AC_CHECK_DECLS([__MIPSEL__], [HAVE_MIPSEL=1])
- 
- AM_CONDITIONAL(HAVE_X86, [test "x${HAVE_X86}" = "x1"])
- AM_CONDITIONAL(HAVE_ARM, [test "x${HAVE_ARM}" = "x1"])
- AM_CONDITIONAL(HAVE_ARMV7, [test "x${HAVE_ARMV7}" = "x1"])
-+AM_CONDITIONAL(HAVE_MIPSEB, [test "x${HAVE_MIPSEB}" = "x1"])
-+AM_CONDITIONAL(HAVE_MIPSEL, [test "x${HAVE_MIPSEL}" = "x1"])
- 
- # Borrowed from pulseaudio's configure.ac
- AC_ARG_ENABLE([neon],
---- webrtc-audio-processing-0.3_3/webrtc/typedefs.h	2015-10-15 12:48:25.000000000 +0200
-+++ webrtc-audio-processing-0.3_3/webrtc/typedefs.h	2017-11-22 20:39:20.800994843 +0100
-@@ -47,6 +47,10 @@
- #elif defined(__pnacl__)
- #define WEBRTC_ARCH_32_BITS
- #define WEBRTC_ARCH_LITTLE_ENDIAN
-+#elif defined(__MIPSEL__)
-+#define WEBRTC_ARCH_LITTLE_ENDIAN
-+#elif defined(__MIPSEB__)
-+#define WEBRTC_ARCH_BIG_ENDIAN
- #else
- #error Please add support for your architecture in typedefs.h
- #endif
---- webrtc-audio-processing-0.3/webrtc/common_audio/wav_file.cc	2015-11-19 13:41:44.000000000 +0100
-+++ webrtc-audio-processing-0.3/webrtc/common_audio/wav_file.cc	2017-11-22 21:01:46.554967737 +0100
-@@ -64,9 +64,6 @@
- }
- 
- size_t WavReader::ReadSamples(size_t num_samples, int16_t* samples) {
--#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
--#error "Need to convert samples to big-endian when reading from WAV file"
--#endif
-   // There could be metadata after the audio; ensure we don't read it.
-   num_samples = std::min(rtc::checked_cast<uint32_t>(num_samples),
-                          num_samples_remaining_);
-@@ -76,6 +73,12 @@
-   RTC_CHECK(read == num_samples || feof(file_handle_));
-   RTC_CHECK_LE(read, num_samples_remaining_);
-   num_samples_remaining_ -= rtc::checked_cast<uint32_t>(read);
-+#ifdef WEBRTC_ARCH_BIG_ENDIAN
-+  for (size_t i = 0; i < read; i++) {
-+    uint16_t s = static_cast<uint16_t>(samples[i]);
-+    samples[i] = static_cast<int16_t>((s >> 8) | (s << 8));
-+  }
-+#endif
-   return read;
- }
- 
-@@ -119,11 +122,20 @@
- }
- 
- void WavWriter::WriteSamples(const int16_t* samples, size_t num_samples) {
--#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
--#error "Need to convert samples to little-endian when writing to WAV file"
--#endif
-+#ifdef WEBRTC_ARCH_LITTLE_ENDIAN
-   const size_t written =
-       fwrite(samples, sizeof(*samples), num_samples, file_handle_);
-+#else
-+  size_t written = 0;
-+  for (size_t i = 0; i < num_samples; i++) {
-+    uint16_t s = static_cast<uint16_t>(samples[i]);
-+    s = static_cast<int16_t>((s<<8) | (s>>8));
-+    size_t size = fwrite(&s, sizeof(s), 1, file_handle_);
-+    if (size < 1)
-+      break;
-+    written += size;
-+  }
-+#endif
-   RTC_CHECK_EQ(num_samples, written);
-   num_samples_ += static_cast<uint32_t>(written);
-   RTC_CHECK(written <= std::numeric_limits<uint32_t>::max() ||
---- webrtc-audio-processing-0.3/webrtc/common_audio/wav_header.cc	2015-10-15 12:48:44.000000000 +0200
-+++ webrtc-audio-processing-0.3/webrtc/common_audio/wav_header.cc	2017-11-22 21:11:36.291955859 +0100
-@@ -129,7 +129,30 @@
-   return std::string(reinterpret_cast<char*>(&x), 4);
- }
- #else
--#error "Write be-to-le conversion functions"
-+static inline void WriteLE16(uint16_t* f, uint16_t x) { *f = (x >> 8) | (x << 8); }
-+static inline void WriteLE32(uint32_t* f, uint32_t x) {
-+  *f = ((x & 0xff000000) >> 24) |
-+       ((x & 0x00ff0000) >>  8) |
-+       ((x & 0x0000ff00) <<  8) |
-+       ((x & 0x000000ff) << 24);
-+}
-+static inline void WriteFourCC(uint32_t* f, char a, char b, char c, char d) {
-+  *f = (static_cast<uint32_t>(a) << 24)
-+      | (static_cast<uint32_t>(b) << 16)
-+      | (static_cast<uint32_t>(c) << 8)
-+      | static_cast<uint32_t>(d);
-+}
-+static inline uint16_t ReadLE16(uint16_t x) { return (x >> 8) | (x << 8); }
-+static inline uint32_t ReadLE32(uint32_t x) {
-+  return ((x << 24) & 0xff000000) |
-+         ((x <<  8) & 0x00ff0000) |
-+         ((x >>  8) & 0x0000ff00) |
-+         ((x >> 24) & 0x000000ff);
-+}
-+static inline std::string ReadFourCC(uint32_t x) {
-+  uint32_t s = ReadLE32(x);
-+  return std::string(reinterpret_cast<char*>(&s), 4);
-+}
- #endif
- 
- static inline uint32_t RiffChunkSize(uint32_t bytes_in_payload) {
diff --git a/srcpkgs/webrtc-audio-processing/patches/musl.patch b/srcpkgs/webrtc-audio-processing/patches/musl.patch
index adca79b6b74869..335a449686bf65 100644
--- a/srcpkgs/webrtc-audio-processing/patches/musl.patch
+++ b/srcpkgs/webrtc-audio-processing/patches/musl.patch
@@ -1,20 +1,33 @@
---- a/webrtc/base/checks.cc.orig	2016-06-25 07:47:34.099515548 +0200
-+++ b/webrtc/base/checks.cc	2016-06-25 07:48:28.554122463 +0200
-@@ -16,7 +16,7 @@
- #include <cstdio>
- #include <cstdlib>
+https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/merge_requests/37
+(see also https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/merge_requests/38)
+
+From de1b9c444df1ed66d72a4ab3d0e4dd2151037934 Mon Sep 17 00:00:00 2001
+From: Markus Volk <f_l_k@t-online.de>
+Date: Thu, 14 Sep 2023 16:12:32 +0200
+Subject: [PATCH] file_wrapper.h: add missing include for musl
+
+this fixes:
+| In file included from ../webrtc-audio-processing-1.3/webrtc/rtc_base/system/file_wrapper.cc:11:
+| ../webrtc-audio-processing-1.3/webrtc/rtc_base/system/file_wrapper.h:86:21: error: 'int64_t' has not been declared
+
+if built with musl libc
+
+Signed-off-by: Markus Volk <f_l_k@t-online.de>
+---
+ webrtc/rtc_base/system/file_wrapper.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/webrtc/rtc_base/system/file_wrapper.h b/webrtc/rtc_base/system/file_wrapper.h
+index 42c463c..c34d366 100644
+--- a/webrtc/rtc_base/system/file_wrapper.h
++++ b/webrtc/rtc_base/system/file_wrapper.h
+@@ -13,6 +13,7 @@
  
--#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
-+#if defined(__GLIBC__) && defined(__GLIBCXX__)
- #include <cxxabi.h>
- #include <execinfo.h>
- #endif
-@@ -55,7 +55,7 @@ void PrintError(const char* format, ...)
- // to get usable symbols on Linux. This is copied from V8. Chromium has a more
- // advanced stace trace system; also more difficult to copy.
- void DumpBacktrace() {
--#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
-+#if defined(__GLIBC__) && defined(__GLIBCXX__)
-   void* trace[100];
-   int size = backtrace(trace, sizeof(trace) / sizeof(*trace));
-   char** symbols = backtrace_symbols(trace, size);
+ #include <stddef.h>
+ #include <stdio.h>
++#include <cstdint>
+ 
+ #include <string>
+ 
+-- 
+GitLab
diff --git a/srcpkgs/webrtc-audio-processing/template b/srcpkgs/webrtc-audio-processing/template
index 30a420b28f5753..e5277d17e0b9e3 100644
--- a/srcpkgs/webrtc-audio-processing/template
+++ b/srcpkgs/webrtc-audio-processing/template
@@ -1,38 +1,33 @@
 # Template file for 'webrtc-audio-processing'
 pkgname=webrtc-audio-processing
-version=0.3.1
+version=1.3
 revision=1
-build_style=gnu-configure
-hostmakedepends="automake libtool"
+build_style=meson
+hostmakedepends="pkg-config"
+makedepends="abseil-cpp-devel"
 short_desc="AudioProcessing library based on Google's implementation of WebRTC"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="BSD-3-Clause"
-homepage="http://freedesktop.org/software/pulseaudio/webrtc-audio-processing"
-distfiles="${homepage}/${pkgname}-${version}.tar.xz"
-checksum=a0fdd938fd85272d67e81572c5a4d9e200a0c104753cb3c209ded175ce3c5dbf
+homepage="https://freedesktop.org/software/pulseaudio/webrtc-audio-processing"
+distfiles="${FREEDESKTOP_SITE}/pulseaudio/webrtc-audio-processing/webrtc-audio-processing-${version}.tar.gz"
+checksum=95552fc17faa0202133707bbb3727e8c2cf64d4266fe31bfdb2298d769c1db75
 
-case "$XBPS_TARGET_MACHINE" in
-	# Disable neon for the arm* architectures
-	arm*) configure_args+=" --enable-neon=no" ;;
-esac
-
-pre_configure() {
-	# Remove failing statement PKG_CHECK_MODULE(GNUSTL, gnustl)
-	sed -i configure.ac -e'/if test "x$with_gnustl" != "xno"; then/,+2d'
-	autoreconf -fi
-}
+# Upstream issue: https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/issues/5
+if [ "$XBPS_MACHINE" = "i686" ]; then
+	CXXFLAGS="-DPFFFT_SIMD_DISABLE=1"
+	CFLAGS="-DPFFFT_SIMD_DISABLE=1"
+fi
 
 post_install() {
 	vlicense COPYING
 }
 
 webrtc-audio-processing-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision}"
+	depends="${sourcepkg}>=${version}_${revision} abseil-cpp-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig
-		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }

From e2e058c2ff885a7ad89e56f19f1c2788a4aa13d3 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Thu, 7 Mar 2024 10:34:29 -0500
Subject: [PATCH 3/6] pulseaudio: revbump for webrtc-audio-processing-1.3

---
 .../patches/webrtc-audio-processing-1.patch   | 676 ++++++++++++++++++
 srcpkgs/pulseaudio/template                   |   5 +-
 2 files changed, 679 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/pulseaudio/patches/webrtc-audio-processing-1.patch

diff --git a/srcpkgs/pulseaudio/patches/webrtc-audio-processing-1.patch b/srcpkgs/pulseaudio/patches/webrtc-audio-processing-1.patch
new file mode 100644
index 00000000000000..12816416f04944
--- /dev/null
+++ b/srcpkgs/pulseaudio/patches/webrtc-audio-processing-1.patch
@@ -0,0 +1,676 @@
+# This can be dropped with PulseAudio 17
+
+From b16b107171f24f791f79c20730cf6eb3ad469944 Mon Sep 17 00:00:00 2001
+From: Arun Raghavan <arun@asymptotic.io>
+Date: Tue, 20 Oct 2020 16:18:57 -0400
+Subject: [PATCH 1/3] echo-cancel-test: Drop references to internal message
+ queue
+
+We don't actually initialise or use it in the test, and this just causes
+a crash at the end.
+
+Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/395>
+---
+ src/modules/echo-cancel/module-echo-cancel.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
+index 3d63ea6084..ae1bf9d684 100644
+--- a/src/modules/echo-cancel/module-echo-cancel.c
++++ b/src/modules/echo-cancel/module-echo-cancel.c
+@@ -2370,8 +2370,6 @@ int main(int argc, char* argv[]) {
+     }
+ 
+     u.ec->done(u.ec);
+-    u.ec->msg->dead = true;
+-    pa_echo_canceller_msg_unref(u.ec->msg);
+ 
+ out:
+     if (u.captured_file)
+-- 
+GitLab
+
+
+From 22bbb5b3ba0d28d630b10944fe19d7f9eee3a00f Mon Sep 17 00:00:00 2001
+From: Eero Nurkkala <eero.nurkkala@offcode.fi>
+Date: Tue, 20 Oct 2020 16:20:23 -0400
+Subject: [PATCH 2/3] echo-cancel: add webrtc AEC3 support
+
+Drop a number of now unsupported features, and add new parameters for
+pre-/post-amplification.
+
+Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/395>
+---
+ src/modules/echo-cancel/webrtc.cc | 433 ++++++++----------------------
+ 1 file changed, 113 insertions(+), 320 deletions(-)
+
+diff --git a/src/modules/echo-cancel/webrtc.cc b/src/modules/echo-cancel/webrtc.cc
+index 56daab0fd0..ed4bb65a56 100644
+--- a/src/modules/echo-cancel/webrtc.cc
++++ b/src/modules/echo-cancel/webrtc.cc
+@@ -3,8 +3,8 @@
+ 
+     Copyright 2011 Collabora Ltd.
+               2015 Aldebaran SoftBank Group
+-
+-    Contributor: Arun Raghavan <mail@arunraghavan.net>
++              2020 Arun Raghavan <arun@asymptotic.io>
++              2020 Eero Nurkkala <eero.nurkkala@offcode.fi>
+ 
+     PulseAudio is free software; you can redistribute it and/or modify
+     it under the terms of the GNU Lesser General Public License as published
+@@ -34,80 +34,47 @@ PA_C_DECL_BEGIN
+ #include "echo-cancel.h"
+ PA_C_DECL_END
+ 
+-#include <webrtc/modules/audio_processing/include/audio_processing.h>
+-#include <webrtc/modules/interface/module_common_types.h>
+-#include <webrtc/system_wrappers/include/trace.h>
++#define WEBRTC_APM_DEBUG_DUMP 0
++
++#include <modules/audio_processing/include/audio_processing.h>
+ 
+ #define BLOCK_SIZE_US 10000
+ 
+ #define DEFAULT_HIGH_PASS_FILTER true
+ #define DEFAULT_NOISE_SUPPRESSION true
++#define DEFAULT_TRANSIENT_NOISE_SUPPRESSION true
+ #define DEFAULT_ANALOG_GAIN_CONTROL true
+ #define DEFAULT_DIGITAL_GAIN_CONTROL false
+ #define DEFAULT_MOBILE false
+-#define DEFAULT_ROUTING_MODE "speakerphone"
+ #define DEFAULT_COMFORT_NOISE true
+ #define DEFAULT_DRIFT_COMPENSATION false
+-#define DEFAULT_VAD true
+-#define DEFAULT_EXTENDED_FILTER false
+-#define DEFAULT_INTELLIGIBILITY_ENHANCER false
+-#define DEFAULT_EXPERIMENTAL_AGC false
++#define DEFAULT_VAD false
+ #define DEFAULT_AGC_START_VOLUME 85
+-#define DEFAULT_BEAMFORMING false
+-#define DEFAULT_TRACE false
++#define DEFAULT_POSTAMP_ENABLE false
++#define DEFAULT_POSTAMP_GAIN_DB 0
++#define DEFAULT_PREAMP_ENABLE false
++#define DEFAULT_PREAMP_GAIN_DB 0
+ 
+ #define WEBRTC_AGC_MAX_VOLUME 255
++#define WEBRTC_POSTAMP_GAIN_MAX_DB 90
++#define WEBRTC_PREAMP_GAIN_MAX_DB 90
+ 
+ static const char* const valid_modargs[] = {
+-    "high_pass_filter",
+-    "noise_suppression",
++    "agc_start_volume",
+     "analog_gain_control",
+     "digital_gain_control",
++    "high_pass_filter",
+     "mobile",
+-    "routing_mode",
+-    "comfort_noise",
+-    "drift_compensation",
++    "noise_suppression",
++    "post_amplifier",
++    "post_amplifier_gain",
++    "pre_amplifier",
++    "pre_amplifier_gain",
++    "transient_noise_suppression",
+     "voice_detection",
+-    "extended_filter",
+-    "intelligibility_enhancer",
+-    "experimental_agc",
+-    "agc_start_volume",
+-    "beamforming",
+-    "mic_geometry", /* documented in parse_mic_geometry() */
+-    "target_direction", /* documented in parse_mic_geometry() */
+-    "trace",
+     NULL
+ };
+ 
+-static int routing_mode_from_string(const char *rmode) {
+-    if (pa_streq(rmode, "quiet-earpiece-or-headset"))
+-        return webrtc::EchoControlMobile::kQuietEarpieceOrHeadset;
+-    else if (pa_streq(rmode, "earpiece"))
+-        return webrtc::EchoControlMobile::kEarpiece;
+-    else if (pa_streq(rmode, "loud-earpiece"))
+-        return webrtc::EchoControlMobile::kLoudEarpiece;
+-    else if (pa_streq(rmode, "speakerphone"))
+-        return webrtc::EchoControlMobile::kSpeakerphone;
+-    else if (pa_streq(rmode, "loud-speakerphone"))
+-        return webrtc::EchoControlMobile::kLoudSpeakerphone;
+-    else
+-        return -1;
+-}
+-
+-class PaWebrtcTraceCallback : public webrtc::TraceCallback {
+-    void Print(webrtc::TraceLevel level, const char *message, int length)
+-    {
+-        if (level & webrtc::kTraceError || level & webrtc::kTraceCritical)
+-            pa_log("%s", message);
+-        else if (level & webrtc::kTraceWarning)
+-            pa_log_warn("%s", message);
+-        else if (level & webrtc::kTraceInfo)
+-            pa_log_info("%s", message);
+-        else
+-            pa_log_debug("%s", message);
+-    }
+-};
+-
+ static int webrtc_volume_from_pa(pa_volume_t v)
+ {
+     return (v * WEBRTC_AGC_MAX_VOLUME) / PA_VOLUME_NORM;
+@@ -120,8 +87,7 @@ static pa_volume_t webrtc_volume_to_pa(int v)
+ 
+ static void webrtc_ec_fixate_spec(pa_sample_spec *rec_ss, pa_channel_map *rec_map,
+                                   pa_sample_spec *play_ss, pa_channel_map *play_map,
+-                                  pa_sample_spec *out_ss, pa_channel_map *out_map,
+-                                  bool beamforming)
++                                  pa_sample_spec *out_ss, pa_channel_map *out_map)
+ {
+     rec_ss->format = PA_SAMPLE_FLOAT32NE;
+     play_ss->format = PA_SAMPLE_FLOAT32NE;
+@@ -139,110 +105,22 @@ static void webrtc_ec_fixate_spec(pa_sample_spec *rec_ss, pa_channel_map *rec_ma
+     *out_ss = *rec_ss;
+     *out_map = *rec_map;
+ 
+-    if (beamforming) {
+-        /* The beamformer gives us a single channel */
+-        out_ss->channels = 1;
+-        pa_channel_map_init_mono(out_map);
+-    }
+-
+     /* Playback stream rate needs to be the same as capture */
+     play_ss->rate = rec_ss->rate;
+ }
+ 
+-static bool parse_point(const char **point, float (&f)[3]) {
+-    int ret, length;
+-
+-    ret = sscanf(*point, "%g,%g,%g%n", &f[0], &f[1], &f[2], &length);
+-    if (ret != 3)
+-        return false;
+-
+-    /* Consume the bytes we've read so far */
+-    *point += length;
+-
+-    return true;
+-}
+-
+-static bool parse_mic_geometry(const char **mic_geometry, std::vector<webrtc::Point>& geometry) {
+-    /* The microphone geometry is expressed as cartesian point form:
+-     *   x1,y1,z1,x2,y2,z2,...
+-     *
+-     * Where x1,y1,z1 is the position of the first microphone with regards to
+-     * the array's "center", x2,y2,z2 the position of the second, and so on.
+-     *
+-     * 'x' is the horizontal coordinate, with positive values being to the
+-     * right from the mic array's perspective.
+-     *
+-     * 'y' is the depth coordinate, with positive values being in front of the
+-     * array.
+-     *
+-     * 'z' is the vertical coordinate, with positive values being above the
+-     * array.
+-     *
+-     * All distances are in meters.
+-     */
+-
+-    /* The target direction is expected to be in spherical point form:
+-     *   a,e,r
+-     *
+-     * Where 'a' is the azimuth of the target point relative to the center of
+-     * the array, 'e' its elevation, and 'r' the radius.
+-     *
+-     * 0 radians azimuth is to the right of the array, and positive angles
+-     * move in a counter-clockwise direction.
+-     *
+-     * 0 radians elevation is horizontal w.r.t. the array, and positive
+-     * angles go upwards.
+-     *
+-     * radius is distance from the array center in meters.
+-     */
+-
+-    long unsigned int i;
+-    float f[3];
+-
+-    for (i = 0; i < geometry.size(); i++) {
+-        if (!parse_point(mic_geometry, f)) {
+-            pa_log("Failed to parse channel %lu in mic_geometry", i);
+-            return false;
+-        }
+-
+-        /* Except for the last point, we should have a trailing comma */
+-        if (i != geometry.size() - 1) {
+-            if (**mic_geometry != ',') {
+-                pa_log("Failed to parse channel %lu in mic_geometry", i);
+-                return false;
+-            }
+-
+-            (*mic_geometry)++;
+-        }
+-
+-        pa_log_debug("Got mic #%lu position: (%g, %g, %g)", i, f[0], f[1], f[2]);
+-
+-        geometry[i].c[0] = f[0];
+-        geometry[i].c[1] = f[1];
+-        geometry[i].c[2] = f[2];
+-    }
+-
+-    if (**mic_geometry != '\0') {
+-        pa_log("Failed to parse mic_geometry value: more parameters than expected");
+-        return false;
+-    }
+-
+-    return true;
+-}
+-
+ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+                        pa_sample_spec *rec_ss, pa_channel_map *rec_map,
+                        pa_sample_spec *play_ss, pa_channel_map *play_map,
+                        pa_sample_spec *out_ss, pa_channel_map *out_map,
+                        uint32_t *nframes, const char *args) {
+-    webrtc::AudioProcessing *apm = NULL;
++    webrtc::AudioProcessing *apm = webrtc::AudioProcessingBuilder().Create();
+     webrtc::ProcessingConfig pconfig;
+-    webrtc::Config config;
+-    bool hpf, ns, agc, dgc, mobile, cn, vad, ext_filter, intelligibility, experimental_agc, beamforming;
+-    int rm = -1, i;
+-    uint32_t agc_start_volume;
++    webrtc::AudioProcessing::Config config;
++    bool hpf, ns, tns, agc, dgc, mobile, pre_amp, vad, post_amp;
++    int i;
++    uint32_t agc_start_volume, pre_amp_gain, post_amp_gain;
+     pa_modargs *ma;
+-    bool trace = false;
+ 
+     if (!(ma = pa_modargs_new(args, valid_modargs))) {
+         pa_log("Failed to parse submodule arguments.");
+@@ -261,6 +139,12 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+         goto fail;
+     }
+ 
++    tns = DEFAULT_TRANSIENT_NOISE_SUPPRESSION;
++    if (pa_modargs_get_value_boolean(ma, "transient_noise_suppression", &tns) < 0) {
++        pa_log("Failed to parse transient_noise_suppression value");
++        goto fail;
++    }
++
+     agc = DEFAULT_ANALOG_GAIN_CONTROL;
+     if (pa_modargs_get_value_boolean(ma, "analog_gain_control", &agc) < 0) {
+         pa_log("Failed to parse analog_gain_control value");
+@@ -278,62 +162,47 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+         goto fail;
+     }
+ 
+-    mobile = DEFAULT_MOBILE;
+-    if (pa_modargs_get_value_boolean(ma, "mobile", &mobile) < 0) {
+-        pa_log("Failed to parse mobile value");
++    pre_amp = DEFAULT_PREAMP_ENABLE;
++    if (pa_modargs_get_value_boolean(ma, "pre_amplifier", &pre_amp) < 0) {
++        pa_log("Failed to parse pre_amplifier value");
+         goto fail;
+     }
+-
+-    ec->params.drift_compensation = DEFAULT_DRIFT_COMPENSATION;
+-    if (pa_modargs_get_value_boolean(ma, "drift_compensation", &ec->params.drift_compensation) < 0) {
+-        pa_log("Failed to parse drift_compensation value");
++    pre_amp_gain = DEFAULT_PREAMP_GAIN_DB;
++    if (pa_modargs_get_value_u32(ma, "pre_amplifier_gain", &pre_amp_gain) < 0) {
++        pa_log("Failed to parse pre_amplifier_gain value");
+         goto fail;
+     }
+-
+-    if (mobile) {
+-        if (ec->params.drift_compensation) {
+-            pa_log("Can't use drift_compensation in mobile mode");
+-            goto fail;
+-        }
+-
+-        if ((rm = routing_mode_from_string(pa_modargs_get_value(ma, "routing_mode", DEFAULT_ROUTING_MODE))) < 0) {
+-            pa_log("Failed to parse routing_mode value");
+-            goto fail;
+-        }
+-
+-        cn = DEFAULT_COMFORT_NOISE;
+-        if (pa_modargs_get_value_boolean(ma, "comfort_noise", &cn) < 0) {
+-            pa_log("Failed to parse cn value");
+-            goto fail;
+-        }
+-    } else {
+-        if (pa_modargs_get_value(ma, "comfort_noise", NULL) || pa_modargs_get_value(ma, "routing_mode", NULL)) {
+-            pa_log("The routing_mode and comfort_noise options are only valid with mobile=true");
+-            goto fail;
+-        }
++    if (pre_amp_gain > WEBRTC_PREAMP_GAIN_MAX_DB) {
++        pa_log("Preamp gain must not exceed %u", WEBRTC_PREAMP_GAIN_MAX_DB);
++        goto fail;
+     }
+ 
+-    vad = DEFAULT_VAD;
+-    if (pa_modargs_get_value_boolean(ma, "voice_detection", &vad) < 0) {
+-        pa_log("Failed to parse voice_detection value");
++    post_amp = DEFAULT_POSTAMP_ENABLE;
++    if (pa_modargs_get_value_boolean(ma, "post_amplifier", &post_amp) < 0) {
++        pa_log("Failed to parse post_amplifier value");
+         goto fail;
+     }
+-
+-    ext_filter = DEFAULT_EXTENDED_FILTER;
+-    if (pa_modargs_get_value_boolean(ma, "extended_filter", &ext_filter) < 0) {
+-        pa_log("Failed to parse extended_filter value");
++    post_amp_gain = DEFAULT_POSTAMP_GAIN_DB;
++    if (pa_modargs_get_value_u32(ma, "post_amplifier_gain", &post_amp_gain) < 0) {
++        pa_log("Failed to parse post_amplifier_gain value");
++        goto fail;
++    }
++    if (post_amp_gain > WEBRTC_POSTAMP_GAIN_MAX_DB) {
++        pa_log("Postamp gain must not exceed %u", WEBRTC_POSTAMP_GAIN_MAX_DB);
+         goto fail;
+     }
+ 
+-    intelligibility = DEFAULT_INTELLIGIBILITY_ENHANCER;
+-    if (pa_modargs_get_value_boolean(ma, "intelligibility_enhancer", &intelligibility) < 0) {
+-        pa_log("Failed to parse intelligibility_enhancer value");
++    mobile = DEFAULT_MOBILE;
++    if (pa_modargs_get_value_boolean(ma, "mobile", &mobile) < 0) {
++        pa_log("Failed to parse mobile value");
+         goto fail;
+     }
+ 
+-    experimental_agc = DEFAULT_EXPERIMENTAL_AGC;
+-    if (pa_modargs_get_value_boolean(ma, "experimental_agc", &experimental_agc) < 0) {
+-        pa_log("Failed to parse experimental_agc value");
++    ec->params.drift_compensation = DEFAULT_DRIFT_COMPENSATION;
++
++    vad = DEFAULT_VAD;
++    if (pa_modargs_get_value_boolean(ma, "voice_detection", &vad) < 0) {
++        pa_log("Failed to parse voice_detection value");
+         goto fail;
+     }
+ 
+@@ -348,82 +217,7 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+     }
+     ec->params.webrtc.agc_start_volume = agc_start_volume;
+ 
+-    beamforming = DEFAULT_BEAMFORMING;
+-    if (pa_modargs_get_value_boolean(ma, "beamforming", &beamforming) < 0) {
+-        pa_log("Failed to parse beamforming value");
+-        goto fail;
+-    }
+-
+-    if (ext_filter)
+-        config.Set<webrtc::ExtendedFilter>(new webrtc::ExtendedFilter(true));
+-    if (intelligibility)
+-        pa_log_warn("The intelligibility enhancer is not currently supported");
+-    if (experimental_agc)
+-        config.Set<webrtc::ExperimentalAgc>(new webrtc::ExperimentalAgc(true, ec->params.webrtc.agc_start_volume));
+-
+-    trace = DEFAULT_TRACE;
+-    if (pa_modargs_get_value_boolean(ma, "trace", &trace) < 0) {
+-        pa_log("Failed to parse trace value");
+-        goto fail;
+-    }
+-
+-    if (trace) {
+-        webrtc::Trace::CreateTrace();
+-        webrtc::Trace::set_level_filter(webrtc::kTraceAll);
+-        ec->params.webrtc.trace_callback = new PaWebrtcTraceCallback();
+-        webrtc::Trace::SetTraceCallback((PaWebrtcTraceCallback *) ec->params.webrtc.trace_callback);
+-    }
+-
+-    webrtc_ec_fixate_spec(rec_ss, rec_map, play_ss, play_map, out_ss, out_map, beamforming);
+-
+-    /* We do this after fixate because we need the capture channel count */
+-    if (beamforming) {
+-        std::vector<webrtc::Point> geometry(rec_ss->channels);
+-        webrtc::SphericalPointf direction(0.0f, 0.0f, 0.0f);
+-        const char *mic_geometry, *target_direction;
+-
+-        if (!(mic_geometry = pa_modargs_get_value(ma, "mic_geometry", NULL))) {
+-            pa_log("mic_geometry must be set if beamforming is enabled");
+-            goto fail;
+-        }
+-
+-        if (!parse_mic_geometry(&mic_geometry, geometry)) {
+-            pa_log("Failed to parse mic_geometry value");
+-            goto fail;
+-        }
+-
+-        if ((target_direction = pa_modargs_get_value(ma, "target_direction", NULL))) {
+-            float f[3];
+-
+-            if (!parse_point(&target_direction, f)) {
+-                pa_log("Failed to parse target_direction value");
+-                goto fail;
+-            }
+-
+-            if (*target_direction != '\0') {
+-                pa_log("Failed to parse target_direction value: more parameters than expected");
+-                goto fail;
+-            }
+-
+-#define IS_ZERO(f) ((f) < 0.000001 && (f) > -0.000001)
+-
+-            if (!IS_ZERO(f[1]) || !IS_ZERO(f[2])) {
+-                pa_log("The beamformer currently only supports targeting along the azimuth");
+-                goto fail;
+-            }
+-
+-            direction.s[0] = f[0];
+-            direction.s[1] = f[1];
+-            direction.s[2] = f[2];
+-        }
+-
+-        if (!target_direction)
+-            config.Set<webrtc::Beamforming>(new webrtc::Beamforming(true, geometry));
+-        else
+-            config.Set<webrtc::Beamforming>(new webrtc::Beamforming(true, geometry, direction));
+-    }
+-
+-    apm = webrtc::AudioProcessing::Create(config);
++    webrtc_ec_fixate_spec(rec_ss, rec_map, play_ss, play_map, out_ss, out_map);
+ 
+     pconfig = {
+         webrtc::StreamConfig(rec_ss->rate, rec_ss->channels, false), /* input stream */
+@@ -436,46 +230,60 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+         goto fail;
+     }
+ 
++    if (pre_amp) {
++       config.pre_amplifier.enabled = true;
++       config.pre_amplifier.fixed_gain_factor = (float)pre_amp_gain;
++    } else
++       config.pre_amplifier.enabled = false;
++
+     if (hpf)
+-        apm->high_pass_filter()->Enable(true);
+-
+-    if (!mobile) {
+-        apm->echo_cancellation()->enable_drift_compensation(ec->params.drift_compensation);
+-        apm->echo_cancellation()->Enable(true);
+-    } else {
+-        apm->echo_control_mobile()->set_routing_mode(static_cast<webrtc::EchoControlMobile::RoutingMode>(rm));
+-        apm->echo_control_mobile()->enable_comfort_noise(cn);
+-        apm->echo_control_mobile()->Enable(true);
+-    }
++        config.high_pass_filter.enabled = true;
++    else
++        config.high_pass_filter.enabled = false;
+ 
+-    if (ns) {
+-        apm->noise_suppression()->set_level(webrtc::NoiseSuppression::kHigh);
+-        apm->noise_suppression()->Enable(true);
+-    }
++    config.echo_canceller.enabled = true;
+ 
+-    if (agc || dgc) {
+-        if (mobile && rm <= webrtc::EchoControlMobile::kEarpiece) {
+-            /* Maybe this should be a knob, but we've got a lot of knobs already */
+-            apm->gain_control()->set_mode(webrtc::GainControl::kFixedDigital);
+-            ec->params.webrtc.agc = false;
+-        } else if (dgc) {
+-            apm->gain_control()->set_mode(webrtc::GainControl::kAdaptiveDigital);
+-            ec->params.webrtc.agc = false;
+-        } else {
+-            apm->gain_control()->set_mode(webrtc::GainControl::kAdaptiveAnalog);
+-            if (apm->gain_control()->set_analog_level_limits(0, WEBRTC_AGC_MAX_VOLUME) !=
+-                    webrtc::AudioProcessing::kNoError) {
+-                pa_log("Failed to initialise AGC");
+-                goto fail;
+-            }
+-            ec->params.webrtc.agc = true;
+-        }
++    if (!mobile)
++        config.echo_canceller.mobile_mode = false;
++    else
++        config.echo_canceller.mobile_mode = true;
++
++    if (ns)
++       config.noise_suppression.enabled = true;
++    else
++       config.noise_suppression.enabled = false;
+ 
+-        apm->gain_control()->Enable(true);
++    if (tns)
++       config.transient_suppression.enabled = true;
++    else
++       config.transient_suppression.enabled = false;
++
++    if (dgc) {
++        ec->params.webrtc.agc = false;
++        config.gain_controller1.enabled = true;
++        if (mobile)
++            config.gain_controller1.mode = webrtc::AudioProcessing::Config::GainController1::kFixedDigital;
++        else
++            config.gain_controller1.mode = webrtc::AudioProcessing::Config::GainController1::kAdaptiveDigital;
++    } else if (agc) {
++        ec->params.webrtc.agc = true;
++        config.gain_controller1.enabled = true;
++        config.gain_controller1.mode = webrtc::AudioProcessing::Config::GainController1::kAdaptiveAnalog;
++        config.gain_controller1.analog_level_minimum = 0;
++        config.gain_controller1.analog_level_maximum = WEBRTC_AGC_MAX_VOLUME;
+     }
+ 
+     if (vad)
+-        apm->voice_detection()->Enable(true);
++        config.voice_detection.enabled = true;
++    else
++        config.voice_detection.enabled = false;
++
++    if (post_amp) {
++        config.gain_controller2.enabled = true;
++        config.gain_controller2.fixed_digital.gain_db = (float)post_amp_gain;
++        config.gain_controller2.adaptive_digital.enabled = false;
++    } else
++        config.gain_controller2.enabled = false;
+ 
+     ec->params.webrtc.apm = apm;
+     ec->params.webrtc.rec_ss = *rec_ss;
+@@ -485,6 +293,8 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+     *nframes = ec->params.webrtc.blocksize;
+     ec->params.webrtc.first = true;
+ 
++    apm->ApplyConfig(config);
++
+     for (i = 0; i < rec_ss->channels; i++)
+         ec->params.webrtc.rec_buffer[i] = pa_xnew(float, *nframes);
+     for (i = 0; i < play_ss->channels; i++)
+@@ -496,10 +306,7 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
+ fail:
+     if (ma)
+         pa_modargs_free(ma);
+-    if (ec->params.webrtc.trace_callback) {
+-        webrtc::Trace::ReturnTrace();
+-        delete ((PaWebrtcTraceCallback *) ec->params.webrtc.trace_callback);
+-    } if (apm)
++    if (apm)
+         delete apm;
+ 
+     return false;
+@@ -515,12 +322,6 @@ void pa_webrtc_ec_play(pa_echo_canceller *ec, const uint8_t *play) {
+     pa_deinterleave(play, (void **) buf, ss->channels, pa_sample_size(ss), n);
+ 
+     pa_assert_se(apm->ProcessReverseStream(buf, config, config, buf) == webrtc::AudioProcessing::kNoError);
+-
+-    /* FIXME: If ProcessReverseStream() makes any changes to the audio, such as
+-     * applying intelligibility enhancement, those changes don't have any
+-     * effect. This function is called at the source side, but the processing
+-     * would have to be done in the sink to be able to feed the processed audio
+-     * to speakers. */
+ }
+ 
+ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out) {
+@@ -538,7 +339,7 @@ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out
+     if (ec->params.webrtc.agc) {
+         pa_volume_t v = pa_echo_canceller_get_capture_volume(ec);
+         old_volume = webrtc_volume_from_pa(v);
+-        apm->gain_control()->set_stream_analog_level(old_volume);
++        apm->set_stream_analog_level(old_volume);
+     }
+ 
+     apm->set_stream_delay_ms(0);
+@@ -553,7 +354,7 @@ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out
+             ec->params.webrtc.first = false;
+             new_volume = ec->params.webrtc.agc_start_volume;
+         } else {
+-            new_volume = apm->gain_control()->stream_analog_level();
++            new_volume = apm->recommended_stream_analog_level();
+         }
+ 
+         if (old_volume != new_volume)
+@@ -564,9 +365,6 @@ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out
+ }
+ 
+ void pa_webrtc_ec_set_drift(pa_echo_canceller *ec, float drift) {
+-    webrtc::AudioProcessing *apm = (webrtc::AudioProcessing*)ec->params.webrtc.apm;
+-
+-    apm->echo_cancellation()->set_stream_drift_samples(drift * ec->params.webrtc.blocksize);
+ }
+ 
+ void pa_webrtc_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out) {
+@@ -577,11 +375,6 @@ void pa_webrtc_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *
+ void pa_webrtc_ec_done(pa_echo_canceller *ec) {
+     int i;
+ 
+-    if (ec->params.webrtc.trace_callback) {
+-        webrtc::Trace::ReturnTrace();
+-        delete ((PaWebrtcTraceCallback *) ec->params.webrtc.trace_callback);
+-    }
+-
+     if (ec->params.webrtc.apm) {
+         delete (webrtc::AudioProcessing*)ec->params.webrtc.apm;
+         ec->params.webrtc.apm = NULL;
+-- 
+GitLab
+
+
+From 84c53066c65439deb42d29bba8c6899a4fa0e318 Mon Sep 17 00:00:00 2001
+From: Arun Raghavan <arun@asymptotic.io>
+Date: Tue, 20 Oct 2020 17:29:55 -0400
+Subject: [PATCH 3/3] build-sys: Bump webrtc-audio-processing dependency
+
+The package name and versioning are changing upstream, so prepare for
+that.
+
+Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/395>
+---
+ meson.build | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index b678bb531a..a1652e4d30 100644
+--- a/meson.build
++++ b/meson.build
+@@ -728,7 +728,7 @@ if get_option('daemon')
+     cdata.set('HAVE_SOXR', 1)
+   endif
+ 
+-  webrtc_dep = dependency('webrtc-audio-processing', version : '>= 0.2', required : get_option('webrtc-aec'))
++  webrtc_dep = dependency('webrtc-audio-processing-1', version : '>= 1.0', required : get_option('webrtc-aec'))
+   if webrtc_dep.found()
+     cdata.set('HAVE_WEBRTC', 1)
+   endif
+-- 
+GitLab
+
+
diff --git a/srcpkgs/pulseaudio/template b/srcpkgs/pulseaudio/template
index b153d83502a5a2..708ab4f79ab067 100644
--- a/srcpkgs/pulseaudio/template
+++ b/srcpkgs/pulseaudio/template
@@ -1,14 +1,15 @@
 # Template file for 'pulseaudio'
 pkgname=pulseaudio
 version=16.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Djack=enabled -Dlirc=disabled -Dhal-compat=false -Dorc=enabled
  -Dgtk=disabled -Dsystemd=disabled -Dwebrtc-aec=enabled
  -Dgsettings=enabled -Dbluez5=enabled
  -Dbluez5-ofono-headset=false -Dbluez5-native-headset=true
  -Delogind=enabled -Dudevrulesdir=/usr/lib/udev/rules.d
- -Dbashcompletiondir=/usr/share/bash-completion/completions"
+ -Dbashcompletiondir=/usr/share/bash-completion/completions
+ -Dcpp_std=c++17"
 hostmakedepends="m4 gettext libtool orc-devel perl-XML-Parser pkg-config
  doxygen"
 makedepends="$(vopt_if avahi avahi-libs-devel) eudev-libudev-devel fftw-devel jack-devel

From 56582a29be4d3e42b5fa99f50902daf63853616f Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Thu, 7 Mar 2024 10:34:50 -0500
Subject: [PATCH 4/6] pipewire: revbump for webrtc-audio-processing-1.3

---
 srcpkgs/pipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index d23956e13e3a78..4848292c1d8403 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'pipewire'
 pkgname=pipewire
 version=1.0.3
-revision=1
+revision=2
 build_style=meson
 configure_args="
  --auto-features=enabled

From 0429bd34e50c69b60016d5c312e74d0a235e8c8d Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Thu, 7 Mar 2024 10:35:29 -0500
Subject: [PATCH 5/6] gst-plugins-bad1: revbump for webrtc-audio-processing-1.3

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 10dc49f4c151bc..dc4db910c43e84 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 62919514f7bc5ab5dda46fdb6705faabe86725e6 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Thu, 7 Mar 2024 10:35:55 -0500
Subject: [PATCH 6/6] baresip: revbump for webrtc-audio-processing-1.3

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b7..b16b67beab8d2b 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PR PATCH] [Merged]: webrtc-audio-processing: update to 1.3; revbump dependents
  2024-02-23 23:04 [PR PATCH] webrtc-audio-processing: update to 1.3; revbump dependents cinerea0
                   ` (3 preceding siblings ...)
  2024-03-07 21:26 ` [PR PATCH] [Updated] " cinerea0
@ 2024-03-09 20:17 ` cinerea0
  4 siblings, 0 replies; 6+ messages in thread
From: cinerea0 @ 2024-03-09 20:17 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 375 bytes --]

There's a merged pull request on the void-packages repository

webrtc-audio-processing: update to 1.3; revbump dependents
https://github.com/void-linux/void-packages/pull/48902

Description:
#### Testing the changes
- I tested the changes in this PR: **YES**

---

@ahesford Are there any potential negative consequences of forcing abseil to use C++17 you can think of?

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-09 20:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-23 23:04 [PR PATCH] webrtc-audio-processing: update to 1.3; revbump dependents cinerea0
2024-02-23 23:11 ` cinerea0
2024-02-23 23:21 ` [PR PATCH] [Updated] " cinerea0
2024-02-24  0:16 ` ahesford
2024-03-07 21:26 ` [PR PATCH] [Updated] " cinerea0
2024-03-09 20:17 ` [PR PATCH] [Merged]: " cinerea0

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).