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

behavior of Mixer.getMaxLines(Line.Info) method doesn't match the spec

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.4.1
    • Fix Version/s: 1.4.1
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      hopper
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: abR10010 Date: 04/12/2002



      The specification for the Mixer.getMaxLines(Line.Info) method from the
      javax.sound.sampled package says:

      public int getMaxLines(Line.Info info)

          Obtains the maximum number of lines of the requested type that can be open
          simultaneously on the mixer. The requested type is any line that matches the
          description in the provided Line.Info object. For example, if the info object
          represents a speaker port, and the mixer supports exactly one speaker port,
          this method should return 1. If the info object represents a source data
          line and the mixer supports the use of 32 source data lines simultaneously,
          the return value should be 32.

          Parameters:
                    info - a Line.Info that describes the line for which the number of
                    supported instances is queried
          Returns:
                 the maximum number of matching lines supported


      It is natural to suppose that the returned int value has to be non-negative
      int value.

      However the simple test (see below) shows the Mixer.getMaxLines(Line.Info)
      method returns the negative value (-1) for the one of installed on the system
      mixers with JDK 1.4.1-beta-b08.

      It is reasonable to suppose that in these cases the "-1" int value means
      the AudioSystem.NOT_SPECIFIED value.

      If so the spec for the Mixer.getMaxLines(Line.Info) method has to be adjusted
      to describe the returned value more precisely.


      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.getMaxLines(Line.Info info) method:

      ==> tested Mixer: com.sun.media.sound.HeadspaceMixer@7ffe01

      => tested LineInfo = interface Line
      => testedMixer.getMaxLines(testedLineInfo) = 32

      => tested LineInfo = interface DataLine
      => testedMixer.getMaxLines(testedLineInfo) = 32

      => tested LineInfo = interface SourceDataLine
      => testedMixer.getMaxLines(testedLineInfo) = 32

      => tested LineInfo = interface TargetDataLine
      => testedMixer.getMaxLines(testedLineInfo) = 0

      => tested LineInfo = interface Clip
      => testedMixer.getMaxLines(testedLineInfo) = 32

      => tested LineInfo = interface Port
      => testedMixer.getMaxLines(testedLineInfo) = 0

      => tested LineInfo = interface Mixer
      => testedMixer.getMaxLines(testedLineInfo) = 0

      => tested LineInfo = class test
      => testedMixer.getMaxLines(testedLineInfo) = 0

      ==> tested Mixer: com.sun.media.sound.SimpleInputDevice@1d8957f

      => tested LineInfo = interface Line
      => testedMixer.getMaxLines(testedLineInfo) = -1
      ## Mixer.getMaxLines(Line.Info) failed:
      # negative int value is returned = -1

      => tested LineInfo = interface DataLine
      => testedMixer.getMaxLines(testedLineInfo) = -1
      ## Mixer.getMaxLines(Line.Info) failed:
      # negative int value is returned = -1

      => tested LineInfo = interface SourceDataLine
      => testedMixer.getMaxLines(testedLineInfo) = 0

      => tested LineInfo = interface TargetDataLine
      => testedMixer.getMaxLines(testedLineInfo) = -1
      ## Mixer.getMaxLines(Line.Info) failed:
      # negative int value is returned = -1

      => tested LineInfo = interface Clip
      => testedMixer.getMaxLines(testedLineInfo) = 0

      => tested LineInfo = interface Port
      => testedMixer.getMaxLines(testedLineInfo) = 0

      => tested LineInfo = interface Mixer
      => testedMixer.getMaxLines(testedLineInfo) = 0

      => tested LineInfo = class test
      => testedMixer.getMaxLines(testedLineInfo) = 0

      ==> tested Mixer: com.sun.media.sound.SimpleOutputDevice@3ee284

      => tested LineInfo = interface Line
      => testedMixer.getMaxLines(testedLineInfo) = 1

      => tested LineInfo = interface DataLine
      => testedMixer.getMaxLines(testedLineInfo) = 1

      => tested LineInfo = interface SourceDataLine
      => testedMixer.getMaxLines(testedLineInfo) = 1

      => tested LineInfo = interface TargetDataLine
      => testedMixer.getMaxLines(testedLineInfo) = 0

      => tested LineInfo = interface Clip
      => testedMixer.getMaxLines(testedLineInfo) = 0

      => tested LineInfo = interface Port
      => testedMixer.getMaxLines(testedLineInfo) = 0

      => tested LineInfo = interface Mixer
      => testedMixer.getMaxLines(testedLineInfo) = 0

      => tested LineInfo = class test
      => testedMixer.getMaxLines(testedLineInfo) = 0

      ==> test FAILED!
       
       
      The test sorce:
      ------------------------------- 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;
              
              Line.Info testedLinesInfo[] = {
                  new Line.Info(Line.class),
                  new Line.Info(DataLine.class),
                  new Line.Info(SourceDataLine.class),
                  new Line.Info(TargetDataLine.class),
                  new Line.Info(Clip.class),
                  new Line.Info(Port.class),
                  new Line.Info(Mixer.class),
                  new Line.Info(test.class)
                  };
          
              out.println("\n====> Test for Mixer.getMaxLines(Line.Info info) 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 ) {
                  // there are no mixers installed on the system - so this testcase can not be tested
                  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(Mixer.Info) threw unexpected exception:");
                      out.println("# Mixer.Info = " + installedMixersInfo[i]);
                      thrown.printStackTrace(out);
                      testResult = STATUS_FAILED;
                      continue;
                  }

                  out.println("\n==> tested Mixer: " + testedMixer);

                  for (int j=0; j < testedLinesInfo.length; j++) {
                      Line.Info currentTestedLineInfo = testedLinesInfo[j];
                      int maxLines = testedMixer.getMaxLines(currentTestedLineInfo);
                      out.println("\n=> tested LineInfo = " + currentTestedLineInfo);
                      out.println("=> testedMixer.getMaxLines(testedLineInfo) = " + maxLines);
                      if ( maxLines < 0 ) {
                          out.println("## Mixer.getMaxLines(Line.Info) failed:");
                          out.println("# negative int value is returned = " + maxLines);
                          testResult = STATUS_FAILED;
                      }
                  }
              }

              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: