Show informative message when loading PortAudio on MacOS (see #85) · processing/processing-sound@843cacf (original) (raw)

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -65,8 +65,7 @@
65 65 </patternset>
66 66 <mapper type="flatten"/>
67 67 </unzip>
68 -
69 - <unzip src="${lib}/jportaudio_mac_20120904.zip" dest="${lib}/">
68 + <unzip src="${lib}/jportaudio_mac_20120904.zip" dest="${lib}/macos-x86_64/">
70 69 <patternset>
71 70 <include name="**/*.jnilib" />
72 71 </patternset>
Original file line number Diff line number Diff line change
@@ -73,7 +73,18 @@ public void write(int b) { }
73 73 try {
74 74 return new JPortAudioDevice();
75 75 } catch (UnsatisfiedLinkError e) {
76 -// e.printStackTrace();
76 +// on loading PortAudio the first time on Mac, an exception with the
77 +// following message is thrown:
78 +// no suitable image found. Did find:
79 +// ~/Documents/Processing/libraries/sound/library/macos-x86_64/libjportaudio.jnilib:
80 +// code signature in
81 +// (~/Documents/Processing/libraries/sound/library/macos-x86_64/libjportaudio.jnilib)
82 +// not valid for use in process using Library Validation: library load
83 +// disallowed by system policy at
84 +// java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
85 +if (e.getMessage().contains("disallowed")) {
86 +throw new RuntimeException("in order to use the PortAudio drivers, you need to give Processing permission to open the PortAudio library file.\n\n============================== ENABLING PORTAUDIO ON MAC OS X ==============================\n\nPlease follow these steps to enable PortAudio (dont worry, you only need to do this once):\n\n - if you pressed 'Move to Bin' in the previous popup, you will need first need to restore\n the library file: please find libjportaudio.jnilib in your Bin, right click and select 'Put Back'\n\n - go to System Preferences > Security & Privacy> General. At the bottom you will see\na message saying that 'libjportaudio.jnilib was blocked'. Press 'Allow Anyway'. When you\nrun this sketch again you should get another popup, just select 'Open' and you're done!\n\n============================================================================================");
87 + }
77 88 throw new RuntimeException("PortAudio is not supported on this operating system/architecture");
78 89 } finally {
79 90 System.setOut(originalStream);