aboutsummaryrefslogtreecommitdiff
path: root/gphoto/gphoto.c
diff options
context:
space:
mode:
authorB. Bogart <bbogart@users.sourceforge.net>2010-03-09 01:58:27 +0000
committerB. Bogart <bbogart@users.sourceforge.net>2010-03-09 01:58:27 +0000
commit3a6d9ca8df725d596dc76f731c4fc9dfa6116e65 (patch)
treeac125aa74da166a1a3719403bb7a2a3d46d305bd /gphoto/gphoto.c
parent4570aa77dc44b45b43887e2596d789738b28056b (diff)
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
Diffstat (limited to 'gphoto/gphoto.c')
-rw-r--r--gphoto/gphoto.c16
1 files changed, 10 insertions, 6 deletions
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();