1{ lib, stdenv, fetchurl
2, darwin
3, abseil-cpp_202111
4, meson
5, ninja
6}:
7
8stdenv.mkDerivation rec {
9 pname = "webrtc-audio-processing";
10 version = "1.0";
11
12 src = fetchurl {
13 url = "https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/archive/v1.0/webrtc-audio-processing-v${version}.tar.gz";
14 sha256 = "sha256-dqRy1OfOG9TX2cgCD8cowU44zVanns/nPYZrilPfuiU=";
15 };
16
17 nativeBuildInputs = [
18 meson
19 ninja
20 ];
21
22 buildInputs = [
23 abseil-cpp_202111
24 ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ ApplicationServices ]);
25
26 patchPhase = ''
27 # this is just incorrect upstream
28 # see https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/issues/4
29 substituteInPlace meson.build \
30 --replace "absl_flags_registry" "absl_flags_reflection"
31 '' + lib.optionalString stdenv.hostPlatform.isMusl ''
32 substituteInPlace webrtc/base/checks.cc --replace 'defined(__UCLIBC__)' 1
33 '';
34
35 meta = with lib; {
36 homepage = "https://www.freedesktop.org/software/pulseaudio/webrtc-audio-processing";
37 description = "A more Linux packaging friendly copy of the AudioProcessing module from the WebRTC project";
38 license = licenses.bsd3;
39 # https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/blob/master/webrtc/rtc_base/system/arch.h
40 platforms = intersectLists platforms.unix (platforms.aarch64 ++ platforms.mips ++ platforms.riscv ++ platforms.x86);
41 # attempts to inline 256bit AVX instructions on x86
42 # https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/issues/5
43 broken = stdenv.isx86_32;
44 };
45}