Okay, here's an attempt to create some friendly wrappers for the new buffers:
https://bitbucket.org/hudson/magic-lantern/pull-request/529User-level API:- srm_malloc_suite/srm_free_suite: will allocate the entire SRM memory (size autodetected) and return a memory suite, just like shoot_malloc_suite (preferred for raw_rec/mlv_rec)
- malloc/free: will use these buffers when you request very large sizes that can't be handled by shoot_malloc (32MB+); these are one level above srm_malloc_suite
- srm_malloc/srm_free: will use these buffers for any request higher than 25MB (even if the same buffers can be allocated from shoot_malloc)
Caveats:- once somebody allocated from the SRM buffer, nobody else will be allowed to do so, and you will not be able to take pictures (this is because the backend must free the buffers in exactly the same order as allocated)
- you can, however, use malloc/free from two diferent tasks (first malloc will allocate all the SRM buffers, last free will give all buffers back to the system)
- with malloc, you can free the buffers in any order (the backend will take care of it)
- be careful allocating SRM buffers outside LiveView: you may not be able to enter LiveView until you free them
- depending on camera, some buffer sizes like 27MB may fail with malloc (because it will try shoot_malloc first, and it doesn't report the free space correctly [fixme]); workaround: srm_malloc will work.
For short-term processing that requires huge amounts of RAM, or for RAW recording, these wrappers should be just fine.
Porting notes:- Stubs required: SRM_AllocateMemoryResourceFor1stJob, SRM_FreeMemoryResourceFor1stJob, CreateMemorySuite, DeleteMemorySuite, CreateMemoryChunk, AddMemoryChunk.
- Check the Free Memory dialog and post a screenshot (I already did for 5D3 123 earlier in this thread).
- Run the test from "don't click me" and post the screenshot created there.
- While this test is running, try taking some pictures (it should not crash, but the allocator may fail - it's normal, it should fail gracefully).
Some more thoughts:g3gg0 is researching a way to merge two memory suites, so you would get the entire memory allocated in a single suite. With this, there would be - in theory - no need to modify the raw recording code, it would work out of the box.
However, if you enable the memory hack, it will allocate the memory outside LiveView and then get back into LiveView. The problem with this is that, if you allocate the entire RAM outside LV, the camera may not have enough RAM for the LiveView tasks (it happens on 5D3). So, I'd keep two separate allocators for now, and the user code will be responsible for having the proper context before calling (e.g. don't switch modes after allocating).