From 3a6d9ca8df725d596dc76f731c4fc9dfa6116e65 Mon Sep 17 00:00:00 2001 From: "B. Bogart" Date: Tue, 9 Mar 2010 01:58:27 +0000 Subject: Made some slight changes, for example the limit of ~500 images is likely due to the lack of a file close in captureImage, as there is a limit to how many files can be open by a single process. Testing the capture of more than 500 images at a time has not been done. Also added some missing sys_lock() and sys_unlock() calls around error(). svn path=/trunk/externals/bbogart/; revision=13196 --- gphoto/gphoto.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'gphoto/gphoto.c') diff --git a/gphoto/gphoto.c b/gphoto/gphoto.c index 45b75a6..0a574a4 100644 --- a/gphoto/gphoto.c +++ b/gphoto/gphoto.c @@ -1,5 +1,5 @@ /* Gphoto PD External */ -/* Copyright Ben Bogart, 2009 */ +/* Copyright Ben Bogart, 2009/2010 */ /* This program is distributed under the params of the GNU Public License */ /////////////////////////////////////////////////////////////////////////////////// @@ -366,23 +366,27 @@ void *captureImage(void *threadArgs) { CameraFile *camerafile; CameraFilePath camera_file_path; t_symbol *filename; - + + sys_lock(); filename = atom_getsymbol( ((gphoto_gimme_struct *)threadArgs)->argv ); // destination filename + sys_unlock(); gp_ret = gp_camera_capture(((gphoto_gimme_struct *)threadArgs)->gphoto->camera, GP_CAPTURE_IMAGE, &camera_file_path, NULL); - if (gp_ret != 0) {error("3gphoto: ERROR: %s\n", gp_result_as_string(gp_ret)); gp_camera_unref(((gphoto_gimme_struct *)threadArgs)->gphoto->camera); return(NULL);} + if (gp_ret != 0) {sys_lock(); error("gphoto: ERROR: %s\n", gp_result_as_string(gp_ret)); sys_unlock(); gp_camera_unref(((gphoto_gimme_struct *)threadArgs)->gphoto->camera); return(NULL);} fd = open( filename->s_name, O_CREAT | O_WRONLY, 0644); // create file descriptor gp_ret = gp_file_new_from_fd(&camerafile, fd); // create gphoto file from descriptor - if (gp_ret != 0) {error("4gphoto: ERROR: %s\n", gp_result_as_string(gp_ret)); gp_camera_unref(((gphoto_gimme_struct *)threadArgs)->gphoto->camera); return(NULL);} + if (gp_ret != 0) {sys_lock(); error("gphoto: ERROR: %s\n", gp_result_as_string(gp_ret)); sys_unlock(); gp_camera_unref(((gphoto_gimme_struct *)threadArgs)->gphoto->camera); return(NULL);} gp_ret = gp_camera_file_get(((gphoto_gimme_struct *)threadArgs)->gphoto->camera, camera_file_path.folder, camera_file_path.name, GP_FILE_TYPE_NORMAL, camerafile, NULL); // get file from camera - if (gp_ret != 0) {error("5gphoto: ERROR: %s\n", gp_result_as_string(gp_ret)); gp_camera_unref(((gphoto_gimme_struct *)threadArgs)->gphoto->camera); return(NULL);} + if (gp_ret != 0) {sys_lock(); error("gphoto: ERROR: %s\n", gp_result_as_string(gp_ret)); sys_unlock(); gp_camera_unref(((gphoto_gimme_struct *)threadArgs)->gphoto->camera); return(NULL);} gp_ret = gp_camera_file_delete(((gphoto_gimme_struct *)threadArgs)->gphoto->camera, camera_file_path.folder, camera_file_path.name, NULL); - if (gp_ret != 0) {error("6gphoto: ERROR: %s\n", gp_result_as_string(gp_ret)); gp_camera_unref(((gphoto_gimme_struct *)threadArgs)->gphoto->camera); return(NULL);} + if (gp_ret != 0) {sys_lock(); error("gphoto: ERROR: %s\n", gp_result_as_string(gp_ret)); sys_unlock(); gp_camera_unref(((gphoto_gimme_struct *)threadArgs)->gphoto->camera); return(NULL);} + + close(fd); // close file descriptor // Send bang out 2nd outlet when operation is done. sys_lock(); -- cgit v1.2.1