From 31cf1ff4ee6d7181a679f1d5bcd7a5d82e6f7c5e Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Fri, 21 Jun 2019 18:14:06 +0000 Subject: [PATCH] openalSolf: make it search its own $out for data files Without those data files HRTF will silently fail to initialize. It searches /usr and /usr/local by default but we don't have those paths. It also searches XDG_DATA_DIRS but using that requires configuration by the user. This patch makes makes it just work. How to play with it: - Build `mpv` with `openalSoft` support. - cat << EOF > ~/.alsoftrc [general] hrtf = true EOF - Wear stereo headphones. - Play a file with 6 or more channels with `mpv -ao openal $file`, e.g. https://archive.org/download/5.1SurroundSoundTestFilesVariousFormatsAACAC3MP4DTSWAV/5.1%20Surround%20Sound%20AAC%20Test.mp4 - Try `hrtf = false` to hear the difference. --- pkgs/development/libraries/openal-soft/default.nix | 8 ++++++++ .../libraries/openal-soft/search-out.patch | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 pkgs/development/libraries/openal-soft/search-out.patch diff --git a/pkgs/development/libraries/openal-soft/default.nix b/pkgs/development/libraries/openal-soft/default.nix index 89ac85b752b..76f2861428d 100644 --- a/pkgs/development/libraries/openal-soft/default.nix +++ b/pkgs/development/libraries/openal-soft/default.nix @@ -20,6 +20,14 @@ stdenv.mkDerivation rec { sha256 = "0b0g0q1c36nfb289xcaaj3cmyfpiswvvgky3qyalsf9n4dj7vnzi"; }; + # this will make it find its own data files (e.g. HRTF profiles) + # without any other configuration + patches = [ ./search-out.patch ]; + postPatch = '' + substituteInPlace Alc/helpers.c \ + --replace "@OUT@" $out + ''; + nativeBuildInputs = [ cmake ]; buildInputs = [] diff --git a/pkgs/development/libraries/openal-soft/search-out.patch b/pkgs/development/libraries/openal-soft/search-out.patch new file mode 100644 index 00000000000..0f9c2abad3c --- /dev/null +++ b/pkgs/development/libraries/openal-soft/search-out.patch @@ -0,0 +1,12 @@ +diff -Nuar a/Alc/helpers.c b/Alc/helpers.c +--- a/Alc/helpers.c 1970-01-01 00:00:01.000000000 +0000 ++++ b/Alc/helpers.c 1970-01-01 00:00:02.000000000 +0000 +@@ -951,6 +951,8 @@ + } + } + ++ DirectorySearch("@OUT@/share", ext, &results); ++ + alstr_reset(&path); + } +