Improves device selection via portaudio for MacOSX (hostapi coreaudio): adds the possibility to get the device transport type (USB, bluetooth, etc.) and an unique identifier. Corrects problems when: loading the same device twice (for the moment only for the same hostapi), a new plugged device is selected during a call or if the selected device is unchanged.

cusax-fix
Vincent Lucas 14 years ago
parent 34b1e043bb
commit 59b514e323

@ -415,8 +415,6 @@
<compilerarg value="x86_64" if="is.running.macos" />
<compilerarg value="-arch" if="is.running.macos" />
<compilerarg value="i386" if="is.running.macos" />
<compilerarg value="-arch" if="is.running.macos" />
<compilerarg value="ppc" if="is.running.macos" />
<compilerarg value="-I/System/Library/Frameworks/JavaVM.framework/Headers" if="is.running.macos" />
<linkerarg value="-o" location="end" if="is.running.macos" />
@ -426,8 +424,6 @@
<linkerarg value="x86_64" if="is.running.macos" />
<linkerarg value="-arch" if="is.running.macos" />
<linkerarg value="i386" if="is.running.macos" />
<linkerarg value="-arch" if="is.running.macos" />
<linkerarg value="ppc" if="is.running.macos" />
<linkerarg value="-framework" location="end" if="is.running.macos" />
<linkerarg value="AudioToolbox" location="end" if="is.running.macos" />
<linkerarg value="-framework" location="end" if="is.running.macos" />
@ -501,8 +497,6 @@
<compilerarg value="x86_64" if="is.running.macos" />
<compilerarg value="-arch" if="is.running.macos" />
<compilerarg value="i386" if="is.running.macos" />
<compilerarg value="-arch" if="is.running.macos" />
<compilerarg value="ppc" if="is.running.macos" />
<compilerarg value="-I/System/Library/Frameworks/JavaVM.framework/Headers" if="is.running.macos" />
<linkerarg value="-o" location="end" if="is.running.macos" />
@ -512,8 +506,6 @@
<linkerarg value="x86_64" if="is.running.macos" />
<linkerarg value="-arch" if="is.running.macos" />
<linkerarg value="i386" if="is.running.macos" />
<linkerarg value="-arch" if="is.running.macos" />
<linkerarg value="ppc" if="is.running.macos" />
<linkerarg value="-lspeex" location="end" if="is.running.macos" />
<linkerarg value="-lspeexdsp" location="end" if="is.running.macos" />

@ -902,6 +902,62 @@ Java_net_java_sip_communicator_impl_neomedia_portaudio_PortAudio_PaDeviceInfo_1g
return nameBytes;
}
JNIEXPORT jbyteArray JNICALL
Java_net_java_sip_communicator_impl_neomedia_portaudio_PortAudio_PaDeviceInfo_1getTransportTypeBytes
(JNIEnv *env, jclass clazz, jlong deviceInfo)
{
jbyteArray typeBytes = NULL;
if(((PaDeviceInfo *) (intptr_t) deviceInfo)->structVersion >= 3)
{
const char *type
= ((PaDeviceInfo *) (intptr_t) deviceInfo)->transportType;
if(type != NULL)
{
size_t typeLength = strlen(type);
typeBytes = (*env)->NewByteArray(env, typeLength);
if (typeBytes && typeLength)
{
(*env)->SetByteArrayRegion(
env,
typeBytes, 0, typeLength,
(jbyte *) type);
}
}
}
return typeBytes;
}
JNIEXPORT jbyteArray JNICALL
Java_net_java_sip_communicator_impl_neomedia_portaudio_PortAudio_PaDeviceInfo_1getDeviceUIDBytes
(JNIEnv *env, jclass clazz, jlong deviceInfo)
{
jbyteArray uidBytes = NULL;
if(((PaDeviceInfo *) (intptr_t) deviceInfo)->structVersion >= 3)
{
const char *uid
= ((PaDeviceInfo *) (intptr_t) deviceInfo)->deviceUID;
if (uid)
{
size_t uidLength = strlen(uid);
uidBytes = (*env)->NewByteArray(env, uidLength);
if (uidBytes && uidLength)
{
(*env)->SetByteArrayRegion(
env,
uidBytes, 0, uidLength,
(jbyte *) uid);
}
}
}
return uidBytes;
}
JNIEXPORT jint JNICALL
Java_net_java_sip_communicator_impl_neomedia_portaudio_PortAudio_PaHostApiInfo_1getDefaultInputDevice
(JNIEnv *env, jclass clazz, jlong hostApi)

