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

Activates update for reloadable audio systems in order to activate them if the...

Activates update for reloadable audio systems in order to activate them if the number of devices changes from 0 to something greater.
parent 18f1afab
No related branches found
No related tags found
No related merge requests found
......@@ -209,6 +209,9 @@ public class DeviceConfiguration
*/
public static final String VIDEO_CAPTURE_DEVICE = "VIDEO_CAPTURE_DEVICE";
/**
* The currently selected audio system.
*/
private AudioSystem audioSystem;
/**
......@@ -265,6 +268,9 @@ public DeviceConfiguration()
registerCustomRenderers();
fixRenderers();
//Registers this device configuration to all reloadable device sytem.
registerToDeviceSystemPropertyChangeListener();
}
/**
......@@ -491,15 +497,27 @@ public void setAudioSystem(AudioSystem audioSystem, boolean save)
{
if (this.audioSystem != audioSystem)
{
if (this.audioSystem != null)
// Removes the registration to change listener only if this audio
// sytem does not supports reinitialize.
if (this.audioSystem != null
&& (this.audioSystem.getFeatures()
& DeviceSystem.FEATURE_REINITIALIZE) == 0)
{
this.audioSystem.removePropertyChangeListener(this);
}
AudioSystem oldValue = this.audioSystem;
this.audioSystem = audioSystem;
// Registers the new selected audio system. Even if every
// reloadable audio systems are already registered, the check for
// dupplicate entries will be done by the addPropertyChangeListener
// function.
if (this.audioSystem != null)
{
this.audioSystem.addPropertyChangeListener(this);
}
if (save)
{
......@@ -994,10 +1012,24 @@ public void propertyChange(PropertyChangeEvent event)
|| AUDIO_NOTIFY_DEVICE.equals(propertyName)
|| AUDIO_PLAYBACK_DEVICE.equals(propertyName))
{
firePropertyChange(
propertyName,
event.getOldValue(),
event.getNewValue());
CaptureDeviceInfo deviceInfo
= (CaptureDeviceInfo) event.getOldValue();
if(deviceInfo == null)
{
deviceInfo = (CaptureDeviceInfo) event.getNewValue();
}
// Fire an event on the selected device, only if the event is
// generated by the selected audio system.
if(deviceInfo == null
|| deviceInfo.getLocator().getProtocol().equals(
getAudioSystem().getLocatorProtocol()))
{
firePropertyChange(
propertyName,
event.getOldValue(),
event.getNewValue());
}
}
else if (DeviceSystem.PROP_DEVICES.equals(propertyName))
{
......@@ -1125,4 +1157,33 @@ private void extractConfiguredVideoCaptureDevices()
logger.info("No Video Device was found.");
}
}
/**
* Registers this device configuration to all reloadable device sytem, in
* order to receive events from device systems which are not currently
* selected. I.e. a device system which changes its number of device from 0
* to 1 or more, is becoming available and can be selected by the user.
*/
private void registerToDeviceSystemPropertyChangeListener()
{
// Look at all kind of device systems: audio and video.
for(MediaType mediaType: MediaType.values())
{
DeviceSystem[] deviceSystems
= DeviceSystem.getDeviceSystems(mediaType);
if(deviceSystems != null)
{
for (DeviceSystem deviceSystem : deviceSystems)
{
// If the device system is reloadable, then register this
// device configuration.
if((deviceSystem.getFeatures()
& DeviceSystem.FEATURE_REINITIALIZE) != 0)
{
deviceSystem.addPropertyChangeListener(this);
}
}
}
}
}
}
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