[sane-devel] Patch to make XSane work with SANE 1.1
jb at jblache.org
Tue Oct 7 20:35:37 UTC 2008
stef <stef.dev at free.fr> wrote:
>> Please, tell me this is not busy-looping on sane_start() ...
> sorry can't tell you that. It is indeed doing busy-looping. While it works
> fine with the pnm backend and the rts8891 which handles warming-up, adding a
> sleep() in the loop would be better. However, this will have to be replaced
> with some dialog box, which is the reason there is a SANE_STATUS_WARMING_UP.
> It is currently a quick fix to make XSane work with SANE 1.1.
The problem is that the dialog box will hardly alleviate the need to
poll for the scanner status by calling sane_start() repeatedly.
Also sleeping is never a good idea as in some cases you'll just end up
chewing CPU as if you were busy-looping (and chewing CPU means taking
CPU time away from other, well-behaved processes). If the delay is
long enough you can sched_yield(), but the effects vary greatly
depending on the scheduler and the load on the machine.
If a frontend now has to poll for the status of the scanner, then
there should be a way to do so properly, without having to rely on
The interface here is not good enough; it's not going to work well for
scanners that need 30+ seconds to warm up like my 2480 does.
Also for XSane, at a minimum, the code should be like
status = sane_start(dev);
} while (status == SANE_STATUS_WARMING_UP);
Otherwise the GUI will break in an ugly, 1990 kind of way.
Julien BLACHE <http://www.jblache.org>
<jb at jblache.org> GPG KeyID 0xF5D65169
More information about the sane-devel