Skip to content
Snippets Groups Projects
Commit 140730d9 authored by Vincent Lucas's avatar Vincent Lucas
Browse files

Corrects PortAudio not running on Linux: checks if CoreAudio is supported for the current system.

parent 83c2a25a
No related branches found
No related tags found
No related merge requests found
...@@ -15,20 +15,32 @@ ...@@ -15,20 +15,32 @@
*/ */
public class CoreAudioDevice public class CoreAudioDevice
{ {
/**
* Loads CoreAudioDevice if we are using MacOsX or Windows Vista/7/8.
*/
static static
{ {
isLoaded = false;
if(OSUtils.IS_MAC) if(OSUtils.IS_MAC)
{ {
System.loadLibrary("jnmaccoreaudio"); System.loadLibrary("jnmaccoreaudio");
isLoaded = true;
} }
else if(OSUtils.IS_WINDOWS_VISTA else if(OSUtils.IS_WINDOWS_VISTA
|| OSUtils.IS_WINDOWS_7 || OSUtils.IS_WINDOWS_7
|| OSUtils.IS_WINDOWS_8) || OSUtils.IS_WINDOWS_8)
{ {
System.loadLibrary("jnwincoreaudio"); System.loadLibrary("jnwincoreaudio");
isLoaded = true;
} }
} }
/**
* Tells if the CoreAudio library used by this CoreAudioDevice is correctly
* loaded: if we are under a supported operating system.
*/
public static boolean isLoaded;
public static native int initDevices(); public static native int initDevices();
public static native void freeDevices(); public static native void freeDevices();
......
...@@ -264,7 +264,8 @@ protected void doInitialize() ...@@ -264,7 +264,8 @@ protected void doInitialize()
= new LinkedList<ExtendedCaptureDeviceInfo>(); = new LinkedList<ExtendedCaptureDeviceInfo>();
final boolean loggerIsDebugEnabled = logger.isDebugEnabled(); final boolean loggerIsDebugEnabled = logger.isDebugEnabled();
CoreAudioDevice.initDevices(); if(CoreAudioDevice.isLoaded)
CoreAudioDevice.initDevices();
for (int deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++) for (int deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++)
{ {
long deviceInfo = Pa.GetDeviceInfo(deviceIndex); long deviceInfo = Pa.GetDeviceInfo(deviceIndex);
...@@ -281,8 +282,10 @@ protected void doInitialize() ...@@ -281,8 +282,10 @@ protected void doInitialize()
= Pa.DeviceInfo_getTransportType(deviceInfo); = Pa.DeviceInfo_getTransportType(deviceInfo);
String deviceUID String deviceUID
= Pa.DeviceInfo_getDeviceUID(deviceInfo); = Pa.DeviceInfo_getDeviceUID(deviceInfo);
String modelIdentifier String modelIdentifier = null;
= CoreAudioDevice.getDeviceModelIdentifier(deviceUID); if(CoreAudioDevice.isLoaded)
modelIdentifier
= CoreAudioDevice.getDeviceModelIdentifier(deviceUID);
/* /*
* TODO The intention of reinitialize() was to perform the * TODO The intention of reinitialize() was to perform the
...@@ -398,7 +401,8 @@ else if (maxOutputChannels > 0) ...@@ -398,7 +401,8 @@ else if (maxOutputChannels > 0)
} }
} }
} }
CoreAudioDevice.freeDevices(); if(CoreAudioDevice.isLoaded)
CoreAudioDevice.freeDevices();
/* /*
* Make sure that devices which support both capture and playback are * Make sure that devices which support both capture and playback are
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment