Logo Search packages:      
Sourcecode: libgphoto2 version File versions  Download package

int gp_camera_start_timeout ( Camera camera,
unsigned int  timeout,
CameraTimeoutFunc  func 
)

Parameters:
camera a Camera
timeout number of seconds that should pass between each call to func
func the function that should be called each timeout seconds
Returns:
The id of the background process or a gphoto2 error code
This function should be called by the camera driver during camera_init() if the camera needs to be sent messages periodically in order to prevent it from shutting down.

Definition at line 1454 of file gphoto2-camera.c.

References GP_ERROR_BAD_PARAMETERS, GP_ERROR_NO_MEMORY, and GP_ERROR_NOT_SUPPORTED.

{
      int id;
      unsigned int *ids;

      if (!camera || !camera->pc)
            return (GP_ERROR_BAD_PARAMETERS);

      if (!camera->pc->timeout_start_func)
            return (GP_ERROR_NOT_SUPPORTED);

      /*
       * We remember the id here in order to automatically remove
       * the timeout on gp_camera_exit.
       */
      ids = realloc (camera->pc->timeout_ids, sizeof (int) *
                              (camera->pc->timeout_ids_len + 1));
      if (!ids)
            return (GP_ERROR_NO_MEMORY);
      camera->pc->timeout_ids = ids;

      id = camera->pc->timeout_start_func (camera, timeout, func,
                                   camera->pc->timeout_data);
      if (id < 0)
            return (id);
      camera->pc->timeout_ids[camera->pc->timeout_ids_len] = id;
      camera->pc->timeout_ids_len++;

      return (id);
}


Generated by  Doxygen 1.6.0   Back to index