From 6b8a5d334c7c29dfc0a106c3abb3d8dbb5f77bbd Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sat, 17 Jan 2015 19:41:22 +0000 Subject: [PATCH] also adjust the backoff logic for nikon cameras to wait longer git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@15332 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/ptp2/library.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c index bb3dc3be1..f2bc112e7 100644 --- a/camlibs/ptp2/library.c +++ b/camlibs/ptp2/library.c @@ -4027,7 +4027,7 @@ camera_wait_for_event (Camera *camera, int timeout, if (_timeout_passed (&event_start, timeout)) break; - /* incremental backoff wait ... including this wait loop */ + /* incremental backoff wait ... including this wait loop, will go up to 200ms. */ for (i=sleepcnt;i--;) { int resttime; struct timeval curtime; @@ -4035,12 +4035,14 @@ camera_wait_for_event (Camera *camera, int timeout, gp_context_idle (context); gettimeofday (&curtime, 0); resttime = ((curtime.tv_sec - event_start.tv_sec)*1000)+((curtime.tv_usec - event_start.tv_usec)/1000); - if (resttime < 20) + if (resttime <= 0) break; - usleep(20*1000); /* 20 ms */ + if (resttime > 50) + resttime = 50; + usleep(resttime*1000); /* at most 50 ms */ } sleepcnt++; /* incremental back off */ - if (sleepcnt>10) sleepcnt=10; + if (sleepcnt>4) sleepcnt = 4; continue; } sleepcnt = 1;