[jitsi~svn:10209] Enables the media configuration dialog to listen to audio system and devi

vincent_lucas at java.net vincent_lucas at java.net
Thu Dec 20 16:02:05 CET 2012


Project:    jitsi
Repository: svn
Revision:   10209
Author:     vincent_lucas
Date:       2012-12-20 15:02:04 UTC
Link:       

Log Message:
------------
Enables the media configuration dialog to listen to audio system and device changes even if the audio system combo box is disabled (via the AUDIO_SYSTEM_DISABLED_PROP portperty).


Revisions:
----------
10209


Modified Paths:
---------------
trunk/src/net/java/sip/communicator/impl/neomedia/MediaConfigurationImpl.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/MediaConfigurationImpl.java
===================================================================
--- trunk/src/net/java/sip/communicator/impl/neomedia/MediaConfigurationImpl.java	(revision 10208)
+++ trunk/src/net/java/sip/communicator/impl/neomedia/MediaConfigurationImpl.java	(revision 10209)
@@ -358,85 +358,89 @@
                 deviceAndPreviewPanel.add(preview, BorderLayout.CENTER);
             }
         }
-        else
-        {
-            final ActionListener deviceComboBoxActionListener
-                = new ActionListener()
+
+        final ActionListener deviceComboBoxActionListener
+            = new ActionListener()
+            {
+                public void actionPerformed(ActionEvent event)
                 {
-                    public void actionPerformed(ActionEvent event)
+                    boolean revalidateAndRepaint = false;
+
+                    for (int i = deviceAndPreviewPanel
+                            .getComponentCount() - 1;
+                            i >= 0;
+                            i--)
                     {
-                        boolean revalidateAndRepaint = false;
+                        Component c = deviceAndPreviewPanel.getComponent(i);
 
-                        for (int i = deviceAndPreviewPanel
-                                .getComponentCount() - 1;
-                                i >= 0;
-                                i--)
+                        if (c != devicePanel)
                         {
-                            Component c = deviceAndPreviewPanel.getComponent(i);
-
-                            if (c != devicePanel)
-                            {
-                                deviceAndPreviewPanel.remove(i);
-                                revalidateAndRepaint = true;
-                            }
+                            deviceAndPreviewPanel.remove(i);
+                            revalidateAndRepaint = true;
                         }
+                    }
 
-                        Component preview = null;
+                    Component preview = null;
 
-                        if ((deviceComboBox.getSelectedItem() != null)
-                                && deviceComboBox.isShowing())
-                        {
-                            preview = createPreview(type, deviceComboBox,
+                    if ((deviceComboBox.getSelectedItem() != null)
+                            && (deviceComboBox.isShowing()
+                                ||
+                                (type == DeviceConfigurationComboBoxModel.AUDIO
+                                 && isAudioSystemComboDisabled)
+                               )
+                       )
+                    {
+                        preview = createPreview(type, deviceComboBox,
                                 deviceAndPreviewPanel.getPreferredSize());
-                        }
+                    }
 
-                        if (preview != null)
-                        {
-                            deviceAndPreviewPanel
-                                .add(preview, BorderLayout.CENTER);
-                            revalidateAndRepaint = true;
-                        }
+                    if (preview != null)
+                    {
+                        deviceAndPreviewPanel
+                            .add(preview, BorderLayout.CENTER);
+                        revalidateAndRepaint = true;
+                    }
 
-                        if (revalidateAndRepaint)
-                        {
-                            deviceAndPreviewPanel.revalidate();
-                            deviceAndPreviewPanel.repaint();
-                        }
+                    if (revalidateAndRepaint)
+                    {
+                        deviceAndPreviewPanel.revalidate();
+                        deviceAndPreviewPanel.repaint();
                     }
-                };
+                }
+            };
 
-            deviceComboBox.addActionListener(deviceComboBoxActionListener);
-            /*
-             * We have to initialize the controls to reflect the configuration
-             * at the time of creating this instance. Additionally, because the
-             * video preview will stop when it and its associated controls
-             * become unnecessary, we have to restart it when the mentioned
-             * controls become necessary again. We'll address the two goals
-             * described by pretending there's a selection in the video combo
-             * box when the combo box in question becomes displayable.
-             */
-            deviceComboBox.addHierarchyListener(
-                    new HierarchyListener()
+        deviceComboBox.addActionListener(deviceComboBoxActionListener);
+
+        /*
+         * We have to initialize the controls to reflect the configuration
+         * at the time of creating this instance. Additionally, because the
+         * video preview will stop when it and its associated controls
+         * become unnecessary, we have to restart it when the mentioned
+         * controls become necessary again. We'll address the two goals
+         * described by pretending there's a selection in the video combo
+         * box when the combo box in question becomes displayable.
+         */
+        deviceComboBox.addHierarchyListener(
+                new HierarchyListener()
+                {
+                    public void hierarchyChanged(HierarchyEvent event)
                     {
-                        public void hierarchyChanged(HierarchyEvent event)
+                        if ((event.getChangeFlags()
+                                    & HierarchyEvent.SHOWING_CHANGED)
+                                != 0)
                         {
-                            if ((event.getChangeFlags()
-                                        & HierarchyEvent.SHOWING_CHANGED)
-                                    != 0)
-                            {
-                                SwingUtilities.invokeLater(
-                                        new Runnable()
+                            SwingUtilities.invokeLater(
+                                    new Runnable()
+                                    {
+                                        public void run()
                                         {
-                                            public void run()
-                                            {
-                                                deviceComboBoxActionListener
-                                                    .actionPerformed(null);
-                                            }
-                                        });
-                            }
+                                            deviceComboBoxActionListener
+                                                .actionPerformed(null);
+                                        }
+                                    });
                         }
-                    });
-        }
+                    }
+                });
 
         return deviceAndPreviewPanel;
     }
Index: libjitsi/src/org/jitsi/impl/neomedia/device/DeviceConfiguration.java
===================================================================
--- libjitsi/src/org/jitsi/impl/neomedia/device/DeviceConfiguration.java	(revision 10208)
+++ libjitsi/src/org/jitsi/impl/neomedia/device/DeviceConfiguration.java	(revision 10209)
@@ -1049,10 +1049,16 @@
         else if (DeviceSystem.PROP_DEVICES.equals(propertyName))
         {
             if (event.getSource() instanceof AudioSystem)
+            {
+                // Try to switch to a new active audio system if we are
+                // currently using the "none" system.
+                switchFromNoneToActiveAudioSystem(
+                        (CaptureDeviceInfo) event.getNewValue());
                 firePropertyChange(
                         PROP_AUDIO_SYSTEM_DEVICES,
                         event.getOldValue(),
                         event.getNewValue());
+            }
         }
         else if (PROP_VIDEO_FRAMERATE.equals(propertyName))
         {
@@ -1237,5 +1243,13 @@
                 }
             }
         }
+        // The device has been unplugged checks. It may be good to check if the
+        // current active audio system still have actvie devices. If not, then
+        // we will choose another audio system, or the "none" one if no audio
+        // system is available.
+        else
+        {
+            extractConfiguredAudioCaptureDevices();
+        }
     }
 }







More information about the commits mailing list