From 8024f4c52329cd6b67cfab78cd9dc37ca6d28182 Mon Sep 17 00:00:00 2001 From: triallax Date: Wed, 24 May 2023 21:49:37 +0100 Subject: [PATCH 1/5] abseil-cpp: update for webrtc-audio-processing-1.3. --- 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 4b049b6b84fdd..7df3aa0ef0c39 100644 --- a/srcpkgs/abseil-cpp/template +++ b/srcpkgs/abseil-cpp/template @@ -1,9 +1,10 @@ # Template file for 'abseil-cpp' pkgname=abseil-cpp version=20230802.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 " From f1cd59c681e4818b9d3275ead56f5b80ae806da6 Mon Sep 17 00:00:00 2001 From: triallax Date: Wed, 24 May 2023 22:01:40 +0100 Subject: [PATCH 2/5] webrtc-audio-processing: update to 1.3. --- common/shlibs | 3 +- ...yte-order-and-pointer-size-detection.patch | 33 ----- .../patches/mips.patch | 113 ------------------ .../patches/musl.patch | 20 ---- srcpkgs/webrtc-audio-processing/template | 27 ++--- 5 files changed, 10 insertions(+), 186 deletions(-) delete mode 100644 srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.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 ede20ee14a683..0d0adb3ae7ea4 100644 --- a/common/shlibs +++ b/common/shlibs @@ -1050,7 +1050,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 deleted file mode 100644 index 1338784e69ef8..0000000000000 --- a/srcpkgs/webrtc-audio-processing/patches/Add-generic-byte-order-and-pointer-size-detection.patch +++ /dev/null @@ -1,33 +0,0 @@ -From: Than -Date: Wed, 8 Jun 2016 19:10:08 -0400 -Subject: Add generic byte order and pointer size detection - ---- - 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 @@ - #define WEBRTC_ARCH_32_BITS - #define WEBRTC_ARCH_LITTLE_ENDIAN - #else --#error Please add support for your architecture in typedefs.h -+/* instead of failing, use typical unix defines... */ -+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -+#define WEBRTC_ARCH_LITTLE_ENDIAN -+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -+#define WEBRTC_ARCH_BIG_ENDIAN -+#else -+#error __BYTE_ORDER__ is not defined -+#endif -+#if defined(__LP64__) -+#define WEBRTC_ARCH_64_BITS -+#else -+#define WEBRTC_ARCH_32_BITS -+#endif - #endif - - #if !(defined(WEBRTC_ARCH_LITTLE_ENDIAN) ^ defined(WEBRTC_ARCH_BIG_ENDIAN)) 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(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(read); -+#ifdef WEBRTC_ARCH_BIG_ENDIAN -+ for (size_t i = 0; i < read; i++) { -+ uint16_t s = static_cast(samples[i]); -+ samples[i] = static_cast((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(samples[i]); -+ s = static_cast((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(written); - RTC_CHECK(written <= std::numeric_limits::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(&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(a) << 24) -+ | (static_cast(b) << 16) -+ | (static_cast(c) << 8) -+ | static_cast(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(&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 - #include - --#if defined(__GLIBCXX__) && !defined(__UCLIBC__) -+#if defined(__GLIBC__) && defined(__GLIBCXX__) - #include - #include - #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..6d56b16ca37d5 100644 --- a/srcpkgs/webrtc-audio-processing/template +++ b/srcpkgs/webrtc-audio-processing/template @@ -1,38 +1,27 @@ # 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 " license="BSD-3-Clause" -homepage="http://freedesktop.org/software/pulseaudio/webrtc-audio-processing" -distfiles="${homepage}/${pkgname}-${version}.tar.xz" -checksum=a0fdd938fd85272d67e81572c5a4d9e200a0c104753cb3c209ded175ce3c5dbf - -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 -} +homepage="https://freedesktop.org/software/pulseaudio/webrtc-audio-processing" +distfiles="${FREEDESKTOP_SITE}/pulseaudio/webrtc-audio-processing/webrtc-audio-processing-${version}.tar.gz" +checksum=95552fc17faa0202133707bbb3727e8c2cf64d4266fe31bfdb2298d769c1db75 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 69a2916b2eed219bdd24c85a8a8ba254fda62298 Mon Sep 17 00:00:00 2001 From: triallax Date: Wed, 24 May 2023 22:04:57 +0100 Subject: [PATCH 3/5] 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 2bf2f4b0642fe..0fafcb6555395 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.5 -revision=1 +revision=2 build_helper="gir" build_style=meson configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled From 6c0dc021290832efbdf64bcc69dff2a7e332ae51 Mon Sep 17 00:00:00 2001 From: triallax Date: Wed, 24 May 2023 22:04:58 +0100 Subject: [PATCH 4/5] pulseaudio: revbump for webrtc-audio-processing-1.3. --- .../patches/webrtc-audio-processing-1.patch | 673 ++++++++++++++++++ srcpkgs/pulseaudio/template | 5 +- 2 files changed, 676 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..a2f4522560f4e --- /dev/null +++ b/srcpkgs/pulseaudio/patches/webrtc-audio-processing-1.patch @@ -0,0 +1,673 @@ +From b16b107171f24f791f79c20730cf6eb3ad469944 Mon Sep 17 00:00:00 2001 +From: Arun Raghavan +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: +--- + 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 +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: +--- + 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 ++ 2020 Arun Raghavan ++ 2020 Eero Nurkkala + + 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 +-#include +-#include ++#define WEBRTC_APM_DEBUG_DUMP 0 ++ ++#include + + #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& 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(new webrtc::ExtendedFilter(true)); +- if (intelligibility) +- pa_log_warn("The intelligibility enhancer is not currently supported"); +- if (experimental_agc) +- config.Set(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 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(new webrtc::Beamforming(true, geometry)); +- else +- config.Set(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(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 +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: +--- + 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 f7e48f6996e9afb5ed5fbf8ae710097ec0b1ec31 Mon Sep 17 00:00:00 2001 From: Mohammed Anas Date: Sun, 12 Nov 2023 23:02:54 +0000 Subject: [PATCH 5/5] 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