>>>>> Andreas Beck writes:
>> Why not write to a single file (every third byte, for example),
>> and on each other pass, read a bufferful from the file, add in the
>> bytes from the scanner, and write the bufferful back to the file.
AB> This is a feasible solution. The buffering problem only comes up,
AB> if the frontend doesn't save to file (which it could do in-situ
AB> for simple formats exactly the way you described).
AB> The problem arises, if you want to pipe the output to another
AB> program. In this case you have to do something like this :
AB> scan-data --> buffer --> pipe
Ahh, yes. Okay... my fault, I forgot the SANE specs there for a
moment.
My lack of foresight is my enemy. I forgot we weren't just talking
about (x)scanimage.
>> Heck, I'll even help with implementation if that's the extra push
>> that's needed to convince any skeptics. :)
AB> Yeah - do it. Make it configureable so you can do malloc(),mmap()
AB> and normal file-io.
AB> Ah - and try to put it in a seperate source file, as more than
AB> one backend might want to use it.
That would be a good thing. The default method could be calculated by
the library, and then overridden by the application, if necessary.
Sane defaults, to me, would be trying to malloc the whole thing, then
if that fails, mmapping, and if that fails, writing to a temp file.
This would be motivated by the fact that buffering on disk is a
performance penalty that should be avoided if possible. If we cannot
guess the behaviour of other programs in the pipe, we might as well be
greedy.
Perhaps the application (such as xscanimage) could specify the
location of the eventual output file. This would change the strategy
to hit the disk (in a specific spot) as soon as possible.
Thoughts?
-- Gord Matzigkeit | Proudly running pieces of the GNU operating system. gord@m-tech.ab.ca | Jacques Cousteau loved programming in assembler.
-- Source code, list archive, and docs: http://www.azstarnet.com/~axplinux/sane/ To unsubscribe: mail -s unsubscribe sane-devel-request@listserv.azstarnet.com