Re: SANE_Device issue
Perry Hutchison via sane-devel <[email protected]> Thu, 29 May 2025 01:42:06 -0700
| Newsgroups | gmane.comp.graphics.scanning.sane.devel |
|---|---|
| Message-ID | <68381dde.nmmsx13Vi/sdQRXh%[email protected]> |
Ralph Little <[email protected]> wrote: > Hi, > > On Wed, May 28, 2025 at 9:32???PM Ben Olden-Cooligan <[email protected]> > wrote: > > > It's very hacky but I get around this in NAPS2 by creating a temporary > > config dir with only the one backend for the specified device. > > It certainly sounds a bit janky, but I didn't think of this. It might > be the only option to get the information without an API change. I haven't looked into the code, but just thinking about how something like this "has to" work I would expect sane_get_devices() to do, roughly: for b in backends { ... b->get_devices(); ... } IOW each backend has to already implement a specified interface that probes for devices supported by that backend and (somehow) loads the results into SANE_Device. Is there some reason why a program like xsane, when told which backend to use, cannot just call that one backend's get_devices() function directly -- at the same point where it would otherwise call sane_get_devices()? This is effectively what Ben's solution accomplishes by limiting "backends" to the one of interest, but without having to create and populate a scratch directory somewhere. > The other option actually is just to replace that descriptive > information with something nondescript like "None" or "Unknown". > Doesn't look all that great but it would avoid the delay on startup. > > Cheers, > Ralph > > > https://github.com/cyanfish/naps2/blob/master/NAPS2.Sdk/Scan/Internal/Sane/SaneScanDriver.cs#L324 > > > > Certainly it would be nice if there was an API for this but there doesn't > > seem to be. > > > > On Wed, May 28, 2025, 21:24 Ralph Little <[email protected]> wrote: > > > >> Hi Devs, > >> I'm looking at an issue that affects xsane that I have had a number > >> of complaints about. > >> > >> When xsane starts, it calls sane_get_devices() regardless of whether > >> or not a specific device was specified by the user. The main issue > >> is the long delay before xsane starts up while device polling is > >> happening, which *can* be annoying long. > >> > >> On the face of it, this seems pointless if we already know which > >> device the user wants to use. However, in various places, xsane > >> uses the descriptive information for that device that we get in the > >> SANE_Device structure which can only be got from sane_get_devices() > >> This seems like a gaping hole in the protocol that the information > >> about a specific device cannot be determined without searching for > >> all devices. > >> > >> Does anyone have any ideas how we might get around this without > >> breaking backwards compatibility in the SANE API and have > >> I missed some official method whereby this information might be > >> obtained? > >> > >> Cheers, > >> Ralph