Shine-MP3-Encoder-on-AS3-Alchemy
Shine-MP3-Encoder-on-AS3-Alchemy copied to clipboard
RangeError: Error #1506: The specified range is invalid. at cmodule.shine::FSM_update_compress/work()
Hi there,
I have posted this issue on the Google Code repository for this same project (http://code.google.com/p/flash-kikko/issues/detail?id=4) because some people have noted similar problems however I am aware that GitHub is the projects new home so thought I should post here as well.
What steps will reproduce the problem?
- Record wav ByteArray using MicRecorder and Wave Encoder classes from http://www.bytearray.org/?p=1858
- Feed wav ByteArray to cmodule.shine.CLibInit.init()
- Intermittently fails with the following error:
RangeError: Error #1506: The specified range is invalid.
at cmodule.shine::FSM_update_compress/work()
at Function/
What is the expected output? What do you see instead? Sometimes conversion occurs with no problems at all.
What version of the product are you using? On what operating system? https://github.com/kikko/Shine-MP3-Encoder-on-AS3-Alchemy/tree/master/bin/shineMP3_alchemy.swc (Updated March 26, 2010)
Please provide any additional information below. After scouring these updates on Google Code (http://code.google.com/u/@UxhXS1FXBRZFXwN9/updates/projects) I tried making the cshine class a singleton so it is not instantiated more than once. I've added the swc and my singleton to an external swf and loaded them in dynamically. Finally I have ensured that the position of the Wav ByteArray is set to 0 before passing it to the mp3 encoder. All of these have had no effect.
Just to re-emphasise, this problem is seriously intermittent. I have spent quite some time trying to determine if there was a pattern to the issue but it seems not. It seems to happen more often when I have multiple Wav ByteArrays to convert. At first I believed it was some sort of memory address problem because it didn't seem to happen with the first ByteArray conversion but quite often after 1 or 2 but recently I have seen it happen on the first pass as well.
Any information or guidance would be greatly appreciated. (getting desperate!) Thanks, Gareth
Hi Gareth, did you find a solution to this? Have the same issue. Suddenly the error keeps popping up.
I just solved my problem, but I'm not so sure it's the same issue as you had. Anyway, can be helpful for someone else perhaps. I previously saved a reference to the CLibInit-class, like _loader = new CLibInit; Then another variable for the init-object. _lib = _loader.init(); That caused the problem. If I changed back as in the documented example _lib = (new CLibInit).init(). Then it worked without errors.
Hi there,
Thanks for posting your solution here inear. Since the project has progressed we have found a workaround that didn't use mp3 conversion so I haven't tested your theory.
Someone also contacted me with a solution to this on Google code. I am going to cross post this here at his request since it might also offer someone a solution:
The text:
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 95% of the RangeErrors by editing the timing of the call to the ShineMP3Encoder.update() function:
ORIGINAL
timer = new Timer(1000/30); //(or 33) timer.addEventListener(TimerEvent.TIMER, update);
NEW:
timer = new Timer(175); timer.addEventListener(TimerEvent.TIMER, update);
Secondly catch possible int out of range errors and convert 'percent:int' to 'percent:*'
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/formatBitstream.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