It's been tested with libao and it works correctly.
I've added more helper functions to make it easier to override the functionality of the generic_* functions. Breaking them down into smaller functions should make it easier to just replace a part of them in the pr. package script.
patch and unpack functions have not been thoroughly tested though :)
This is the first attempt and it's not finished