duckstation: use cubeb from nixpkgs

Signed-off-by: Marcin Serwin <marcin@serwin.dev>
This commit is contained in:
Marcin Serwin 2025-05-24 18:17:21 +02:00
parent 9d9fc4258d
commit 709d5b4e5c
No known key found for this signature in database
GPG key ID: DACFAC4EA0B194E0
3 changed files with 49 additions and 11 deletions

View file

@ -6,9 +6,7 @@
callPackage,
cmake,
cpuinfo,
cubeb,
curl,
discord-rpc,
extra-cmake-modules,
libXrandr,
libbacktrace,
@ -42,6 +40,7 @@ llvmPackages.stdenv.mkDerivation (finalAttrs: {
./002-hardcode-vars.diff
# Fix NEON intrinsics usage
./003-fix-NEON-intrinsics.patch
./remove-cubeb-vendor.patch
];
nativeBuildInputs = [
@ -57,6 +56,7 @@ llvmPackages.stdenv.mkDerivation (finalAttrs: {
buildInputs = [
SDL2
cpuinfo
sources.cubeb
curl
libXrandr
libbacktrace
@ -70,7 +70,7 @@ llvmPackages.stdenv.mkDerivation (finalAttrs: {
sources.soundtouch-patched
sources.spirv-cross-patched
wayland
] ++ cubeb.passthru.backendLibs;
];
cmakeFlags = [
(lib.cmakeBool "BUILD_TESTS" true)
@ -115,14 +115,11 @@ llvmPackages.stdenv.mkDerivation (finalAttrs: {
qtWrapperArgs =
let
libPath = lib.makeLibraryPath (
[
sources.shaderc-patched
sources.spirv-cross-patched
vulkan-loader
]
++ cubeb.passthru.backendLibs
);
libPath = lib.makeLibraryPath ([
sources.shaderc-patched
sources.spirv-cross-patched
vulkan-loader
]);
in
[
"--prefix LD_LIBRARY_PATH : ${libPath}"

View file

@ -0,0 +1,29 @@
diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt
index af35687..8347825 100644
--- a/dep/CMakeLists.txt
+++ b/dep/CMakeLists.txt
@@ -22,9 +22,8 @@ add_subdirectory(rcheevos EXCLUDE_FROM_ALL)
disable_compiler_warnings_for_target(rcheevos)
add_subdirectory(rapidyaml EXCLUDE_FROM_ALL)
disable_compiler_warnings_for_target(rapidyaml)
-add_subdirectory(cubeb EXCLUDE_FROM_ALL)
-disable_compiler_warnings_for_target(cubeb)
-disable_compiler_warnings_for_target(speex)
+find_package(cubeb REQUIRED GLOBAL)
+add_library(cubeb ALIAS cubeb::cubeb)
add_subdirectory(kissfft EXCLUDE_FROM_ALL)
disable_compiler_warnings_for_target(kissfft)
diff --git a/src/util/cubeb_audio_stream.cpp b/src/util/cubeb_audio_stream.cpp
index 85579c4..526d168 100644
--- a/src/util/cubeb_audio_stream.cpp
+++ b/src/util/cubeb_audio_stream.cpp
@@ -261,7 +261,7 @@ std::vector<std::pair<std::string, std::string>> AudioStream::GetCubebDriverName
std::vector<std::pair<std::string, std::string>> names;
names.emplace_back(std::string(), TRANSLATE_STR("AudioStream", "Default"));
- const char** cubeb_names = cubeb_get_backend_names();
+ const char*const * cubeb_names = cubeb_get_backend_names();
for (u32 i = 0; cubeb_names[i] != nullptr; i++)
names.emplace_back(cubeb_names[i], cubeb_names[i]);
return names;

View file

@ -9,6 +9,7 @@
stdenv,
cmake,
ninja,
cubeb,
}:
{
@ -163,4 +164,15 @@
platforms = lib.platforms.linux;
};
});
cubeb = cubeb.overrideAttrs (old: {
pname = "cubeb-patched-for-duckstation";
patches = (old.patches or [ ]) ++ [
(fetchpatch {
url = "https://github.com/PCSX2/pcsx2/commit/430e31abe4a9e09567cb542f1416b011bb9b6ef9.patch";
stripLen = 2;
hash = "sha256-bbH0c1X3lMeX6hfNKObhcq5xraFpicFV3mODQGYudvQ=";
})
];
});
}