Commit 61a274a9 authored by Éric Thiébaut's avatar Éric Thiébaut
Browse files

Use a function to copy camera information and fix orthograph

parent 2d5b3dd7
......@@ -56,7 +56,7 @@ static tao_status on_reset(
return on_send(dm, ctx);
}
// Release ressources. This function is automatically called on normal exit.
// Release resources. This function is automatically called on normal exit.
static void cleanup(void)
{
if (dm != NULL) {
......
......@@ -203,7 +203,7 @@ int main(
return EXIT_FAILURE;
}
// Value returned on exit and created ressources.
// Value returned on exit and created resources.
int retval = EXIT_SUCCESS;
tao_camera* dev = NULL;
tao_camera_server* srv = NULL;
......
......@@ -155,7 +155,7 @@ static tao_status update_processing_parameters(
// server. Most of these macros yield an L-value which is suitable for
// assignment.
//
// The names of these functions and macros shall make clear which ressource
// The names of these functions and macros shall make clear which resource
// must be locked by the caller and how.
//-----------------------------------------------------------------------------
......@@ -1292,6 +1292,22 @@ static void execute_command(
camera_device_unlock(srv);
}
// Copy camera information that may have changed while acquisition is running
// from source `src` to destination `dst`. The caller must have correctly
// locked the two resources.
static inline void copy_running_camera_information(
tao_camera_info* dst,
const tao_camera_info* src)
{
dst->frames = src->frames;
dst->droppedframes = src->droppedframes;
dst->overruns = src->overruns;
dst->lostframes = src->lostframes;
dst->overflows = src->overflows;
dst->lostsyncs = src->lostsyncs;
dst->timeouts = src->timeouts;
}
// High-level function called by the worker thread to wait for the next
// acquisition buffer.
//
......@@ -1319,15 +1335,7 @@ static void wait_buffer(
}
// Copy information that may have changed.
tao_camera_info* dst = &srv->info;
const tao_camera_info* src = &srv->device->info;
dst->frames = src->frames;
dst->droppedframes = src->droppedframes;
dst->overruns = src->overruns;
dst->lostframes = src->lostframes;
dst->overflows = src->overflows;
dst->lostsyncs = src->lostsyncs;
dst->timeouts = src->timeouts;
copy_running_camera_information(&srv->info, &srv->device->info);
// Unlock the camera device.
camera_device_unlock(srv);
......@@ -1378,7 +1386,7 @@ static void remote_camera_write_shmid(
//
// Caller must have only locked the server structure.
//
// The worker may use the server ressources, the camera device, and the remote
// The worker may use the server resources, the camera device, and the remote
// camera. It communicates with the server via the mutex and the condition
// variable of the server structure.
static void* run_worker(
......@@ -1469,15 +1477,7 @@ static void* run_worker(
// Update remote camera information.
remote_camera_lock(srv);
remote_camera_serial(srv) = srv->serial;
tao_camera_info* dst = &srv->remote->info;
const tao_camera_info* src = &srv->info;
dst->frames = src->frames;
dst->droppedframes = src->droppedframes;
dst->overruns = src->overruns;
dst->lostframes = src->lostframes;
dst->overflows = src->overflows;
dst->lostsyncs = src->lostsyncs;
dst->timeouts = src->timeouts;
copy_running_camera_information(&srv->remote->info, &srv->info);
remote_camera_notify(srv);
remote_camera_unlock(srv);
}
......@@ -1814,7 +1814,7 @@ tao_camera_server* tao_camera_server_create(
srv->images[i] = NULL;
}
// Allocate ressources for processing images and update camera information.
// Allocate resources for processing images and update camera information.
server_lock(srv);
camera_device_lock(srv);
remote_camera_lock(srv);
......@@ -1856,7 +1856,7 @@ tao_status tao_camera_server_destroy(
}
}
// Destroy ressources shared with clients.
// Destroy resources shared with clients.
if (remote_camera(srv) != NULL) {
// Lock remote camera and indicate that server is unreachable.
remote_camera_lock(srv);
......
......@@ -423,7 +423,7 @@ const char* FUNC(
CASE(TAO_MUST_RESET, "Device must be reset");
CASE(TAO_MISSING_SEPARATOR, "Separator missing");
CASE(TAO_EXHAUSTED, "Resource exhausted");
CASE(TAO_DESTROYED, "Ressource has been destroyed");
CASE(TAO_DESTROYED, "Resource has been destroyed");
CASE(TAO_CORRUPTED, "Corrupted structure");
CASE(TAO_CANT_TRACK_ERROR, "Insufficient memory to track errors");
CASE(TAO_BROKEN_CYCLE, "Broken cycle or unordered operations");
......
......@@ -165,7 +165,7 @@ tao_serial tao_remote_camera_configure(
tao_remote_object_cast(cam), TAO_COMMAND_CONFIG, secs);
if (num > 0) {
// Server is ready to accept a new command. Copy configuration to
// start with as the next configuration and unlock the ressources.
// start with as the next configuration and unlock the resources.
memcpy(&cam->arg.config, cfg, sizeof(*cfg));
if (tao_remote_camera_unlock(cam) != TAO_OK) {
num = -1;
......
......@@ -299,7 +299,7 @@ tao_serial tao_remote_mirror_set_reference(
if (num > 0) {
// The server is ready for a new command.
//
// 1. Copy the reference commands in the shared ressources.
// 1. Copy the reference commands in the shared resources.
memcpy(dest, vals, nvals*sizeof(double));
//
// 2. There is nothing else to be done by the server, so we increment
......@@ -308,7 +308,7 @@ tao_serial tao_remote_mirror_set_reference(
obj->base.ncmds = num;
obj->base.command = TAO_COMMAND_NONE;
//
// 3. Finally unlock the ressources.
// 3. Finally unlock the resources.
if (tao_remote_mirror_unlock(obj) != TAO_OK) {
num = -1;
}
......
......@@ -193,7 +193,7 @@ tao_serial tao_remote_object_wait_output(
}
# undef keep_waiting
// Unlock ressources.
// Unlock resources.
if (locked && tao_remote_object_unlock(obj) != TAO_OK) {
status = TAO_ERROR;
}
......@@ -291,7 +291,7 @@ tao_status tao_remote_object_wait_command(
# undef keep_waiting
// Unlock ressources.
// Unlock resources.
if (locked && tao_remote_object_unlock(obj) != TAO_OK) {
status = TAO_ERROR;
}
......
......@@ -69,7 +69,7 @@ struct tao_pixels_processor_context_ {
* Camera server structure.
*
* The mutex and condition variable of a camera server are to control the
* access to the ressources of the camera server which are shared between two
* access to the resources of the camera server which are shared between two
* threads: the "server", that is the calling thread of
* tao_camera_server_run_loop(), and the "worker". The "worker" is in charge
* of the camera device.
......@@ -174,7 +174,7 @@ extern tao_status tao_camera_server_destroy(
* @brief Run the main loop of a camera server.
*
* This high-level function runs the main loop of a camera server. None of the
* ressources controlled by the server (the server itself, the camera device,
* resources controlled by the server (the server itself, the camera device,
* and the remote camera) shall be locked by the caller.
*
* @param srv Pointer to a camera server.
......
......@@ -403,10 +403,10 @@ extern tao_camera* tao_camera_create(
size_t size);
/**
* @brief Release the ressources associated to a camera.
* @brief Release the resources associated to a camera.
*
* This function aborts any acquisition with the associated camera and releases
* all related ressources. The camera must not be locked when calling this
* all related resources. The camera must not be locked when calling this
* function.
*
* @warning The camera must not have been locked by the caller.
......
......@@ -25,7 +25,7 @@
*
* This module provides:
*
* - means to control access to shared ressources: exclusive locks, conditions
* - means to control access to shared resources: exclusive locks, conditions
* variables, read/write locks, and semaphores that may be shared by
* processes;
*
......
......@@ -53,7 +53,7 @@ static tao_status on_reset(
return on_send(dm, ctx);
}
// Release ressources. This function is automatically called on normal exit.
// Release resources. This function is automatically called on normal exit.
static void cleanup(void)
{
if (dm != NULL) {
......
......@@ -75,7 +75,7 @@ typedef struct tao_threadpool_ tao_threadpool;
*
* @return The address of the thread-pool, `NULL` in case of failure. It is the
* caller's responsibility to call tao_threadpool_destroy() to
* eventually release ressources associated with the thread-pool.
* eventually release resources associated with the thread-pool.
*/
extern tao_threadpool* tao_threadpool_create(
int workers);
......@@ -83,7 +83,7 @@ extern tao_threadpool* tao_threadpool_create(
/**
* Destroy a thread-pool.
*
* This function destroys a thread-pool releasing all associated ressources.
* This function destroys a thread-pool releasing all associated resources.
* Calling this function waits for running jobs to complete. Running jobs are
* completed but unstarted jobs are abandoned.
*
......@@ -98,7 +98,7 @@ extern void tao_threadpool_destroy(
* This function pushes a new job in the queue of pending jobs of a
* thread-pool. Execution of the job is started as soon as possible but after
* previouly pushed jobs have been completed. It is the caller responsibility
* to make sure that the ressources used by the function specified to execute
* to make sure that the resources used by the function specified to execute
* the job will remain accessible when this function will be executed.
*
* @param pool The address of the thread-pool.
......
......@@ -25,7 +25,7 @@ struct tao_job_ {
};
struct tao_threadpool_ {
tao_mutex mutex; ///< Lock to control access to ressources.
tao_mutex mutex; ///< Lock to control access to resources.
tao_cond task; ///< Condition variable to notify idle workers that a new
/// task has been assigned (a job has been pushed or
/// quitting has been requested).
......@@ -106,7 +106,7 @@ static void* run_worker(
return NULL;
}
// The routine to release ressources associated with a thread-pool. It is
// The routine to release resources associated with a thread-pool. It is
// assumed that the structure has been allocated (non-NULL) although it may
// not have been fully initialized (as indicated by the level).
static void finalize(
......@@ -116,7 +116,7 @@ static void finalize(
// If thread-pool was correctly initialized, there may be pending
// and/or running jobs.
if (level >= 3) {
// Lock ressources.
// Lock resources.
LOCK(pool);
// Remove all unstarted jobs from the queue of pending jobs.
......@@ -142,12 +142,12 @@ static void finalize(
free((void*)job);
}
// Unlock ressources (the mutex must be unlocked before being
// Unlock resources (the mutex must be unlocked before being
// destroyed).
UNLOCK(pool);
}
// Destroy other ressources.
// Destroy other resources.
if (level >= 3) {
pthread_cond_destroy(&pool->done);
}
......@@ -268,7 +268,7 @@ tao_status tao_threadpool_push_job(
errno = EFAULT;
status = TAO_ERROR;
} else {
// Lock ressources.
// Lock resources.
LOCK(pool);
if (pool->quitting) {
......@@ -307,7 +307,7 @@ tao_status tao_threadpool_push_job(
}
}
// Unlock ressources.
// Unlock resources.
UNLOCK(pool);
}
......
......@@ -113,7 +113,7 @@ chosen by the creator.
If POSIX shared memory is used, the unique numerical identifier of the object
is created by incrementing a counter when the object is created. The counter
is stored in shared memory in the global object manager ressources. The path
is stored in shared memory in the global object manager resources. The path
name is composed as:
```c
......@@ -156,7 +156,7 @@ typedef struct TaoSharedObject {
pthread_mutex_t mutex; /* mutex associated with the object */
int32_t nrefs; /* number of references on the object */
uint32_t size; /* totla number of bytes allocated for the object */
int32_t shmid; /* numerical identifier of the ressource */
int32_t shmid; /* numerical identifier of the resource */
int32_t type; /* object type */
} TaoSharedObject;
```
......
......@@ -374,7 +374,7 @@ Actual code is more complicated because, there may be errors, timeouts (to avoid
waiting for ever), and the server may have been killed (it is not sufficient to
just check the value of pending command while waiting).
A variant may be to unlock the ressources while processing the command but this
A variant may be to unlock the resources while processing the command but this
is only of interest if something in the `ctrl` structure has changed at that
time.
......
......@@ -173,7 +173,7 @@ int main(
return EXIT_FAILURE;
}
// Value returned on exit and created ressources.
// Value returned on exit and created resources.
int retval = EXIT_SUCCESS;
tao_camera* dev = NULL;
tao_camera_server* srv = NULL;
......
......@@ -185,7 +185,7 @@ typedef struct phnx_create_options_ {
* This function allocates a camera handler, connects to the camera and sets
* some initial camera parameters. A pointer to a `tao_camera` structure is
* returned. This pointer can be used to query/set camera parameters and
* acquire images. When no longer needed, the ressources should be released by
* acquire images. When no longer needed, the resources should be released by
* calling tao_destroy_camera().
*
* @param handler A user defined handler for errors. If `NULL`, a
......
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