From 64beb015d693ef7f57ed17f99ca55d1b9d8b2cec Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Fri, 10 Jul 2009 17:49:19 +0000 Subject: [PATCH] replaced fixed sleep times in EOS code by incremental backoff from 20ms to 200ms git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@12214 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/ptp2/library.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c index 6655ad2bc..d72d926b6 100644 --- a/camlibs/ptp2/library.c +++ b/camlibs/ptp2/library.c @@ -1693,6 +1693,7 @@ camera_canon_eos_capture (Camera *camera, CameraCaptureType type, CameraFilePath unsigned char *ximage = NULL; static int capcnt = 0; PTPObjectInfo oi; + int sleepcnt = 1; time_t capture_start=time(NULL); if (!ptp_operation_issupported(params, PTP_OC_CANON_EOS_RemoteRelease)) { @@ -1734,10 +1735,15 @@ camera_canon_eos_capture (Camera *camera, CameraCaptureType type, CameraFilePath } if (!nrofentries) { free (entries); - gp_context_idle (context); - usleep(100*1000); /* 100 ms */ + for (i=sleepcnt;i--;) { + gp_context_idle (context); + usleep(20*1000); /* 20 ms */ + } + sleepcnt++; /* incremental back off */ + if (sleepcnt>10) sleepcnt=10; continue; } + sleepcnt = 1; for (i=0;i10) sleepcnt=10; continue; } + sleepcnt = 1; for (i=0;i