[sane-devel] Patch to make XSane work with SANE 1.1

stef stef.dev at free.fr
Wed Oct 8 04:49:51 UTC 2008

Le Tuesday 07 October 2008 22:35:37 Julien BLACHE, vous avez écrit :
> stef <stef.dev at free.fr> wrote:
> Hi,
> >> 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
> busy-looping.
> 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
> do
>  {
>    while (gtk_events_pending())
>      gtk_main_iteration();
>    status = sane_start(dev);
>  } while (status == SANE_STATUS_WARMING_UP);
> Otherwise the GUI will break in an ugly, 1990 kind of way.
> JB.


	I agree with you. This is the way that xscanimage was modified to handle 
warming up. Hints to get it even better are welcomed. You can test this 
functionality with the 'pnm:warmup' test backend.


More information about the sane-devel mailing list