Skip to content

Commit 843cacf

Browse files
committed
Show informative message when loading PortAudio on MacOS (see #85)
1 parent cc2c8c3 commit 843cacf

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

build.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@
6565
</patternset>
6666
<mapper type="flatten"/>
6767
</unzip>
68-
<!-- the mac libraries need to go into library/ rather than the sub-directory... -->
69-
<unzip src="${lib}/jportaudio_mac_20120904.zip" dest="${lib}/">
68+
<unzip src="${lib}/jportaudio_mac_20120904.zip" dest="${lib}/macos-x86_64/">
7069
<patternset>
7170
<include name="**/*.jnilib" />
7271
</patternset>

src/processing/sound/Engine.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,18 @@ public void write(int b) { }
7373
try {
7474
return new JPortAudioDevice();
7575
} 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+
}
7788
throw new RuntimeException("PortAudio is not supported on this operating system/architecture");
7889
} finally {
7990
System.setOut(originalStream);

0 commit comments

Comments
 (0)