@ -229,6 +229,22 @@ JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_neomedia_portaudio_Po
JNIEXPORT jbyteArray JNICALL Java_net_java_sip_communicator_impl_neomedia_portaudio_PortAudio_PaDeviceInfo_1getNameBytes
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_portaudio_PortAudio
* Method: PaDeviceInfo_getTransportTypeBytes
* Signature: (J)[B
*/
JNIEXPORT jbyteArray JNICALL Java_net_java_sip_communicator_impl_neomedia_portaudio_PortAudio_PaDeviceInfo_1getTransportTypeBytes
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_portaudio_PortAudio
* Method: PaDeviceInfo_getDeviceUIDBytes
* Signature: (J)[B
*/
JNIEXPORT jbyteArray JNICALL Java_net_java_sip_communicator_impl_neomedia_portaudio_PortAudio_PaDeviceInfo_1getDeviceUIDBytes
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_neomedia_portaudio_PortAudio
* Method: PaHostApiInfo_getDefaultInputDevice

@ -35,13 +35,24 @@ public static class CaptureDevice
{
/**
* Compares two CaptureDeviceInfo
* @param a first <tt>CaptureDeviceInfo</tt> to compare
* @param b second <tt>CaptureDeviceInfo</tt> to compare
* @return whether a is equal to b
* @param device The <tt>CaptureDeviceInfo</tt> to compare with.
* @return whether this CaptureDevice is equal to device.
*/
public static boolean equals(CaptureDeviceInfo a, CaptureDeviceInfo b)
public boolean equals(CaptureDeviceInfo device)
{
return (a == null) ? (b == null) : a.equals(b);
if(info == null && device == null)
{
return true;
}
else if(info != null)
{
if(info instanceof ExtendedCaptureDeviceInfo)
{
return ((ExtendedCaptureDeviceInfo) info).equals(device);
}
return info.equals(device);
}
return false;
}
/**
@ -68,11 +79,25 @@ public CaptureDevice(CaptureDeviceInfo info)
@Override
public String toString()
{
return
(info == null)
? NeomediaActivator.getResources().getI18NString(
"impl.media.configform.NO_DEVICE")
: info.getName();
if(info == null)
{
return NeomediaActivator.getResources().getI18NString(
"impl.media.configform.NO_DEVICE");
}
else
{
String deviceString = info.getName();
if(info instanceof ExtendedCaptureDeviceInfo)
{
String transportType
= ((ExtendedCaptureDeviceInfo) info).getTransportType();
if(transportType != null)
{
deviceString += " (" + transportType + ")";
}
}
return deviceString;
}
}
}
@ -217,7 +242,7 @@ private CaptureDevice[] getDevices()
return devices;
AudioSystem audioSystem;
List<CaptureDeviceInfo> infos;
List<? extends CaptureDeviceInfo> infos = null;
switch (type)
{
@ -294,9 +319,14 @@ private CaptureDevice getSelectedDevice()
throw new IllegalStateException("type");
}
for (CaptureDevice device : getDevices())
if (CaptureDevice.equals(device.info, info))
return device;
if(info != null)
{
for (CaptureDevice device : getDevices())
{
if (device.info.equals(info))
return device;
}
}
return null;
}
@ -355,7 +385,7 @@ private void setSelectedDevice(CaptureDevice device)
if (audioSystem != null)
audioSystem.setDevice(
AudioSystem.CAPTURE_INDEX,
device.info,
((ExtendedCaptureDeviceInfo) device.info),
true);
break;
case AUDIO_NOTIFY:
@ -363,7 +393,7 @@ private void setSelectedDevice(CaptureDevice device)
if (audioSystem != null)
audioSystem.setDevice(
AudioSystem.NOTIFY_INDEX,
device.info,
((ExtendedCaptureDeviceInfo) device.info),
true);
break;
case AUDIO_PLAYBACK:
@ -371,7 +401,7 @@ private void setSelectedDevice(CaptureDevice device)
if (audioSystem != null)
audioSystem.setDevice(
AudioSystem.PLAYBACK_INDEX,
device.info,
((ExtendedCaptureDeviceInfo) device.info),
true);
break;
case VIDEO:

Loading…
Cancel
Save