Exception not raised while opening TargetDataLine

rayishu

New Member
According to Javadocs, when I used \[code\]javax.sound.sampledTargetDataLine\[/code\]'s following method:\[code\]public void open(AudioFormat format,int bufferSize)\[/code\]Which says:\[quote\] Invoking this method with a requested buffer size that does not meet this requirement may result in an IllegalArgumentException.`\[/quote\]So when I implement the following Java code: \[code\]AudioFormat format = getAudioFormat();DataLine.Info info = new DataLine.Info(TargetDataLine.class,format);// open the TargetDataLine for capture.try { TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info); line.open(format, line.getBufferSize()+3000); } catch (LineUnavailableException ex){ ex.printStackTrace(); }\[/code\]But when I run the above code it does not throw any exception. Now according to documentation: \[quote\] \[code\]public int getBufferSize()\[/code\]
Obtains the maximum number of bytes of data that will fit in the data line's internal buffer. For a source data line, this is the size of the buffer to which data can be written. For a target data line, it is the size of the buffer from which data can be read. Note that the units used are bytes, but will always correspond to an integral number of sample frames of audio data.\[/quote\]Which says maximum size will be returned, and the I had added 3000 \[code\]line.open(format, line.getBufferSize()+3000); \[/code\]As show above, why does it do not throw any exception?
 
Top