From 56ade2e8c5751f5471c9e1ae93f94778db050139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Voltz?= Date: Tue, 1 Dec 2009 21:42:48 +0100 Subject: [PATCH] take data buffered in scanner into account at end of document - when document end is detected while scanning, we must take the amount of data buffered in scanner to compute the number of data bytes needed to flush. --- backend/genesys_gl841.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/genesys_gl841.c b/backend/genesys_gl841.c index fb211e357..25a7863fb 100644 --- a/backend/genesys_gl841.c +++ b/backend/genesys_gl841.c @@ -3927,6 +3927,7 @@ gl841_detect_document_end (Genesys_Device * dev) { SANE_Status status = SANE_STATUS_GOOD; SANE_Bool paper_loaded; + unsigned int words = 0; int flines, channels, depth, bytes_remain, sublines, bytes_to_flush, lines, sub_bytes, tmp, read_bytes_left; DBG (DBG_proc, "%s: begin\n", __FUNCTION__); @@ -3966,12 +3967,19 @@ gl841_detect_document_end (Genesys_Device * dev) bytes_remain = bytes_remain - tmp; DBG (DBG_io, "gl841_detect_document_end: bytes_remain=%d\n", bytes_remain); + /* we substract the amount of data that is still in scanner's buffer */ + status = sanei_genesys_read_valid_words (dev, &words); + if (status == SANE_STATUS_GOOD) + { + bytes_remain -= words; + } + /* remaining lines to read by frontend for the current scan */ if (depth == 1 || dev->settings.scan_mode == SCAN_MODE_LINEART) - { + { flines = bytes_remain * 8 / dev->settings.pixels / channels; - } + } else flines = bytes_remain / (depth / 8) / dev->settings.pixels / channels; @@ -6204,3 +6212,5 @@ sanei_gl841_init_cmd_set (Genesys_Device * dev) dev->model->cmd_set = &gl841_cmd_set; return SANE_STATUS_GOOD; } + +/* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */