diff options
author | Weijia Wang <9713184+wegank@users.noreply.github.com> | 2022-08-02 18:39:28 +0200 |
---|---|---|
committer | Weijia Wang <9713184+wegank@users.noreply.github.com> | 2022-08-02 18:39:28 +0200 |
commit | fd031c029969f8efdc1b39d37cbafa252f9d9d0b (patch) | |
tree | a5e44d43e184e5af8d60684ee624bbd27f096d40 /pkgs/servers/pulseaudio | |
parent | 5ae322a93ec55a3464aa97c818601f0e949ebd10 (diff) | |
download | nixpkgs-fd031c029969f8efdc1b39d37cbafa252f9d9d0b.tar nixpkgs-fd031c029969f8efdc1b39d37cbafa252f9d9d0b.tar.gz nixpkgs-fd031c029969f8efdc1b39d37cbafa252f9d9d0b.tar.bz2 nixpkgs-fd031c029969f8efdc1b39d37cbafa252f9d9d0b.tar.lz nixpkgs-fd031c029969f8efdc1b39d37cbafa252f9d9d0b.tar.xz nixpkgs-fd031c029969f8efdc1b39d37cbafa252f9d9d0b.tar.zst nixpkgs-fd031c029969f8efdc1b39d37cbafa252f9d9d0b.zip |
pulseaudio: add darwin support
Diffstat (limited to 'pkgs/servers/pulseaudio')
15 files changed, 218 insertions, 229 deletions
diff --git a/pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-when-gsettings-is-disabled.patch b/pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-15.patch index c087dcd7e7d..c087dcd7e7d 100644 --- a/pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-when-gsettings-is-disabled.patch +++ b/pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-15.patch diff --git a/pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-16.patch b/pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-16.patch new file mode 100644 index 00000000000..2a5ae040d9d --- /dev/null +++ b/pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-16.patch @@ -0,0 +1,26 @@ +From 72f3fe059f031f24c5ad026cb2fc16318f227c09 Mon Sep 17 00:00:00 2001 +From: Andrew Childs <andrew.childs@bibo.com.ph> +Date: Tue, 19 Apr 2022 16:29:58 +0900 +Subject: [PATCH 1/8] Make gio-2.0 optional when gsettings is disabled + +Derived from https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/654 +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index c5135330f..340f58e17 100644 +--- a/meson.build ++++ b/meson.build +@@ -683,7 +683,7 @@ if get_option('daemon') + cdata.set('HAVE_ALSA_UCM', 1) + endif + +- gio_dep = dependency('gio-2.0', version : '>= 2.26.0') ++ gio_dep = dependency('gio-2.0', version : '>= 2.26.0', required : false) + if get_option('gsettings').enabled() + assert(gio_dep.found(), 'GSettings support needs glib I/O library (GIO)') + cdata.set('HAVE_GSETTINGS', 1) +-- +2.35.1 + diff --git a/pkgs/servers/pulseaudio/0002-Ignore-SCM_CREDS-on-macOS.patch b/pkgs/servers/pulseaudio/0002-Ignore-SCM_CREDS-on-darwin.patch index 9196e205dc0..9196e205dc0 100644 --- a/pkgs/servers/pulseaudio/0002-Ignore-SCM_CREDS-on-macOS.patch +++ b/pkgs/servers/pulseaudio/0002-Ignore-SCM_CREDS-on-darwin.patch diff --git a/pkgs/servers/pulseaudio/0003-Disable-z-nodelete-on-darwin.patch b/pkgs/servers/pulseaudio/0003-Disable-z-nodelete-on-darwin.patch deleted file mode 100644 index 81b3ab92733..00000000000 --- a/pkgs/servers/pulseaudio/0003-Disable-z-nodelete-on-darwin.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 3f1abb55f4eb985fd0715b2b2ca45dcce3a56824 Mon Sep 17 00:00:00 2001 -From: Andrew Childs <andrew.childs@bibo.com.ph> -Date: Tue, 19 Apr 2022 17:06:50 +0900 -Subject: [PATCH 3/8] Disable `-z nodelete` on darwin - -Not supported[citation needed]. ---- - meson.build | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/meson.build b/meson.build -index f7adf1413..d4bece11a 100644 ---- a/meson.build -+++ b/meson.build -@@ -404,7 +404,7 @@ cdata.set('MESON_BUILD', 1) - # so we request the nodelete flag to be enabled. - # On other systems, we don't really know how to do that, but it's welcome if somebody can tell. - # Windows doesn't support this flag. --if host_machine.system() != 'windows' -+if host_machine.system() != 'windows' and host_machine.system() != 'darwin' - nodelete_link_args = ['-Wl,-z,nodelete'] - else - nodelete_link_args = [] --- -2.35.1 - diff --git a/pkgs/servers/pulseaudio/0003-Ignore-HAVE_CPUID_H-on-aarch64-darwin.patch b/pkgs/servers/pulseaudio/0003-Ignore-HAVE_CPUID_H-on-aarch64-darwin.patch new file mode 100644 index 00000000000..ce0df74f877 --- /dev/null +++ b/pkgs/servers/pulseaudio/0003-Ignore-HAVE_CPUID_H-on-aarch64-darwin.patch @@ -0,0 +1,26 @@ +diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c +index c383a61c0..3d0a68c2e 100644 +--- a/src/pulsecore/core-util.c ++++ b/src/pulsecore/core-util.c +@@ -110,7 +110,7 @@ + #include <sys/personality.h> + #endif + +-#ifdef HAVE_CPUID_H ++#if defined(HAVE_CPUID_H) && !(defined(__APPLE__) && defined(__aarch64__)) + #include <cpuid.h> + #endif + +diff --git a/src/pulsecore/cpu-x86.c b/src/pulsecore/cpu-x86.c +index 317a0101e..d1eb95d2b 100644 +--- a/src/pulsecore/cpu-x86.c ++++ b/src/pulsecore/cpu-x86.c +@@ -24,7 +24,7 @@ + + #include <stdint.h> + +-#ifdef HAVE_CPUID_H ++#if defined(HAVE_CPUID_H) && !(defined(__APPLE__) && defined(__aarch64__)) + #include <cpuid.h> + #endif + diff --git a/pkgs/servers/pulseaudio/0004-Prefer-HAVE_CLOCK_GETTIME-on-darwin.patch b/pkgs/servers/pulseaudio/0004-Prefer-HAVE_CLOCK_GETTIME-on-darwin.patch new file mode 100644 index 00000000000..0eeaf2a03a1 --- /dev/null +++ b/pkgs/servers/pulseaudio/0004-Prefer-HAVE_CLOCK_GETTIME-on-darwin.patch @@ -0,0 +1,13 @@ +diff --git a/src/pulsecore/core-rtclock.c b/src/pulsecore/core-rtclock.c +index 2c2e28631..b946a3fb1 100644 +--- a/src/pulsecore/core-rtclock.c ++++ b/src/pulsecore/core-rtclock.c +@@ -65,7 +65,7 @@ pa_usec_t pa_rtclock_age(const struct timeval *tv) { + + struct timeval *pa_rtclock_get(struct timeval *tv) { + +-#if defined(OS_IS_DARWIN) ++#if defined(OS_IS_DARWIN) && !defined(HAVE_CLOCK_GETTIME) + uint64_t val, abs_time = mach_absolute_time(); + Nanoseconds nanos; + diff --git a/pkgs/servers/pulseaudio/0004-Prefer-clock_gettime.patch b/pkgs/servers/pulseaudio/0004-Prefer-clock_gettime.patch deleted file mode 100644 index eb7bd1c6270..00000000000 --- a/pkgs/servers/pulseaudio/0004-Prefer-clock_gettime.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 0bd3b613ac3bf16a73b3223fa1b961da3a0db1b2 Mon Sep 17 00:00:00 2001 -From: Andrew Childs <andrew.childs@bibo.com.ph> -Date: Tue, 19 Apr 2022 17:12:52 +0900 -Subject: [PATCH 4/8] Prefer clock_gettime - -Available in darwin since 10.12 (released in 2016). ---- - src/pulsecore/core-rtclock.c | 26 +++++++++++++------------- - 1 file changed, 13 insertions(+), 13 deletions(-) - -diff --git a/src/pulsecore/core-rtclock.c b/src/pulsecore/core-rtclock.c -index 2c2e28631..a08d4b391 100644 ---- a/src/pulsecore/core-rtclock.c -+++ b/src/pulsecore/core-rtclock.c -@@ -65,19 +65,7 @@ pa_usec_t pa_rtclock_age(const struct timeval *tv) { - - struct timeval *pa_rtclock_get(struct timeval *tv) { - --#if defined(OS_IS_DARWIN) -- uint64_t val, abs_time = mach_absolute_time(); -- Nanoseconds nanos; -- -- nanos = AbsoluteToNanoseconds(*(AbsoluteTime *) &abs_time); -- val = *(uint64_t *) &nanos; -- -- tv->tv_sec = val / PA_NSEC_PER_SEC; -- tv->tv_usec = (val % PA_NSEC_PER_SEC) / PA_NSEC_PER_USEC; -- -- return tv; -- --#elif defined(HAVE_CLOCK_GETTIME) -+#if defined(HAVE_CLOCK_GETTIME) - struct timespec ts; - - #ifdef CLOCK_MONOTONIC -@@ -109,6 +97,18 @@ struct timeval *pa_rtclock_get(struct timeval *tv) { - - return tv; - } -+#elif defined(OS_IS_DARWIN) -+ uint64_t val, abs_time = mach_absolute_time(); -+ Nanoseconds nanos; -+ -+ nanos = AbsoluteToNanoseconds(*(AbsoluteTime *) &abs_time); -+ val = *(uint64_t *) &nanos; -+ -+ tv->tv_sec = val / PA_NSEC_PER_SEC; -+ tv->tv_usec = (val % PA_NSEC_PER_SEC) / PA_NSEC_PER_USEC; -+ -+ return tv; -+ - #endif /* HAVE_CLOCK_GETTIME */ - - return pa_gettimeofday(tv); --- -2.35.1 - diff --git a/pkgs/servers/pulseaudio/0005-Enable-CoreAudio-on-darwin.patch b/pkgs/servers/pulseaudio/0005-Enable-CoreAudio-on-darwin.patch new file mode 100644 index 00000000000..bdf5ff2b9ca --- /dev/null +++ b/pkgs/servers/pulseaudio/0005-Enable-CoreAudio-on-darwin.patch @@ -0,0 +1,31 @@ +diff --git a/meson.build b/meson.build +index c5135330f..055567479 100644 +--- a/meson.build ++++ b/meson.build +@@ -185,6 +185,7 @@ endif + # rather than ending up in the config.h file? + if host_machine.system() == 'darwin' + cdata.set('OS_IS_DARWIN', 1) ++ cdata.set('HAVE_COREAUDIO', 1) + cdata.set('_DARWIN_C_SOURCE', '200112L') # Needed to get NSIG on Mac OS + elif host_machine.system() == 'windows' + cdata.set('OS_IS_WIN32', 1) +diff --git a/src/modules/meson.build b/src/modules/meson.build +index 1e12569dc..53a800927 100644 +--- a/src/modules/meson.build ++++ b/src/modules/meson.build +@@ -63,6 +63,14 @@ all_modules = [ + [ 'module-volume-restore', 'module-volume-restore.c' ], + ] + ++if host_machine.system() == 'darwin' ++ coreaudio_dep = dependency('appleframeworks', modules : ['AudioUnit', 'Cocoa', 'CoreServices', 'CoreAudio']) ++ all_modules += [ ++ [ 'module-coreaudio-detect', 'macosx/module-coreaudio-detect.c', [], [], [coreaudio_dep] ], ++ [ 'module-coreaudio-device', 'macosx/module-coreaudio-device.c', [], [], [coreaudio_dep] ], ++ ] ++endif ++ + if host_machine.system() == 'windows' + winmm_dep = meson.get_compiler('c').find_library('winmm') + ksuser_dep = meson.get_compiler('c').find_library('ksuser') diff --git a/pkgs/servers/pulseaudio/0005-Include-poll-posix.c-on-darwin.patch b/pkgs/servers/pulseaudio/0005-Include-poll-posix.c-on-darwin.patch deleted file mode 100644 index 4779fce2afd..00000000000 --- a/pkgs/servers/pulseaudio/0005-Include-poll-posix.c-on-darwin.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 8dee473920d3a331b73a415b37e7e0b01f014110 Mon Sep 17 00:00:00 2001 -From: Andrew Childs <andrew.childs@bibo.com.ph> -Date: Tue, 19 Apr 2022 17:22:23 +0900 -Subject: [PATCH 5/8] Include poll-posix.c on darwin - ---- - src/meson.build | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/meson.build b/src/meson.build -index e2860811b..5bd68cb12 100644 ---- a/src/meson.build -+++ b/src/meson.build -@@ -182,6 +182,7 @@ if host_machine.system() == 'windows' - else - libpulsecommon_sources += [ - 'pulsecore/mutex-posix.c', -+ 'pulsecore/poll-posix.c', - 'pulsecore/semaphore-posix.c', - 'pulsecore/thread-posix.c' - ] --- -2.35.1 - diff --git a/pkgs/servers/pulseaudio/0006-Fix-libpulsecommon-sources-on-darwin.patch b/pkgs/servers/pulseaudio/0006-Fix-libpulsecommon-sources-on-darwin.patch new file mode 100644 index 00000000000..67a21af4679 --- /dev/null +++ b/pkgs/servers/pulseaudio/0006-Fix-libpulsecommon-sources-on-darwin.patch @@ -0,0 +1,18 @@ +diff --git a/src/meson.build b/src/meson.build +index 9efb561d8..d181f4867 100644 +--- a/src/meson.build ++++ b/src/meson.build +@@ -179,6 +179,13 @@ if host_machine.system() == 'windows' + 'pulsecore/semaphore-win32.c', + 'pulsecore/thread-win32.c', + ] ++elif host_machine.system() == 'darwin' ++ libpulsecommon_sources += [ ++ 'pulsecore/mutex-posix.c', ++ 'pulsecore/poll-posix.c', ++ 'pulsecore/semaphore-osx.c', ++ 'pulsecore/thread-posix.c' ++ ] + else + libpulsecommon_sources += [ + 'pulsecore/mutex-posix.c', diff --git a/pkgs/servers/pulseaudio/0006-Only-use-version-script-on-GNU-ish-linkers.patch b/pkgs/servers/pulseaudio/0006-Only-use-version-script-on-GNU-ish-linkers.patch deleted file mode 100644 index 8b27b3e5ab7..00000000000 --- a/pkgs/servers/pulseaudio/0006-Only-use-version-script-on-GNU-ish-linkers.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 419258112b9d90d149ebbd5c657a36d8532b78a2 Mon Sep 17 00:00:00 2001 -From: Andrew Childs <andrew.childs@bibo.com.ph> -Date: Tue, 19 Apr 2022 17:31:36 +0900 -Subject: [PATCH 6/8] Only use version-script on GNU-ish linkers - ---- - src/pulse/meson.build | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/src/pulse/meson.build b/src/pulse/meson.build -index c2128e087..a5e47867e 100644 ---- a/src/pulse/meson.build -+++ b/src/pulse/meson.build -@@ -74,7 +74,11 @@ run_target('update-map-file', - command : [ join_paths(meson.source_root(), 'scripts/generate-map-file.sh'), 'map-file', - [ libpulse_headers, 'simple.h', join_paths(meson.build_root(), 'src', 'pulse', 'version.h') ] ]) - --versioning_link_args = '-Wl,-version-script=' + join_paths(meson.source_root(), 'src', 'pulse', 'map-file') -+if meson.get_compiler('c').get_linker_id().startswith('ld.') -+ versioning_link_args = '-Wl,-version-script=' + join_paths(meson.source_root(), 'src', 'pulse', 'map-file') -+else -+ versioning_link_args = [] -+endif - - libpulse = shared_library('pulse', - libpulse_sources, --- -2.35.1 - diff --git a/pkgs/servers/pulseaudio/0007-Adapt-undefined-link-args-per-linker.patch b/pkgs/servers/pulseaudio/0007-Adapt-undefined-link-args-per-linker.patch deleted file mode 100644 index 6893df8a7e2..00000000000 --- a/pkgs/servers/pulseaudio/0007-Adapt-undefined-link-args-per-linker.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 6f132be835d5acb5db4301ea1818601504e47fae Mon Sep 17 00:00:00 2001 -From: Andrew Childs <andrew.childs@bibo.com.ph> -Date: Tue, 19 Apr 2022 17:41:34 +0900 -Subject: [PATCH 7/8] Adapt undefined link args per linker - -TODO: Why is this required? Isn't it default? ---- - src/modules/meson.build | 13 ++++++++++++- - 1 file changed, 12 insertions(+), 1 deletion(-) - -diff --git a/src/modules/meson.build b/src/modules/meson.build -index be72c3b9b..0163b583f 100644 ---- a/src/modules/meson.build -+++ b/src/modules/meson.build -@@ -293,6 +293,17 @@ all_modules += [ - # FIXME: meson doesn't support multiple RPATH arguments currently - rpath_dirs = join_paths(privlibdir) + ':' + join_paths(modlibexecdir) - -+if meson.get_compiler('c').get_linker_id().startswith('ld.') -+ no_undefined_link_args = [ '-Wl,--no-undefined' ] -+elif meson.get_compiler('c').get_linker_id() == 'ld64' -+ # TODO: is this required? is this not default? -+ no_undefined_link_args = [ '-Wl,-undefined,error' ] -+else -+ # TODO: what platforms is this? what flag do they use? -+ no_undefined_link_args = [] -+endif -+ -+ - foreach m : all_modules - name = m[0] - sources = m[1] -@@ -310,7 +321,7 @@ foreach m : all_modules - install_rpath : rpath_dirs, - install_dir : modlibexecdir, - dependencies : [thread_dep, libpulse_dep, libpulsecommon_dep, libpulsecore_dep, libintl_dep, platform_dep, platform_socket_dep] + extra_deps, -- link_args : [nodelete_link_args, '-Wl,--no-undefined' ], -+ link_args : [nodelete_link_args, no_undefined_link_args ], - link_with : extra_libs, - name_prefix : '', - implicit_include_directories : false) --- -2.35.1 - diff --git a/pkgs/servers/pulseaudio/0007-Fix-link-args-on-darwin.patch b/pkgs/servers/pulseaudio/0007-Fix-link-args-on-darwin.patch new file mode 100644 index 00000000000..30a11adca08 --- /dev/null +++ b/pkgs/servers/pulseaudio/0007-Fix-link-args-on-darwin.patch @@ -0,0 +1,75 @@ +diff --git a/meson.build b/meson.build +index c5135330f..1b66a1fc4 100644 +--- a/meson.build ++++ b/meson.build +@@ -424,7 +424,7 @@ cdata.set('MESON_BUILD', 1) + # so we request the nodelete flag to be enabled. + # On other systems, we don't really know how to do that, but it's welcome if somebody can tell. + # Windows doesn't support this flag. +-if host_machine.system() != 'windows' ++if host_machine.system() not in ['windows', 'darwin'] + nodelete_link_args = ['-Wl,-z,nodelete'] + else + nodelete_link_args = [] +diff --git a/src/modules/echo-cancel/meson.build b/src/modules/echo-cancel/meson.build +index 641cd35e7..523bffac4 100644 +--- a/src/modules/echo-cancel/meson.build ++++ b/src/modules/echo-cancel/meson.build +@@ -10,12 +10,17 @@ libwebrtc_util_sources = [ + 'webrtc.cc' + ] + ++ignore_unresolved_symbols_link_args = ['-Wl,--unresolved-symbols=ignore-in-object-files'] ++if meson.get_compiler('c').get_linker_id() == 'ld64' ++ ignore_unresolved_symbols_link_args = [ '-Wl,-undefined,dynamic_lookup' ] ++endif ++ + libwebrtc_util = shared_library('webrtc-util', + libwebrtc_util_sources, + cpp_args : [pa_c_args, server_c_args], + include_directories : [configinc, topinc], + dependencies : [libpulse_dep, libpulsecommon_dep, libpulsecore_dep, libatomic_ops_dep, webrtc_dep, libintl_dep], +- link_args : [nodelete_link_args, '-Wl,--unresolved-symbols=ignore-in-object-files'], ++ link_args : [nodelete_link_args, ignore_unresolved_symbols_link_args], + install : true, + install_rpath : privlibdir, + install_dir : modlibexecdir, +diff --git a/src/modules/meson.build b/src/modules/meson.build +index 1e12569dc..66f3e46a4 100644 +--- a/src/modules/meson.build ++++ b/src/modules/meson.build +@@ -298,6 +298,11 @@ all_modules += [ + # FIXME: meson doesn't support multiple RPATH arguments currently + rpath_dirs = join_paths(privlibdir) + ':' + join_paths(modlibexecdir) + ++no_undefined_link_args = ['-Wl,--no-undefined'] ++if meson.get_compiler('c').get_linker_id() == 'ld64' ++ no_undefined_link_args = [ '-Wl,-undefined,error' ] ++endif ++ + foreach m : all_modules + name = m[0] + sources = m[1] +@@ -315,7 +320,7 @@ foreach m : all_modules + install_rpath : rpath_dirs, + install_dir : modlibexecdir, + dependencies : [thread_dep, libpulse_dep, libpulsecommon_dep, libpulsecore_dep, libintl_dep, platform_dep, platform_socket_dep] + extra_deps, +- link_args : [nodelete_link_args, '-Wl,--no-undefined' ], ++ link_args : [nodelete_link_args, no_undefined_link_args ], + link_with : extra_libs, + name_prefix : '', + implicit_include_directories : false) +diff --git a/src/pulse/meson.build b/src/pulse/meson.build +index 1b82c807c..938e4addd 100644 +--- a/src/pulse/meson.build ++++ b/src/pulse/meson.build +@@ -75,6 +75,9 @@ run_target('update-map-file', + [ libpulse_headers, 'simple.h', join_paths(meson.build_root(), 'src', 'pulse', 'version.h') ] ]) + + versioning_link_args = '-Wl,-version-script=' + join_paths(meson.source_root(), 'src', 'pulse', 'map-file') ++if meson.get_compiler('c').get_linker_id() == 'ld64' ++ versioning_link_args = [] ++endif + + libpulse = shared_library('pulse', + libpulse_sources, diff --git a/pkgs/servers/pulseaudio/0008-Use-correct-semaphore-on-darwin.patch b/pkgs/servers/pulseaudio/0008-Use-correct-semaphore-on-darwin.patch deleted file mode 100644 index 27453466562..00000000000 --- a/pkgs/servers/pulseaudio/0008-Use-correct-semaphore-on-darwin.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 1a840b6e517004c902dfbea3d358b344c9588978 Mon Sep 17 00:00:00 2001 -From: Andrew Childs <andrew.childs@bibo.com.ph> -Date: Tue, 19 Apr 2022 17:49:08 +0900 -Subject: [PATCH 8/8] Use correct semaphore on darwin - ---- - src/meson.build | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/src/meson.build b/src/meson.build -index 5bd68cb12..041e2fab4 100644 ---- a/src/meson.build -+++ b/src/meson.build -@@ -183,9 +183,13 @@ else - libpulsecommon_sources += [ - 'pulsecore/mutex-posix.c', - 'pulsecore/poll-posix.c', -- 'pulsecore/semaphore-posix.c', - 'pulsecore/thread-posix.c' - ] -+ if host_machine.system() == 'darwin' -+ libpulsecommon_sources += [ 'pulsecore/semaphore-osx.c' ] -+ else -+ libpulsecommon_sources += [ 'pulsecore/semaphore-posix.c' ] -+ endif - endif - # FIXME: Do SIMD things - --- -2.35.1 - diff --git a/pkgs/servers/pulseaudio/default.nix b/pkgs/servers/pulseaudio/default.nix index 95ee97ef6c8..2a1bd3c70fb 100644 --- a/pkgs/servers/pulseaudio/default.nix +++ b/pkgs/servers/pulseaudio/default.nix @@ -9,7 +9,7 @@ , x11Support ? false -, useSystemd ? true +, useSystemd ? stdenv.isLinux , # Whether to support the JACK sound system as a backend. jackaudioSupport ? false @@ -19,17 +19,20 @@ , airtunesSupport ? false -, bluetoothSupport ? true +, bluetoothSupport ? stdenv.isLinux , advancedBluetoothCodecs ? false , remoteControlSupport ? false , zeroconfSupport ? false +, alsaSupport ? stdenv.isLinux +, udevSupport ? stdenv.isLinux + , # Whether to build only the library. libOnly ? false -, AudioUnit, Cocoa, CoreServices +, AudioUnit, Cocoa, CoreServices, CoreAudio }: stdenv.mkDerivation rec { @@ -45,18 +48,15 @@ stdenv.mkDerivation rec { # Install sysconfdir files inside of the nix store, # but use a conventional runtime sysconfdir outside the store ./add-option-for-installation-sysconfdir.patch - ] ++ lib.optionals stdenv.isDarwin [ # https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/654 - ./0001-Make-gio-2.0-optional-when-gsettings-is-disabled.patch - + (./0001-Make-gio-2.0-optional-${lib.versions.major version}.patch) # TODO (not sent upstream) - ./0002-Ignore-SCM_CREDS-on-macOS.patch - ./0003-Disable-z-nodelete-on-darwin.patch - ./0004-Prefer-clock_gettime.patch - ./0005-Include-poll-posix.c-on-darwin.patch - ./0006-Only-use-version-script-on-GNU-ish-linkers.patch - ./0007-Adapt-undefined-link-args-per-linker.patch - ./0008-Use-correct-semaphore-on-darwin.patch + ./0002-Ignore-SCM_CREDS-on-darwin.patch + ./0003-Ignore-HAVE_CPUID_H-on-aarch64-darwin.patch + ./0004-Prefer-HAVE_CLOCK_GETTIME-on-darwin.patch + ./0005-Enable-CoreAudio-on-darwin.patch + ./0006-Fix-libpulsecommon-sources-on-darwin.patch + ./0007-Fix-link-args-on-darwin.patch ]; outputs = [ "out" "dev" ]; @@ -72,7 +72,7 @@ stdenv.mkDerivation rec { buildInputs = [ libtool libsndfile soxr speexdsp fftwFloat check ] ++ lib.optionals stdenv.isLinux [ glib dbus ] - ++ lib.optionals stdenv.isDarwin [ AudioUnit Cocoa CoreServices libintl ] + ++ lib.optionals stdenv.isDarwin [ AudioUnit Cocoa CoreServices CoreAudio libintl ] ++ lib.optionals (!libOnly) ( [ libasyncns webrtc-audio-processing ] ++ lib.optional jackaudioSupport libjack2 @@ -88,7 +88,7 @@ stdenv.mkDerivation rec { ); mesonFlags = [ - "-Dalsa=${if !libOnly then "enabled" else "disabled"}" + "-Dalsa=${if !libOnly && alsaSupport then "enabled" else "disabled"}" "-Dasyncns=${if !libOnly then "enabled" else "disabled"}" "-Davahi=${if zeroconfSupport then "enabled" else "disabled"}" "-Dbluez5=${if !libOnly && bluetoothSupport then "enabled" else "disabled"}" @@ -107,7 +107,7 @@ stdenv.mkDerivation rec { "-Dorc=disabled" "-Dsystemd=${if useSystemd && !libOnly then "enabled" else "disabled"}" "-Dtcpwrap=disabled" - "-Dudev=${if !libOnly then "enabled" else "disabled"}" + "-Dudev=${if !libOnly && udevSupport then "enabled" else "disabled"}" "-Dvalgrind=disabled" "-Dwebrtc-aec=${if !libOnly then "enabled" else "disabled"}" "-Dx11=${if x11Support then "enabled" else "disabled"}" @@ -118,7 +118,7 @@ stdenv.mkDerivation rec { "-Dudevrulesdir=${placeholder "out"}/lib/udev/rules.d" ] ++ lib.optional (stdenv.isLinux && useSystemd) "-Dsystemduserunitdir=${placeholder "out"}/lib/systemd/user" - ++ lib.optionals (stdenv.isDarwin) [ + ++ lib.optionals stdenv.isDarwin [ "-Ddbus=disabled" "-Dglib=disabled" "-Doss-output=disabled" @@ -144,10 +144,21 @@ stdenv.mkDerivation rec { wrapProgram $out/libexec/pulse/gsettings-helper \ --prefix XDG_DATA_DIRS : "$out/share/gsettings-schemas/${pname}-${version}" \ --prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules" + '' + # add .so symlinks for modules to be found under macOS + + lib.optionalString stdenv.isDarwin '' + for file in $out/${passthru.pulseDir}/modules/*.dylib; do + ln -s "''$file" "''${file%.dylib}.so" + ln -s "''$file" "$out/lib/pulseaudio/''$(basename ''$file .dylib).so" + done ''; passthru = { - pulseDir = "lib/pulse-" + lib.versions.majorMinor version; + pulseDir = + if (lib.versionAtLeast version "16.0") then + "lib/pulseaudio" + else + "lib/pulse-" + lib.versions.majorMinor version; }; meta = { |