2022-10-30 02:43:51 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, pkg-config
|
2022-11-13 23:10:39 +00:00
|
|
|
, alsa-lib
|
2022-10-30 02:43:51 +00:00
|
|
|
, jack2
|
2022-11-13 23:10:39 +00:00
|
|
|
, libpulseaudio
|
2022-10-30 02:43:51 +00:00
|
|
|
, sndio
|
|
|
|
, speexdsp
|
2022-11-13 23:10:40 +00:00
|
|
|
, AudioUnit
|
|
|
|
, CoreAudio
|
|
|
|
, CoreServices
|
|
|
|
, lazyLoad ? !stdenv.hostPlatform.isDarwin
|
2022-10-30 02:43:51 +00:00
|
|
|
}:
|
|
|
|
|
2022-11-13 23:10:40 +00:00
|
|
|
assert lib.assertMsg (stdenv.hostPlatform.isDarwin -> !lazyLoad) "cubeb: lazyLoad is inert on Darwin";
|
|
|
|
|
|
|
|
let
|
|
|
|
backendLibs = [
|
|
|
|
alsa-lib
|
|
|
|
jack2
|
|
|
|
libpulseaudio
|
|
|
|
sndio
|
|
|
|
];
|
|
|
|
|
|
|
|
in stdenv.mkDerivation {
|
2022-10-30 02:43:51 +00:00
|
|
|
pname = "cubeb";
|
|
|
|
version = "unstable-2022-10-18";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "mozilla";
|
|
|
|
repo = "cubeb";
|
|
|
|
rev = "27d2a102b0b75d9e49d43bc1ea516233fb87d778";
|
|
|
|
hash = "sha256-q+uz1dGU4LdlPogL1nwCR/KuOX4Oy3HhMdA6aJylBRk=";
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
|
2022-11-13 23:10:40 +00:00
|
|
|
buildInputs = [ speexdsp ] ++ (
|
|
|
|
if stdenv.hostPlatform.isDarwin then [ AudioUnit CoreAudio CoreServices ]
|
|
|
|
else backendLibs
|
|
|
|
);
|
2022-10-30 02:43:51 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_SHARED_LIBS=ON"
|
|
|
|
"-DBUILD_TESTS=OFF" # tests require an audio server
|
|
|
|
"-DBUNDLE_SPEEX=OFF"
|
|
|
|
"-DUSE_SANITIZERS=OFF"
|
|
|
|
|
|
|
|
# Whether to lazily load libraries with dlopen()
|
|
|
|
"-DLAZY_LOAD_LIBS=${if lazyLoad then "ON" else "OFF"}"
|
|
|
|
];
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
# For downstream users when lazyLoad is true
|
2022-11-13 23:10:40 +00:00
|
|
|
backendLibs = lib.optionals lazyLoad backendLibs;
|
2022-10-30 02:43:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Cross platform audio library";
|
2024-03-19 02:14:51 +00:00
|
|
|
mainProgram = "cubeb-test";
|
2022-10-30 02:43:51 +00:00
|
|
|
homepage = "https://github.com/mozilla/cubeb";
|
|
|
|
license = licenses.isc;
|
2022-11-13 23:10:40 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
2022-10-30 02:43:51 +00:00
|
|
|
maintainers = with maintainers; [ zhaofengli ];
|
|
|
|
};
|
|
|
|
}
|