Skip to content

Commit

Permalink
Show informative message when loading PortAudio on MacOS (see #85)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinstadler committed Sep 29, 2023
1 parent cc2c8c3 commit 843cacf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 1 addition & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
</patternset>
<mapper type="flatten"/>
</unzip>
<!-- the mac libraries need to go into library/ rather than the sub-directory... -->
<unzip src="${lib}/jportaudio_mac_20120904.zip" dest="${lib}/">
<unzip src="${lib}/jportaudio_mac_20120904.zip" dest="${lib}/macos-x86_64/">
<patternset>
<include name="**/*.jnilib" />
</patternset>
Expand Down
13 changes: 12 additions & 1 deletion src/processing/sound/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,18 @@ public void write(int b) { }
try {
return new JPortAudioDevice();
} catch (UnsatisfiedLinkError e) {
// e.printStackTrace();
// on loading PortAudio the first time on Mac, an exception with the
// following message is thrown:
// no suitable image found. Did find:
// ~/Documents/Processing/libraries/sound/library/macos-x86_64/libjportaudio.jnilib:
// code signature in
// (~/Documents/Processing/libraries/sound/library/macos-x86_64/libjportaudio.jnilib)
// not valid for use in process using Library Validation: library load
// disallowed by system policy at
// java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
if (e.getMessage().contains("disallowed")) {
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============================================================================================");
}
throw new RuntimeException("PortAudio is not supported on this operating system/architecture");
} finally {
System.setOut(originalStream);
Expand Down

0 comments on commit 843cacf

Please sign in to comment.