Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8202637

AudioSystem.getMixerInfo() returns incorrect Mixer.Info[] on USB hot swap

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Happens on Windows 10, Windows 7, and latest macOS (10.13.x currently)

      A DESCRIPTION OF THE PROBLEM :
      Hot swapping USB audio devices (Plugging in and Unplugging) can cause AudioSystem.getMixerInfo() to return continuous incorrect Mixer.Info's.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      You will need 2 separate USB audio devices (preferably different manufacturers, so they have different names in Mixer.Info.

      Steps:
      1) Plug in USB audio device #1
      2) Unplug USB audio device #1 and plug in USB audio device #2 into the same USB port (You should do this quickly).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      AudioSystem.getMixerInfo() should return the new name of the USB audio device in a timely manner and also remove the no longer connected Audio device from the returned Mixer.Info array
      ACTUAL -
      AudioSystem.getMixerInfo() continues to return the USB device name of USB device #1. It never updates to show USB device #2 even though it is now connected.

      ---------- BEGIN SOURCE ----------
      // This is just a continuous loop to print out Audio Device changes.
      public static void main(String[] args) throws Exception {

              int count = 0;
              List<String> control = new ArrayList<>();
              while (true) {
                  Mixer.Info[] infos = AudioSystem.getMixerInfo();

                  List<String> names = new ArrayList<>();
                  for (int i = 0; i < infos.length; i++) {
                      names.add(infos[i].getName());
                  }

                  if (!control.equals(names)) {
                      control = names;
                      System.out.println("\n\n============== try " + count + " ===============");
                      System.out.println(control);
                  }


                  count++;
                  Thread.sleep(5000);
              }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None known

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: