Logo Search packages:      
Sourcecode: libgphoto2 version File versions

int gp_camera_exit ( Camera camera,
GPContext context 
)

Close connection to camera.

Parameters:
camera a Camera object
context a GPContext object
Returns:
a gphoto2 error code.
Closes a connection to the camera and therefore gives other application the possibility to access the camera, too.

It is recommended that you call this function when you currently don't need the camera. The camera will get reinitialized by gp_camera_init() automatically if you try to access the camera again.

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

References CHECK_NULL, gp_camera_stop_timeout(), gp_filesystem_reset(), gp_log(), GP_LOG_DEBUG, GP_OK, gp_port_close(), and gp_port_open().

Referenced by gp_camera_free(), gp_camera_set_abilities(), and gp_camera_set_port_speed().

{
      CHECK_NULL (camera);

      gp_log (GP_LOG_DEBUG, "gphoto2-camera", "Exiting camera ('%s')...",
            camera->pc->a.model);

      /*
       * We have to postpone this operation if the camera is currently 
       * in use. gp_camera_exit will be called again if the
       * camera->pc->used will drop to zero.
       */
      if (camera->pc->used) {
            camera->pc->exit_requested = 1;
            return (GP_OK);
      }

      /* Remove every timeout that is still pending */
      while (camera->pc->timeout_ids_len)
            gp_camera_stop_timeout (camera, camera->pc->timeout_ids[0]);
      free (camera->pc->timeout_ids);
      camera->pc->timeout_ids = NULL;

      if (camera->functions->exit) {
#ifdef HAVE_MULTI
            gp_port_open (camera->port);
#endif
            camera->functions->exit (camera, context);
      }
      gp_port_close (camera->port);
      memset (camera->functions, 0, sizeof (CameraFunctions));

      if (camera->pc->lh) {
            lt_dlclose (camera->pc->lh);
            lt_dlexit ();
            camera->pc->lh = NULL;
      }

      gp_filesystem_reset (camera->fs);

      return (GP_OK);
}


Generated by  Doxygen 1.6.0   Back to index