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

repeated call of Mixer.open() method throws a NullPointerException

    Details

    • Subcomponent:
    • Resolved In Build:
      1.4.1
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: abR10010 Date: 04/18/2002



      The specification for the Mixer class from the javax.sound.sampled package
      doesn't say that repeated call of Mixer.open() method is not permitted.

      However the simple test (see below) shows the Mixer.open()
      method throws a NullPointerException for the one of installed on the system
      mixers with JDK 1.4.1-beta-b08 when this method is called after the Mixer
      is closed.

      This bug causes failure of new JCK test:
       api/javax_sound/sampled/Mixer/index.html#open

      Please, see test log:

      % java -version
      java version "1.4.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b08)
      Java HotSpot(TM) Client VM (build 1.4.1-beta-b08, mixed mode)

      % java test

      ==> Test for Mixer.open() method:

      >> testedMixer = com.sun.media.sound.HeadspaceMixer@80f4cb
      > testedMixer.isOpen() = false
      > testedMixer.open() - O'Key
      > testedMixer.isOpen() = true
      > testedMixer.close() - O'Key
      > testedMixer.isOpen() = false
      > testedMixer.open() - O'Key
      > testedMixer.isOpen() = true
      > testedMixer.close() - O'Key
      > testedMixer.isOpen() = false

      >> testedMixer = com.sun.media.sound.SimpleInputDevice@60420f
      > testedMixer.isOpen() = false
      > testedMixer.open() - O'Key
      > testedMixer.isOpen() = true
      > testedMixer.close() - O'Key
      > testedMixer.isOpen() = false
      > testedMixer.open() - O'Key
      > testedMixer.isOpen() = true
      > testedMixer.close() - O'Key
      > testedMixer.isOpen() = false

      >> testedMixer = com.sun.media.sound.SimpleOutputDevice@19106c7
      > testedMixer.isOpen() = false
      > testedMixer.open() - O'Key
      > testedMixer.isOpen() = true
      > testedMixer.close() - O'Key
      > testedMixer.isOpen() = false
      ## Mixer.open() threw unexpected exception:
      # Mixer = com.sun.media.sound.SimpleOutputDevice@19106c7
      java.lang.NullPointerException
      at com.sun.media.sound.SimpleOutputDevice.implOpen(SimpleOutputDevice.java:372)
      at com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:85)
      at com.sun.media.sound.AbstractMixer.open(AbstractMixer.java:272)
      at com.sun.media.sound.AbstractMixer.open(AbstractMixer.java:288)
      at test.run(test.java:77)
      at test.main(test.java:13)

      ==> test FAILED!
       
       
      The test source:
      ------------------------------- test.java --------------------------------
      // File: %Z%%M% %I% %E%
      // Copyright %G% Sun Microsystems, Inc. All Rights Reserved

      import javax.sound.sampled.*;

      public class test {

          static final int STATUS_PASSED = 0;
          static final int STATUS_FAILED = 2;
          static final int STATUS_TEMP = 95;
          
          public static void main(String argv[]) {
              int testExitStatus = run(argv, System.out) + STATUS_TEMP;
              System.exit(testExitStatus);
          }

          public static int run(String argv[], java.io.PrintStream out) {
              int testResult = STATUS_PASSED;
          
              out.println("==> Test for Mixer.open() method:");

              Mixer.Info[] installedMixersInfo = AudioSystem.getMixerInfo();
          
              if ( installedMixersInfo == null ) {
                  out.println("## AudioSystem.getMixerInfo() returned unexpected result:");
                  out.println
                      ("# expected: an array of Mixer.Info objects (may be array of length 0);");
                  out.println("# produced: null;");
                  return STATUS_FAILED;
              }

              if ( installedMixersInfo.length == 0 ) {
                  out.println(">> there are no mixers installed on the system");
                  return STATUS_PASSED;
              }

              Mixer testedMixer = null;
              for (int i=0; i < installedMixersInfo.length; i++) {
                  try {
                      testedMixer = AudioSystem.getMixer(installedMixersInfo[i]);
                  } catch (SecurityException securityException) {
                      // installed Mixer is unavailable because of security restrictions
                      continue;
                  } catch (Throwable thrown) {
                      out.println("## AudioSystem.getMixer() threw unexpected exception:");
                      thrown.printStackTrace(out);
                      testResult = STATUS_FAILED;
                      continue;
                  }

                  out.println("\n>> testedMixer = " + testedMixer);
              
                  out.println("> testedMixer.isOpen() = " + testedMixer.isOpen());
                  try {
                      testedMixer.open();
                      out.println("> testedMixer.open() - O'Key");
                  } catch (LineUnavailableException lineUnavailableException) {
                      // testedMixer is not available due to resource restrictions
                      out.println("> testedMixer is not available due to resource restrictions");
                      continue;
                  } catch (SecurityException securityException) {
                      // testedMixer is not available due to security restrictions
                      out.println("> testedMixer is not available due to security restrictions");
                      continue;
                  } catch (Throwable thrown) {
                      out.println("## Mixer.open() threw unexpected exception:");
                      out.println("# Mixer = " + testedMixer);
                      thrown.printStackTrace(out);
                      testResult = STATUS_FAILED;
                      continue;
                  }
                  out.println("> testedMixer.isOpen() = " + testedMixer.isOpen());
                  testedMixer.close();
                  out.println("> testedMixer.close() - O'Key");

                  out.println("> testedMixer.isOpen() = " + testedMixer.isOpen());
                  try {
                      testedMixer.open();
                      out.println("> testedMixer.open() - O'Key");
                  } catch (LineUnavailableException lineUnavailableException) {
                      // testedMixer is not available due to resource restrictions
                      out.println("> testedMixer is not available due to resource restrictions");
                      continue;
                  } catch (SecurityException securityException) {
                      // testedMixer is not available due to security restrictions
                      out.println("> testedMixer is not available due to security restrictions");
                      continue;
                  } catch (Throwable thrown) {
                      out.println("## Mixer.open() threw unexpected exception:");
                      out.println("# Mixer = " + testedMixer);
                      thrown.printStackTrace(out);
                      testResult = STATUS_FAILED;
                      continue;
                  }
                  out.println("> testedMixer.isOpen() = " + testedMixer.isOpen());
                  testedMixer.close();
                  out.println("> testedMixer.close() - O'Key");
                  out.println("> testedMixer.isOpen() = " + testedMixer.isOpen());

              } // for (int i=0; i < installedMixersInfo.length; i++)

              if ( testResult == STATUS_FAILED ) {
                  out.println("\n==> test FAILED!");
              } else {
                  out.println("\n==> test PASSED!");
              }
              return testResult;
          }
      } // end of test class
      -------------------------------------------------------------------------
       
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              fbomerssunw Florian Bomers (Inactive)
              Reporter:
              bondsunw Bond Bond (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: