[sane-devel] sane_get_devices and sanei_usb_init

ABC abc at telekom.ru
Thu Dec 11 23:11:31 UTC 2008


On Thu, Dec 11, 2008 at 04:36:47PM -0500, m. allan noah wrote:
> >> However, sanei_usb_init() is only
> >> called by backends in sane_init() and sane_get_devices(). A frontend
> >> will only call sane_init() once, so that is not a problem, and the
> >> sane standard says this about sane_get_devices():
> >>
> >> The returned list is guaranteed to remain unchanged and valid until
> >> (a) another call to this function is performed or (b) a call to
> >> sane_exit() is performed.
> >
> > This don't says calling sane_get_devices will or should break any
> > already opened device.
> 
> That is strongly implied. Why else would it bother to guarantee only
> half of the cycle?

Unfortunately it is not implied at all. What we read at SANE spec:

| http://www.sane-project.org/html/doc013.html
| Function sane_get_devices() can be called any time after sane_init()
| has been called.

But yes, probably most meaningful is to call it once before sane_open.

But even in scanimage -h it is called after sane_open, and while it is
still opened.


> >> However, you have a valid point that most backends only call
> >> sanei_usb_init() in sane_init(), and I think that should change.
> >
> > In backend I'm writing I call sanei_usb_init multiple times (in each
> > sane_get_devices) only if I don't have opened devices. I think that's ok.
> 
> Unfortunately, that is not enough. if a person has another brand of
> scanner on their machine, alongside yours, and they open the other
> scanner and then call sane_get_devices(), your backend won't know.
> Then you will blast the list with the other backend's open device in
> it.

You are right.




More information about the sane-devel mailing list