JDK-5067526 : DOC: Set default format with DataLine.Info object
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.sound
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-06-24
  • Updated: 2017-05-16
  • Resolved: 2004-07-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
Other
5.0 b59Fixed
Related Reports
Relates :  
Description

Name: fb126949			Date: 06/23/2004


Java Sound has an undocumented feature for the default format of DataLines: if you use an DataLine.Info object with just one fully qualified AudioFormat for retrieving that DataLine, the default audio format of that DataLine will be the format in the Info object and calling open() without parameters will open the data line with that format. 

The correct way of retrieving a line and opening it with a specific format is this:
  // retrieve a line that is capable of "format"
  info = new DataLine.Info(SourceDataLine.class, format);
  sdl = (SourceDataLine) AudioSystem.getLine(info);
  // open the line with the format
  sdl.open(format);

The spec does not say that the DataLine.Info's format list is used for anything else than finding a suitable DataLine. But, apparently, quite a number of applications exploit an undocumented behavior in Java Sound that initializes a line's default format with the first format in the DataLine.Info's format list, so that the following calling sequence leads to the same result:

  // retrieve a line that is capable of "format"
  info = new DataLine.Info(SourceDataLine.class, format);
  sdl = (SourceDataLine) AudioSystem.getLine(info);
  // open the line
  sdl.open();
or
  sdl.open(sdl.getFormat());

The spec for Line.open() and AudioSystem.getLine should be extended with clarification about this behavior.

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-rc FIXED IN: tiger-rc INTEGRATED IN: tiger-b59 tiger-rc
2004-09-19

EVALUATION Should be fixed for tiger b59. ###@###.### 2004-06-23
2004-06-23

PUBLIC COMMENTS Keep backwards compatibility by implementing and documenting the old behavior. ###@###.### 2004-06-23
2004-06-23