Commit 1d5f32b8 authored by Éric Thiébaut's avatar Éric Thiébaut
Browse files

Better reflect camera state

However this does not fully solve an issue (shared camera data and XPA
server give a different camera state) when the camera is stuck at
initialization.
parent 877dad7c
......@@ -288,7 +288,9 @@ int main(int argc, char* argv[])
errors) and reflect the camera settings in the "public" resources. */
vfg = tao_create_framegrabber(NULL, accesspoint, nframes, perms);
shcam = tao_get_framegrabber_shared_camera(vfg);
tao_reflect_camera_information(shcam, dev);
(void)tao_wrlock_shared_camera(NULL, shcam);
(void)tao_reflect_camera_information(shcam, dev);
(void)tao_unlock_shared_camera(NULL, shcam);
info = dev->info;
/* Save the sheared memory identifier of the virtual frame-grabber in a
......@@ -381,9 +383,8 @@ static void
on_return(void)
{
/* Free all resources (more or less in reverse order compared to creation).
This function should only be called once. But in case of, we make sure
to mark resources as released to avoid errors such as freeing more than
once. */
This function should only be called once. But, in case of, we mark
resources as released to avoid errors such as freeing more than once. */
debug(CONTROL_DEBUGLEVEL, "Freeing resources...");
quitting = true;
if (srv != NULL) {
......@@ -665,10 +666,9 @@ change_state(tao_camera_state_t state)
tao_get_camera_state_name(state));
}
info.state = state;
if (tao_try_wrlock_shared_camera(NULL, shcam) == TAO_OK) {
shcam->info.state = state;
tao_unlock_shared_camera(NULL, shcam);
}
(void)tao_wrlock_shared_camera(NULL, shcam);
shcam->info.state = state;
(void)tao_unlock_shared_camera(NULL, shcam);
}
/* This is the main function executed by the "worker" thread. */
......@@ -1529,11 +1529,9 @@ on_set_config(tao_server_t* srv, void* ctx,
tao_set_camera_configuration(dev, &cfg) != TAO_OK) {
status = TAO_ERROR;
}
status = tao_wrlock_shared_camera(NULL, shcam);
if (status == TAO_OK) {
tao_reflect_camera_information(shcam, dev);
tao_unlock_shared_camera(NULL, shcam);
}
tao_wrlock_shared_camera(NULL, shcam);
tao_reflect_camera_information(shcam, dev);
tao_unlock_shared_camera(NULL, shcam);
info.config = dev->info.config;
}
if (status != TAO_OK) {
......
/*
* tao-cameras.h --
*
* Definitions for cameras in TAO. The API is similar to the ScientificCameras
* Julia package.
* Definitions and API for cameras in TAO.
*
*-----------------------------------------------------------------------------
*
......@@ -29,7 +28,7 @@ _TAO_BEGIN_DECLS
*
* - `tao_framegrabber_t` emulates a virtual frame grabber.
*
* - `tao_camera_t` provides a unified interface with a camera device.
* - `tao_camera_t` provides a unified interface to a camera device.
*
* - `tao_shared_camera_t` stores the current state of a camera in shared
* memory.
......@@ -889,7 +888,7 @@ tao_attach_next_image(tao_error_t** errs,
/** @} */
/*---------------------------------------------------------------------------*/
/* GENERIC CAMERAS */
/* UNIFIED INTERFACE FOR CAMERA DEVICES */
/**
* @addtogroup UnifiedCameras
......@@ -900,7 +899,8 @@ tao_attach_next_image(tao_error_t** errs,
*
* The @ref tao_camera_t structure has its own error stack which is used by
* most functions operating on this class of cameras to store error
* information.
* information. This is needed because the camera device may be operated by
* another thread.
*
* The end user shall call tao_any_camera_errors() to check whether there are
* any errors, tao_report_camera_errors() to print any errors to the standard
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment