diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2023-03-06 11:06:48 +0100 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2023-03-06 11:06:48 +0100 |
commit | 17bc4149da9cab810327de36d84506c096197a2a (patch) | |
tree | 6bc2f7220ab8ed0542c0bdded4687bc77098cbf8 | |
parent | 3aa4e89ac8f908b39881e58a10646dce0d833312 (diff) | |
download | libgphoto2-17bc4149da9cab810327de36d84506c096197a2a.tar.gz |
break out of the setter loop if we reached the correct state
fixes https://github.com/gphoto/libgphoto2/issues/896
-rw-r--r-- | camlibs/ptp2/config.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c index 0edb12d11..c78e70830 100644 --- a/camlibs/ptp2/config.c +++ b/camlibs/ptp2/config.c @@ -1356,12 +1356,14 @@ fallback: \ \ /* we tell the camera to do it, but it takes around 0.7 seconds for the SLT-A58 */ \ time(&start); \ + int matched = 0; \ do { \ C_PTP_REP (ptp_sony_getalldevicepropdesc (params)); \ C_PTP_REP (ptp_generic_getdevicepropdesc (params, prop, &dpd)); \ \ if (dpd.CurrentValue.bits == value) { \ GP_LOG_D ("Value matched!"); \ + matched = 1; \ break; \ } \ if (dpd.CurrentValue.bits != origval) { \ @@ -1373,6 +1375,7 @@ fallback: \ \ time(&end); \ } while (end-start <= 3); \ + if (matched) break; \ \ int overshoot = 0; \ if (useenumorder) { \ @@ -1383,18 +1386,18 @@ fallback: \ } \ } \ GP_LOG_D("posnow %d, value %d", posnow, dpd.CurrentValue.bits); \ - \ - /* - If we made a small +-1 adjustment, check for overshoot. - However, use enum position instead of value itself for comparisons as enums - are not always sorted (e.g. Auto ISO has higher numerical value but comes earlier). - */ \ + \ + /* \ + If we made a small +-1 adjustment, check for overshoot. \ + However, use enum position instead of value itself for comparisons as enums \ + are not always sorted (e.g. Auto ISO has higher numerical value but comes earlier). \ + */ \ overshoot = ((propval.u8 == 0x01) && (posnow > posnew)) || ((propval.u8 == 0xff) && (posnow < posnew)); \ } else { \ overshoot = ((propval.u8 == 0x01) && (dpd.CurrentValue.bits > value)) || ((propval.u8 == 0xff) && (dpd.CurrentValue.bits < value)); \ - } \ - \ - if (overshoot) { \ + } \ + \ + if (overshoot) { \ GP_LOG_D ("We overshooted value, maybe not exact match possible. Break!"); \ break; \ } \ @@ -1408,7 +1411,7 @@ fallback: \ break; \ } \ /* We did not get there. Did we hit 0? */ \ - if (useenumorder) { \ + if (useenumorder) { \ if (posnow == -1) { \ GP_LOG_D ("Now value is not in enumeration, falling back to ordered tries.");\ useenumorder = 0; \ |