git.iko.soy/typeable/nixpkgs
on master help sign in
libjack2: fix darwin build
commit7d98316a9745ae6538f90dc580b0873074dfd5e5 authorDaiderd Jordan <daiderd@gmail.com> dateMon 18 Sep 2017, 23:15 (9 years ago) parentbb02b80
4 files changed+95−5
pkgs/misc/jackaudio/clang.patch+22 pkgs/misc/jackaudio/darwin-cf.patch+49 pkgs/misc/jackaudio/default.nix+23−5 pkgs/top-level/all-packages.nix+1
pkgs/misc/jackaudio/clang.patchnew file+22
@@ -0,0 +1,22 @@
1+diff --git a/tests/test.cpp b/tests/test.cpp
2+index 8a8a811..31e8459 100644
3+--- a/tests/test.cpp
4++++ b/tests/test.cpp
5+@@ -479,7 +479,7 @@ int process4(jack_nframes_t nframes, void *arg)
6+ jack_nframes_t delta_time = cur_time - last_time;
7+
8+ Log("calling process4 callback : jack_frame_time = %ld delta_time = %ld\n", cur_time, delta_time);
9+- if (delta_time > 0 && (jack_nframes_t)abs(delta_time - cur_buffer_size) > tolerance) {
10++ if (delta_time > 0 && (jack_nframes_t)fabs(delta_time - cur_buffer_size) > tolerance) {
11+ printf("!!! ERROR !!! jack_frame_time seems to return incorrect values cur_buffer_size = %d, delta_time = %d tolerance %d\n", cur_buffer_size, delta_time, tolerance);
12+ }
13+
14+@@ -1064,7 +1064,7 @@ int main (int argc, char *argv[])
15+ }
16+ jack_sleep(1 * 1000);
17+ cur_buffer_size = jack_get_buffer_size(client1);
18+- if (abs((old_buffer_size * factor) - cur_buffer_size) > 5) { // Tolerance needed for dummy driver...
19++ if (fabs((old_buffer_size * factor) - cur_buffer_size) > 5) { // Tolerance needed for dummy driver...
20+ printf("!!! ERROR !!! Buffer size has not been changed !\n");
21+ printf("!!! Maybe jack was compiled without the '--enable-resize' flag...\n");
22+ } else {
pkgs/misc/jackaudio/darwin-cf.patchnew file+49
@@ -0,0 +1,49 @@
1+diff --git a/common/Jackdmp.cpp b/common/Jackdmp.cpp
2+index 7eea281..4b8d75d 100644
3+--- a/common/Jackdmp.cpp
4++++ b/common/Jackdmp.cpp
5+@@ -50,43 +50,11 @@ are "hard-coded" in the source. A much better approach would be to use the contr
6+ - get available drivers and their possible parameters, then prepare to parse them.
7+ */
8+
9+-#ifdef __APPLE__
10+-#include <CoreFoundation/CFNotificationCenter.h>
11+-#include <CoreFoundation/CoreFoundation.h>
12+-
13+-static void notify_server_start(const char* server_name)
14+-{
15+- // Send notification to be used in the JackRouter plugin
16+- CFStringRef ref = CFStringCreateWithCString(NULL, server_name, kCFStringEncodingMacRoman);
17+- CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterGetDistributedCenter(),
18+- CFSTR("com.grame.jackserver.start"),
19+- ref,
20+- NULL,
21+- kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions);
22+- CFRelease(ref);
23+-}
24+-
25+-static void notify_server_stop(const char* server_name)
26+-{
27+- // Send notification to be used in the JackRouter plugin
28+- CFStringRef ref1 = CFStringCreateWithCString(NULL, server_name, kCFStringEncodingMacRoman);
29+- CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterGetDistributedCenter(),
30+- CFSTR("com.grame.jackserver.stop"),
31+- ref1,
32+- NULL,
33+- kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions);
34+- CFRelease(ref1);
35+-}
36+-
37+-#else
38+-
39+ static void notify_server_start(const char* server_name)
40+ {}
41+ static void notify_server_stop(const char* server_name)
42+ {}
43+
44+-#endif
45+-
46+ static void copyright(FILE* file)
47+ {
48+ fprintf(file, "jackdmp " VERSION "\n"
49+
pkgs/misc/jackaudio/default.nix+23−5
@@ -1,9 +1,12 @@
11{ stdenv, fetchFromGitHub, pkgconfig, python2Packages, makeWrapper
22, bash, libsamplerate, libsndfile, readline, eigen, celt
3+# Darwin Dependencies
4+, aften, AudioToolbox, CoreAudio, CoreFoundation
35
46# Optional Dependencies
57, dbus ? null, libffado ? null, alsaLib ? null
68, libopus ? null
9+, darwin
710
811# Extra options
912, prefix ? ""
@@ -16,7 +19,7 @@ let
1619
1720 libOnly = prefix == "lib";
1821
19− optDbus = shouldUsePkg dbus;
22+ optDbus = if stdenv.isDarwin then null else shouldUsePkg dbus;
2023 optPythonDBus = if libOnly then null else shouldUsePkg dbus-python;
2124 optLibffado = if libOnly then null else shouldUsePkg libffado;
2225 optAlsaLib = if libOnly then null else shouldUsePkg alsaLib;
@@ -34,21 +37,36 @@ stdenv.mkDerivation rec {
3437 };
3538
3639 nativeBuildInputs = [ pkgconfig python makeWrapper ];
37− buildInputs = [ python libsamplerate libsndfile readline eigen celt
40+ buildInputs = [ libsamplerate libsndfile readline eigen celt
3841 optDbus optPythonDBus optLibffado optAlsaLib optLibopus
39− ];
42+ ] ++ stdenv.lib.optionals stdenv.isDarwin [ aften AudioToolbox CoreAudio CoreFoundation ];
4043
41− patchPhase = ''
42− substituteInPlace svnversion_regenerate.sh --replace /bin/bash ${bash}/bin/bash
44+ # CoreFoundation 10.10 doesn't include CFNotificationCenter.h yet.
45+ patches = stdenv.lib.optionals stdenv.isDarwin [ ./clang.patch ./darwin-cf.patch ];
46+
47+ prePatch = ''
48+ substituteInPlace svnversion_regenerate.sh \
49+ --replace /bin/bash ${bash}/bin/bash
50+ '';
51+
52+ # It looks like one of the frameworks depends on <CoreFoundation/CFAttributedString.h>
53+ # since frameworks are impure we also have to use the impure CoreFoundation here.
54+ # FIXME: remove when CoreFoundation is updated to 10.11
55+ preConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
56+ export NIX_CFLAGS_COMPILE="-F${CoreFoundation}/Library/Frameworks $NIX_CFLAGS_COMPILE"
4357 '';
4458
4559 configurePhase = ''
60+ runHook preConfigure
61+
4662 python waf configure --prefix=$out \
4763 ${optionalString (optDbus != null) "--dbus"} \
4864 --classic \
4965 ${optionalString (optLibffado != null) "--firewire"} \
5066 ${optionalString (optAlsaLib != null) "--alsa"} \
5167 --autostart=${if (optDbus != null) then "dbus" else "classic"} \
68+
69+ runHook postConfigure
5270 '';
5371
5472 buildPhase = ''
pkgs/top-level/all-packages.nix+1
@@ -18886,6 +18886,7 @@ with pkgs;
1888618886
1888718887 jack2Full = callPackage ../misc/jackaudio {
1888818888 libopus = libopus.override { withCustomModes = true; };
18889+ inherit (darwin.apple_sdk.frameworks) AudioToolbox CoreAudio CoreFoundation;
1888918890 };
1889018891 libjack2 = jack2Full.override { prefix = "lib"; };
1889118892