• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

IllegalArgumentException

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello *
Could anybody please tell me why do I get this Exception?:
"Warning: java.lang.IllegalArgumentException: Illegal request to write non-integral number of frames (198 bytes)"
This exception occur when I make a read(byte[] b, int off, int len) but only if len==88204. Then the method can only read 198 bytes and this exception is thrown. It doesn't happen when len == 5513.
This argument "len" is passed from a class from the API (player) and I can't control it.
Can anybody help?
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
did you try to free more memory before the read function by calling
System.gc();
Thread.yield();
... ?
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get the error on the last iteration of a loop such as follows

while((cnt = audioInputStream.read(
tempBuffer,0,tempBuffer.length)) != -1
&& stopPlayback == false){
System.out.println("In PlayThread - cnt= " +
cnt + "\n");

if(cnt > 0){
//Write data to the internal buffer of
// the data line where it will be
// delivered to the speaker.
sourceDataLine.write(tempBuffer, 0, cnt);
}//end if
}//end while

the display shows the first so many passes of the loop with cnt = 10000
When the last iteration is less than 10000 it is I A.S.S.U.M.E. not an "integral number"

Messy --- is there a cure.
 
Ann Klein
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well so much for that theory. Found sourceDataLine.available() and displayed it as REMAINDER.
In PlayThread - cnt= 10000
remainer= 8192
In PlayThread - cnt= 10000
remainer= 6192
In PlayThread - cnt= 10000
remainer= 188
In PlayThread - cnt= 10000
remainer= 2176
In PlayThread - cnt= 8024
remainer= 168

The full buffer is not used every time and the remaining bytes vary without seeming logic.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic