[sane-devel] sane_get_devices and sanei_usb_init

ABC abc at telekom.ru
Thu Dec 11 21:24:45 UTC 2008


On Thu, Dec 11, 2008 at 04:06:24PM -0500, m. allan noah wrote:
> On Mon, Dec 1, 2008 at 10:23 PM, ABC <abc at telekom.ru> wrote:
> > First of all sanei_usb_init() is not designed to be used for rescanning
> > after any other sanei_usb functions is called. It is just initialization
> > and rescanning ability is not documented side effect. As stated in
> > documentation: "Call this before any other sanei_usb function". So don't
> > call it after. (This doesn't state it should be called just once, so we
> > could rescan before first device is opened.)
> 
> sanei_usb_init() will blast the existing info, and assign all new
> device indexes to whatever it finds.

Exactly how it works now.

> 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.

> So, if you call sane_get_devices() twice, you cannot complain that any
> devices you have open don't work anymore.

I can complain about that, since list of name/vendor/model/type of all
available devices is logically not related to any already opened
device.

> 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.




More information about the sane-devel mailing list