United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-5067526 DOC: Set default format with DataLine.Info object
JDK-5067526 : DOC: Set default format with DataLine.Info object

Details
Type:
Bug
Submit Date:
2004-06-24
Status:
Resolved
Updated Date:
2004-07-16
Project Name:
JDK
Resolved Date:
2004-07-16
Component:
client-libs
OS:
generic
Sub-Component:
javax.sound
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:
5.0 (b59)

Related Reports
Relates:

Sub Tasks

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
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
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger-rc

FIXED IN:
tiger-rc

INTEGRATED IN:
tiger-b59
tiger-rc


                                     
2004-09-19



Hardware and Software, Engineered to Work Together