Anyloop uses a plugin-like syntax to add devices to a loop.
See the aylp_device
struct in anyloop.h
. Devices have init and fini
functions that each run once, and a proc function that runs once every loop.
Some ground rules:
- Devices must free any memory they allocate.
- Devices must not free any memory they didn't allocate.
- Devices must maintain copies of any memory they allocate.
state->matrix
(for example) should never be the only pointer to its data; otherwise, that's just begging for a memory leak. - If devices fail to do their job, they must return a nonzero error code from
proc()
. This is especially important if the device was supposed to change the pipeline type. - Devices should self-document their parameters and accepted/outputted
aylp_type
s andaylp_units
, either in their header files or in separate documentation elsewhere.
Devices are named with a URI-like syntax. Built-in devices start with the scheme
anyloop
, and are followed only by a "path" (to use URI terminology). For
example, the built-in device to generate von Kármán streams has the path
vonkarman_stream
, and thus has the URI anyloop:vonkarman_stream
.
To add a new built-in device:
- write
src/devices/$MYDEVICE.c
andsrc/devices/$MYDEVICE.h
- modify
device.h
to include the header file - add the device's initialization function to the init map in
device.h
- add the new files to meson.build
Documentation for each built-in device is located under the doc/devices directory of this repository.
Sometimes, due to licensing requirements or whatever, it may be convenient to
use devices not in this repository. No problem! Use the file
scheme
with no authority (RFC 3986). For example,
to load a plug-in device at /opt/foo/bar.so
, write the URI as
file:/opt/foo/bar.so
.
The plug-in device will be initialized the same way built-in devices are. As
such, a device named bar.so
is expected to have a function of the following
name and type signature:
int bar_init(struct aylp_device *self)
Note that we strip off anything including and after the first .
character in
the basename, so a device with a basename of blah.a.b.c
should have an init
function named blah_init
.
This function can then attach whatever proc() and fini() functions it wishes
to its own aylp_device
struct.