Short version:
I see there is an alchemy method called supplyFile(), but the second arg is a ByteArray... what in the world is that for?!?!
Longer version:
I would like to do the following:
I'm able to do this right now by opening the file and reading the chunks into a ByteArray on the Actionscript side and then passing it to C for processing and back- but this calls some unnecessary overhead by needing to do AS3_ByteArray_writeBytes()/AS3_ByteArray_readBytes() on the C side in order to manipulate the data in a char *.
Is there any way to simply fopen() a file on the C side and read in some bytes? If not, will this be possible in alchemy 2?
Asssume we are talking about a very large file on disk (>4GB).
Here is a tutorial about this topic: http://blog.debit.nl/2009/03/using-bytearrays-in-actionscript-and-alch emy/
You should first embed the file as a bytearray and "supply" it to alchemy, then you can use "fopen" directly on the C side.
But I haven't tested that for large files.
Thanks Bruce- but please see what I wrote: "I'm able to do this right now by opening the file and reading the chunks into a ByteArray on the Actionscript side and then passing it to C for processing and back- but this calls some unnecessary overhead"
Note that I'm also chasing this down via stackoverflow, please see my comments there which illustrate the problem in a little more depth: http://stackoverflow.com/questions/11398559/how-to-read-with-supplyfil e
Any ideas anyone? Will this be solved in alchemy2?!
Maybe you can use domain memory API to avoid using "supplyFile" and function calls like that. That's the trick used a lot in many alchemy projects for passing and returning frame buffers. See the source code of the example: http://unitzeroone.com/blog/2009/04/06/more-play-with-alchemy-lookup-t able-effects/
I am using the domain memory API to avoid using "supplyFile" etc... but the link you showed highlighted a point I missed... the domain memory is actually seen as a ByteArray on the actionscript side. So it's maybe possible to FileStream.readBytes() directly into the domain memory space by allocating the pointer as a char * on the C side, passing that pointer to the actionscript side, and reading it directly into that pointer (an offset of AS3_Ram())
Thankfully, I've been able to join up the alchemy 2 pre-release now, so I'm not going to test this out on alchemy 1 at the moment, but maybe this is of use to someone else- and thanks for your help, Bruce!
North America
Europe, Middle East and Africa
Asia Pacific