[sane-devel] sane_get_devices() is very slow
Derry Bryson
dbryson at techass.com
Thu Feb 13 20:58:43 GMT 2003
Henning Meier-Geinitz wrote:
>
> Hi,
>
> [CC to the list, I guess that was intended :-)]
>
> On Thu, Feb 13, 2003 at 11:18:46AM -0800, Derry Bryson wrote:
> [I wrote:]
> > > No, sorry. That's not how it works. It only works for TWAIN because
> > > the user is forced to manually install a driver for every single
> > > scanner and Windows users usally have only one scanner at a single
> > > computer. Think about what would happen if all the scanner drivers had
> > > been provided by Microsoft together with the operating system and
> > > installed by default. If the drivers didn't check for the existance of
> > > the devices, the TWAIN list would be endless.
> > >
> >
> > I see your point. I was only looking at the number of backends and not
> > really considering how many scanners really are supported.
> >
> > I will have to give this more thought. It doesn't seem like a good idea
> > to go through the detection process every time an app requests the device
> > list.
>
> Usually it happens only once during the runtime of the application
> even if the standard allows that the list changes during runtime.
>
> But keeping a fixed list doesn't work, as devices (especially USB) can
> be plugged in and out everytime. In an ideal world, you would plug-in
> any (supported) scanner and run the scan application without any other
> setup action. That works for most USB scanners nowerdays.
> And keep in mind that the device file/address of the device may change
> after replugging, so even if you have a list of device files, the
> scanner may have changed meanwhile.
>
I am thinking along the lines of keeping a list around, but allowing the
user the option to detect devices when selecting a source. This I can do
in my code without needing to change the sane API.
If you were to want to consider changing the API, I might suggest adding a
sane_list_devices() function with the same signature as sane_get_devices()
that would be implemented in most backends as a call to sane_get_devices(),
but in the dll and net backends would return the list of devices cached from the
last call to sane_get_devices(). The cached list would saved to a file when
the backend is unloaded and read when the backend is loaded.
Derry
More information about the sane-devel
mailing list