-
Bug
-
Resolution: Fixed
-
P4
-
1.4.1
-
hopper
-
generic
-
generic
Name: abR10010 Date: 04/03/2002
The specification for the AudioSystem.getTargetEncodings() methods from the
javax.sound.sampled package says:
public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat.Encoding sourceEncoding)
Obtains the encodings that the system can obtain from an audio input stream
with the specified encoding using the set of installed format converters.
Parameters:
sourceEncoding - the encoding for which conversion support is queried
Returns:
array of encodings. The array will always have a length of at least 1,
representing the current encoding (no conversion).
public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat)
Obtains the encodings that the system can obtain from an audio input stream
with the specified format using the set of installed format converters.
Parameters:
sourceFormat - the audio format for which conversion is queried
Returns:
array of encodings. The array will always have a length of at least 1,
representing the current encoding (no conversion).
First, the specification for both methods contains undefined term:
"current encoding".
What does this term mean?
It is reasonable to suppose that this term means "sourceEncoding"
for the first method and "encoding of sourceFormat" for the second method.
In any case, the simple test (see below) shows that nevertheless these methods
can return an array of length 0 with JDK 1.4.1-beta-b07.
Please, see test log:
% java -version
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b07)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b07, mixed mode)
% java test
==> Test for AudioSystem.getTargetEncodings() methods:
## getTargetEncodings(AudioFormat.Encoding) failed:
array of length 0 is returned
## getTargetEncodings(AudioFormat) failed:
array of length 0 is returned
==> 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;
out.println("==> Test for AudioSystem.getTargetEncodings() methods:");
AudioFormat.Encoding producedEncodings[] = null;
AudioFormat.Encoding sourceAudioFormatEncoding =
new GetTargetEncodAFEncoding("TEST_SOURCE_ENCODING");
producedEncodings = AudioSystem.getTargetEncodings(sourceAudioFormatEncoding);
if ( producedEncodings.length == 0 ) {
out.println("\n## getTargetEncodings(AudioFormat.Encoding) failed:");
out.println(" array of length 0 is returned");
testResult = STATUS_FAILED;
}
AudioFormat sourceAudioFormat = new AudioFormat
(sourceAudioFormatEncoding, // AudioFormat.Encoding
(float) 44100.0, // float SampleRate
(int) 16, // int sampleSizeInBits
(int) 2, // int channels
(int) 4, // int frameSize
(float) 110.0, // float frameRate
true // boolean bigEndian
);
producedEncodings = AudioSystem.getTargetEncodings(sourceAudioFormat);
if ( producedEncodings.length == 0 ) {
out.println("\n## getTargetEncodings(AudioFormat) failed:");
out.println(" array of length 0 is returned");
testResult = STATUS_FAILED;
}
if ( testResult == STATUS_FAILED ) {
out.println("\n==> test FAILED!");
} else {
out.println("\n==> test PASSED!");
}
return testResult;
}
} // end of test class
class GetTargetEncodAFEncoding extends AudioFormat.Encoding {
GetTargetEncodAFEncoding( String name ) {
super(name);
}
}
-------------------------------------------------------------------------
======================================================================