mrthuanvn / flash-kikko

Automatically exported from code.google.com/p/flash-kikko
0 stars 0 forks source link

RangeError: Error #1506: The specified range is invalid. #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I am getting a strange error. I have a WAV data ByteArray, and if I use it 
directly, I get this error:

RangeError: Error #1506: The specified range is invalid.
    at cmodule.shine::FSM_imalloc$/start()
    at cmodule.shine::FSM_pubrealloc/work()
    at Function/<anonymous>()
    at Function/<anonymous>()
    at fr.kikko.lab::ShineMP3Encoder/start()[/Users/kikko/work/tests/shineMP3_alchemy/src/fr/kikko/lab/ShineMP3Encoder.as:41]
    at encoder/encodeClicked()[E:\dev2\playmytone\editor\src\encoder.mxml:130]
    at encoder/__encodeButton_click()[E:\dev2\playmytone\editor\src\encoder.mxml:159]

However, if I save this ByteArray to local file system (with FileReference 
object) and then load it back up as .wav, then mp3 encoding works.

I tried cloning the ByteArray before I pass it off to the mp3 encoder, but it 
doesn't help.

Have you observed this issue ?

Original issue reported on code.google.com by boris.re...@gmail.com on 20 Sep 2010 at 4:53

GoogleCodeExporter commented 9 years ago
I have the same problem, Please fix~

Original comment by deng...@gmail.com on 24 Apr 2011 at 8:38

GoogleCodeExporter commented 9 years ago
I have found a work-around by placing the mp3 encoder in a separate .swf and 
dynamically loading it. 

Original comment by boris.re...@gmail.com on 24 Apr 2011 at 8:53

GoogleCodeExporter commented 9 years ago
I found a solution, move WAVE byteArray position to 0 , and everythings work 
fine~

Original comment by deng...@gmail.com on 26 Apr 2011 at 10:17

GoogleCodeExporter commented 9 years ago
Hi deng....@gmail.com,

can you please send me the sample files that is working for you.

please fined attached files I am trying.

Thanks
Pradeep

Original comment by pradeepk...@gmail.com on 13 Jul 2011 at 5:39

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
hello, I also had the RangeError issue and was able to workaround them.
With try catch's I and my debugger I got to the source of the problem.
The error is caused by the cshine.update() call in the update / progressloop on 
a too freaquent basis.
You can kill 80% of the RangeErrors by editing the timing of the call to the 
ShineMP3Encoder.update() function:

A second improvement which solidifies the class and clib errors by another 20% 
is calling the update() less frequent, so in the start() function change:

*********
ORIGINAL
*********
timer = new Timer(1000/30); //(or 33)
timer.addEventListener(TimerEvent.TIMER, update);

*****
NEW:
*****
timer = new Timer(150);
timer.addEventListener(TimerEvent.TIMER, update);

------------

Secondly catch'm and convert percent:int topercent:*:

*********
Original:
*********

private function update(event : TimerEvent) : void {
  var percent:int = cshine.update();
  ....
}

*****
NEW:
*****

private function update(event : TimerEvent) : void {
    try {
           //loose the percent INT type and replace it by *
       var percent:* = cshine.update();
    }catch(e:Error) {
       trace("ShineMP3Encoder::update : cshine.update() error:" + e.message));
    }
       ....
}

------------
Some testing:
------------

With above changes I was able to compress the *same* microphone wave info of 1 
minute length 100 times in a row without any error! 
Even if an error fires from cshine.update(), The try / catch will handle it and 
compressing goes on.

Used classes to get me the WAVE:
org.bytearray.micrecorder.encoder.WaveEncoder
org.bytearray.micrecorder.MicRecorder

------------

Hints (and a big thank you) for master KIKKO:
*********************************************
I'm not a C programmer, but I was able to pinpoint the error in the C code, 
it's the assert(l) function...for some reasn I don't know, but the code 
comments tell me enough:
line 336 here: 
http://code.google.com/p/flash-kikko/source/browse/shineMP3_alchemy/lib/shine/fo
rmatBitstream.c?r=4

static MYSideInfo*
get_side_info()
{
    side_info_link *f = side_queue_free;
    side_info_link *l = side_queue_head;

    /*
      If we stop here it means you didn't provide enough
      headers to support the amount of main data that was
      written.
    */
    assert( l );

    /* update queue head */
    side_queue_head = l->next;

    ......
}

Cheers,

Stijn De Ryck

Original comment by zetm...@gmail.com on 19 Nov 2011 at 5:32