• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IllegalArgumentException

 
Diana Garc´┐Ża
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • 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?
 
Phoum Lib
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
did you try to free more memory before the read function by calling
System.gc();
Thread.yield();
... ?
 
Ann Klein
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic