[jitsi~svn:10176] Activates update for reloadable audio systems in order to activate them i

vincent_lucas at java.net vincent_lucas at java.net
Thu Dec 13 17:44:38 CET 2012


Project:    jitsi
Repository: svn
Revision:   10176
Author:     vincent_lucas
Date:       2012-12-13 16:44:34 UTC
Link:       

Log Message:
------------
Activates update for reloadable audio systems in order to activate them if the number of devices changes from 0 to something greater.


Revisions:
----------
10176


Modified Paths:
---------------
trunk/src/net/java/sip/communicator/impl/neomedia/DeviceConfigurationComboBoxModel.java
trunk/lib/installer-exclude/libjitsi.jar
libjitsi/src/org/jitsi/impl/neomedia/device/DeviceConfiguration.java


Diffs:
------
Index: trunk/lib/installer-exclude/libjitsi.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/src/net/java/sip/communicator/impl/neomedia/DeviceConfigurationComboBoxModel.java
===================================================================
--- trunk/src/net/java/sip/communicator/impl/neomedia/DeviceConfigurationComboBoxModel.java	(revision 10175)
+++ trunk/src/net/java/sip/communicator/impl/neomedia/DeviceConfigurationComboBoxModel.java	(revision 10176)
@@ -226,8 +226,11 @@
         if (type != AUDIO)
             throw new IllegalStateException("type");
 
-        if (audioSystems == null)
-            audioSystems = deviceConfiguration.getAvailableAudioSystems();
+        // This must updated at each call to allows hotplug device system to be
+        // enabled (if the number of devices change to someting greater than 0)
+        // or disabled (if the number of available device changes to 0).
+        audioSystems = deviceConfiguration.getAvailableAudioSystems();
+
         return audioSystems;
     }
 
Index: libjitsi/src/org/jitsi/impl/neomedia/device/DeviceConfiguration.java
===================================================================
--- libjitsi/src/org/jitsi/impl/neomedia/device/DeviceConfiguration.java	(revision 10175)
+++ libjitsi/src/org/jitsi/impl/neomedia/device/DeviceConfiguration.java	(revision 10176)
@@ -209,6 +209,9 @@
      */
     public static final String VIDEO_CAPTURE_DEVICE = "VIDEO_CAPTURE_DEVICE";
 
+    /**
+     * The currently selected audio system.
+     */
     private AudioSystem audioSystem;
 
     /**
@@ -265,6 +268,9 @@
 
         registerCustomRenderers();
         fixRenderers();
+
+        //Registers this device configuration to all reloadable device sytem.
+        registerToDeviceSystemPropertyChangeListener();
     }
 
     /**
@@ -491,15 +497,27 @@
     {
         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 @@
                 || 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 @@
                 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);
+                    }
+                }
+            }
+        }
+    }
 }







More information about the commits mailing list