kopia lustrzana https://gitlab.com/sane-project/backends
avision.c: abort "wait for light" loop if interrupted
Adds a "cancelled" flag to the Avision device structure, cleared in sane_start() and set in sane_cancel(). Test this flag in wait_4_light() and bail out of the 90-second "wait for the light to warm up" loop if the scan is cancelled.merge-requests/1/head
rodzic
28963459a4
commit
755e829caa
|
@ -2756,6 +2756,11 @@ wait_4_light (Avision_Scanner* s)
|
||||||
set_triple (rcmd.transferlen, size);
|
set_triple (rcmd.transferlen, size);
|
||||||
|
|
||||||
for (try = 0; try < 90; ++ try) {
|
for (try = 0; try < 90; ++ try) {
|
||||||
|
|
||||||
|
if (s->cancelled) {
|
||||||
|
DBG (3, "wait_4_light: cancelled\n");
|
||||||
|
return SANE_STATUS_CANCELLED;
|
||||||
|
}
|
||||||
|
|
||||||
DBG (5, "wait_4_light: read bytes %lu\n", (u_long) size);
|
DBG (5, "wait_4_light: read bytes %lu\n", (u_long) size);
|
||||||
status = avision_cmd (&s->av_con, &rcmd, sizeof (rcmd), 0, 0, &result, &size);
|
status = avision_cmd (&s->av_con, &rcmd, sizeof (rcmd), 0, 0, &result, &size);
|
||||||
|
@ -6217,6 +6222,7 @@ do_cancel (Avision_Scanner* s)
|
||||||
s->prepared = s->scanning = SANE_FALSE;
|
s->prepared = s->scanning = SANE_FALSE;
|
||||||
s->duplex_rear_valid = SANE_FALSE;
|
s->duplex_rear_valid = SANE_FALSE;
|
||||||
s->page = 0;
|
s->page = 0;
|
||||||
|
s->cancelled = 1;
|
||||||
|
|
||||||
if (sanei_thread_is_valid (s->reader_pid)) {
|
if (sanei_thread_is_valid (s->reader_pid)) {
|
||||||
int exit_status;
|
int exit_status;
|
||||||
|
@ -8320,6 +8326,9 @@ sane_start (SANE_Handle handle)
|
||||||
/* Make sure there is no scan running!!! */
|
/* Make sure there is no scan running!!! */
|
||||||
if (s->scanning)
|
if (s->scanning)
|
||||||
return SANE_STATUS_DEVICE_BUSY;
|
return SANE_STATUS_DEVICE_BUSY;
|
||||||
|
|
||||||
|
/* Clear cancellation status */
|
||||||
|
s->cancelled = 0;
|
||||||
|
|
||||||
/* Make sure we have a current parameter set. Some of the
|
/* Make sure we have a current parameter set. Some of the
|
||||||
parameters will be overwritten below, but that's OK. */
|
parameters will be overwritten below, but that's OK. */
|
||||||
|
|
|
@ -444,6 +444,7 @@ typedef struct Avision_Scanner
|
||||||
SANE_Bool prepared; /* first page marker */
|
SANE_Bool prepared; /* first page marker */
|
||||||
SANE_Bool scanning; /* scan in progress */
|
SANE_Bool scanning; /* scan in progress */
|
||||||
unsigned int page; /* page counter, 0: uninitialized, 1: scanning 1st page, ... */
|
unsigned int page; /* page counter, 0: uninitialized, 1: scanning 1st page, ... */
|
||||||
|
int cancelled;
|
||||||
|
|
||||||
SANE_Parameters params; /* scan window */
|
SANE_Parameters params; /* scan window */
|
||||||
Avision_Dimensions avdimen; /* scan window - detailed internals */
|
Avision_Dimensions avdimen; /* scan window - detailed internals */
|
||||||
|
|
Ładowanie…
Reference in New Issue