From f6896e0de481fad5c63bf7ffc271aca89b9cbb01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Voltz?= Date: Sun, 12 Apr 2015 10:14:50 +0200 Subject: [PATCH] use expiration time option - use expiration time option value to managed cached entries - changelog for genesys build #2506 --- ChangeLog | 5 +++++ backend/genesys.c | 3 +++ backend/genesys_low.c | 9 +++++---- backend/genesys_low.h | 3 +++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea9650097..81b904fa6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-04-12 Stéphane Voltz + * doc/sane-genesys.man backend/genesys.[ch] backend/genesys_low.c: + fix calibration cleared when calibration file loaded, + add expiration time option for cache. + 2015-04-07 Rolf Bensch * backend/pixma_mp810.c: Canon Pixma MP990 TPU scan patch from Guillaume Courtois. diff --git a/backend/genesys.c b/backend/genesys.c index bef4991b1..548d0da9c 100644 --- a/backend/genesys.c +++ b/backend/genesys.c @@ -5320,6 +5320,9 @@ calc_parameters (Genesys_Scanner * s) s->dev->settings.brightness=0; } + /* cache expiration time */ + s->dev->settings.expiration_time=s->val[OPT_EXPIRATION_TIME].w; + return status; } diff --git a/backend/genesys_low.c b/backend/genesys_low.c index bfd38df4e..0af21496d 100644 --- a/backend/genesys_low.c +++ b/backend/genesys_low.c @@ -1766,7 +1766,8 @@ int sanei_genesys_get_lowest_dpi(Genesys_Device *dev) * A calibration cache is compatible if color mode and x dpi match the user * requested scan. In the case of CIS scanners, dpi isn't a criteria. * flatbed cache entries are considred too old and then expires if they - * are older dans 1h, forcing calcibration at least once an hour. */ + * are older than the expiration time option, forcing calibration at least once + * then given time. */ SANE_Status sanei_genesys_is_compatible_calibration (Genesys_Device * dev, Genesys_Calibration_Cache * cache, @@ -1832,13 +1833,13 @@ sanei_genesys_is_compatible_calibration (Genesys_Device * dev, return SANE_STATUS_UNSUPPORTED; } - /* a cache entry expires after 60 minutes for non sheetfed scanners */ + /* a cache entry expires after afetr expiration time for non sheetfed scanners */ /* this is not taken into account when overwriting cache entries */ #ifdef HAVE_SYS_TIME_H - if(for_overwrite == SANE_FALSE) + if(for_overwrite == SANE_FALSE && dev->settings.expiration_time >=0) { gettimeofday (&time, NULL); - if ((time.tv_sec - cache->last_calibration > 60 * 60) + if ((time.tv_sec - cache->last_calibration > dev->settings.expiration_time*60) && (dev->model->is_sheetfed == SANE_FALSE) && (dev->settings.scan_method == SCAN_METHOD_FLATBED)) { diff --git a/backend/genesys_low.h b/backend/genesys_low.h index 6b0e6dc8f..b5a0a8f00 100644 --- a/backend/genesys_low.h +++ b/backend/genesys_low.h @@ -707,6 +707,9 @@ typedef struct /**< value for brightness enhancement in the [-100..100] range */ int brightness; + + /**< cahe entries expiration time */ + int expiration_time; } Genesys_Settings; typedef struct Genesys_Current_Setup