Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7981367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:20:47+00:00 2026-06-04T10:20:47+00:00

According to Javadocs, when I used javax.sound.sampledTargetDataLine ‘s following method: public void open(AudioFormat format,int

  • 0

According to Javadocs, when I used javax.sound.sampledTargetDataLine‘s following method:

public void open(AudioFormat format,int bufferSize)

Which says:

Invoking this method with a requested buffer size that does not meet this requirement may result in an IllegalArgumentException.`

So when I implement the following Java 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();        
}

But when I run the above code it does not throw any exception. Now according to documentation:

public int getBufferSize()
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.

Which says maximum size will be returned, and the I had added 3000

line.open(format, line.getBufferSize()+3000); 

As show above, why does it do not throw any exception?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:20:49+00:00Added an answer on June 4, 2026 at 10:20 am

    You left out some important descriptions from the JavaDoc for open. More completely, it says:

    void open(AudioFormat format,
              int bufferSize)
              throws LineUnavailableException
    

    Opens the line with the specified format and requested buffer size,
    causing the line to acquire any required system resources and become
    operational. The buffer size is specified in bytes, but must represent
    an integral number of sample frames. Invoking this method with a
    requested buffer size that does not meet this requirement may result
    in an IllegalArgumentException. The actual buffer size for the open
    line may differ from the requested buffer size. The value actually set
    may be queried by subsequently calling DataLine.getBufferSize()

    So, the buffer size you specify may not be the size of the internal buffer and may even exceed it.

    However, it must “represent an integral number of sample frames” or it will throw IllegalArgumentException. If you request more memory than it can allocate internally, then you’ll receive LineUnavailableException. This doesn’t mean requesting a larger size than the current internal buffer will result in LineUnavailableException.

    At least that’s my reading of the docs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to the C++11 standard, is the following program well-formed and portable C++? int
I have the following code snippet: class Cert { public static void main(String[] args)
According to http://java.sun.com/products/javamail/javadocs/javax/mail/FetchProfile.html , Message[] msgs = folder.getMessages(); FetchProfile fp = new FetchProfile(); fp.add(FetchProfile.Item.ENVELOPE);
In App Engine, according to the JavaDoc , the getTypeRank method has this signature:
According to the javadoc, if I call receive() on a javax.jms.MessageConsumer it will block
I've called gc.setAntialias(SWT.ON); and it does nothing. According to that method, it should work.
According to the javadocs, Groovy's MockFor object always ends with a verify. Its StubFor
Given the following code: public class FooBar { public static volatile ConcurrentHashMap myConfigData =
According to the Javadocs for Runtime here : Every Java application has a single
According to the javadoc of javax.xml.validation.SchemaFactory#newInstance, I can specify which implementation of SchemaFactory I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.