[jitsi~svn:10187] First part of automatic audio system change: only if the "none" audio sys

vincent_lucas at java.net vincent_lucas at java.net
Fri Dec 14 19:46:25 CET 2012


Project:    jitsi
Repository: svn
Revision:   10187
Author:     vincent_lucas
Date:       2012-12-14 18:46:23 UTC
Link:       

Log Message:
------------
First part of automatic audio system change: only if the "none" audio system is currently selected and another audio sytem becomes available (a new device has been detected).


Revisions:
----------
10187


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 10186)
+++ trunk/src/net/java/sip/communicator/impl/neomedia/DeviceConfigurationComboBoxModel.java	(revision 10187)
@@ -29,8 +29,7 @@
  */
 public class DeviceConfigurationComboBoxModel
     implements ComboBoxModel,
-               PropertyChangeListener,
-               HierarchyListener
+               PropertyChangeListener
 {
     /**
      * Encapsulates a <tt>CaptureDeviceInfo</tt> for the purposes of its display
@@ -186,8 +185,6 @@
             || type == AUDIO_PLAYBACK)
         {
             deviceConfiguration.addPropertyChangeListener(this);
-
-            parent.addHierarchyListener(this);
         }
     }
 
@@ -466,18 +463,4 @@
             fireContentsChanged(0, getSize() - 1);
         }
     }
-
-    /**
-     * We listen when the component was hidden in order to release resources,
-     * remove listener to clean this instance.
-     * @param e the event.
-     */
-    public void hierarchyChanged(HierarchyEvent e)
-    {
-       if (((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0)
-               && !parent.isShowing())
-       {
-           deviceConfiguration.removePropertyChangeListener(this);
-       }
-   }
 }
Index: libjitsi/src/org/jitsi/impl/neomedia/device/DeviceConfiguration.java
===================================================================
--- libjitsi/src/org/jitsi/impl/neomedia/device/DeviceConfiguration.java	(revision 10186)
+++ libjitsi/src/org/jitsi/impl/neomedia/device/DeviceConfiguration.java	(revision 10187)
@@ -1012,6 +1012,11 @@
                 || AUDIO_NOTIFY_DEVICE.equals(propertyName)
                 || AUDIO_PLAYBACK_DEVICE.equals(propertyName))
         {
+            // Try to switch to a new active audio system if we are currently
+            // using the "none" system.
+            switchFromNoneToActiveAudioSystem(
+                    (CaptureDeviceInfo) event.getNewValue());
+
             CaptureDeviceInfo deviceInfo
                 = (CaptureDeviceInfo) event.getOldValue();
             if(deviceInfo == null)
@@ -1186,4 +1191,41 @@
             }
         }
     }
+
+    /**
+     * Tries to automatically switch from the none audio system to a new active
+     * audio system: detected by an event showing that there is at least one
+     * device active for this system.
+     *
+     * @param newActiveDevice A device that have been recently detected has
+     * available.
+     */
+    private void switchFromNoneToActiveAudioSystem(
+            CaptureDeviceInfo newActiveDevice)
+    {
+        if(newActiveDevice != null)
+        {
+            String deviceSystemProtocol
+                = newActiveDevice.getLocator().getProtocol();
+            // If we are currently using the "none" system, and that the new
+            // available device uses a different system: then switch to the new
+            // audio system.
+            if(!deviceSystemProtocol.equals(NoneAudioSystem.LOCATOR_PROTOCOL)
+                && getAudioSystem().getLocatorProtocol().equals(
+                    NoneAudioSystem.LOCATOR_PROTOCOL))
+            {
+                // If the AUDIO media type is disabled via
+                // MediaServiceImpl.DISABLE_AUDIO_SUPPORT_PNAME, then the
+                // DeviceSystem.initializeDeviceSystems will not instantiante
+                // any other audio system (except the "none" one). Thereby, the
+                // Audio.getAudioSystem will return null.
+                AudioSystem deviceAudioSystem
+                    = AudioSystem.getAudioSystem(deviceSystemProtocol);
+                if(deviceAudioSystem != null)
+                {
+                    setAudioSystem(deviceAudioSystem, false);
+                }
+            }
+        }
+    }
 }







More information about the commits mailing list