camunits plugins have initialize(), but no finalize() hook.
GoogleCodeExporter opened this issue · 3 comments
GoogleCodeExporter commented
Problem:
I am writing a plugin to interface with an external library. The
external library requires that a function { CameraLibraryInitialize() } get
called on startup, before any other functions are called. This fits nicely
into the cam_plugin_initialize() call. The library also provides a
function to be called on cleanup, {CameraLibraryUninitialize() } but there
does not seem to be a place to call such a function.
Workaround:
Via the glib documentation, I've found that I can simply place the
appropriate call in a function named g_module_unload() and this has the
desired effect. It may be cleaner to have a cam_plugin_finalize() to
complement cam_plugin_initialize(), however?
Original issue reported on code.google.com by chrism...@gmail.com
on 12 Apr 2010 at 4:50
GoogleCodeExporter commented
Hi Chris,
That's correct. The plugin is a thin wrapper around a CamUnitDriver.
It is safe to assume that there will only be one instance of a CamUnitDriver in
memory. Under "normal" usage of CamUnits, the start() method of a driver is
called
when the first CamUnitChain is created, and the stop() method of a driver is
called
when the last CamUnitChain is destroyed.
Original comment by ashu...@gmail.com
on 12 Apr 2010 at 7:18
GoogleCodeExporter commented
Hi Chris,
You can get the functionality you're looking for by implementing your own
CamUnitDriver to accompany your custom unit, instead of using the stock driver.
Specifically, you'll want to override the start() and stop() methods of
CamUnitDriver
to do the initialization and cleanup you're looking for. See
trunk/plugins/dc1394/input_dc1394.c for an example.
Original comment by ashu...@gmail.com
on 12 Apr 2010 at 5:56
- Changed state: WontFix
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
GoogleCodeExporter commented
Thanks Albert,
I actually am using a custom CamUnitDriver for other things already. I was using
the start() and stop() method for the library initialization, but it seemed
inappropriate since there's no fundamental reason that the driver couldn't be
instantiated multiple times as a GType. I guess don't have the clearest
understanding of what the plugin does and why it is seperate from the driver.
Is the
plugin meant to only serve as a thin GModule wrapper around a single Driver
instance?
Is it sane to assume that a CamUnitDriver will only be instantiated once?
Original comment by chrism...@gmail.com
on 12 Apr 2010 at 6:16