kopia lustrzana https://gitlab.com/sane-project/website
94 wiersze
4.1 KiB
HTML
94 wiersze
4.1 KiB
HTML
<!-- received="Thu May 29 07:18:45 1997 MST" -->
|
|
<!-- sent="Thu, 29 May 1997 09:38:16 -0400" -->
|
|
<!-- name="Michael K. Johnson" -->
|
|
<!-- email="johnsonm@redhat.com" -->
|
|
<!-- subject="Re: image buffering" -->
|
|
<!-- id="199705291338.JAA12074@nigel.redhat.com" -->
|
|
<!-- inreplyto="image buffering" -->
|
|
<title>sane-devel: Re: image buffering</title>
|
|
<h1>Re: image buffering</h1>
|
|
<b>Michael K. Johnson</b> (<a href="mailto:johnsonm@redhat.com"><i>johnsonm@redhat.com</i></a>)<br>
|
|
<i>Thu, 29 May 1997 09:38:16 -0400</i>
|
|
<p>
|
|
<ul>
|
|
<li> <b>Messages sorted by:</b> <a href="date.html#38">[ date ]</a><a href="index.html#38">[ thread ]</a><a href="subject.html#38">[ subject ]</a><a href="author.html#38">[ author ]</a>
|
|
<!-- next="start" -->
|
|
<li> <b>Next message:</b> <a href="0039.html">becka@sunserver1.rz.uni-duesseldorf.de: "Re: image buffering"</a>
|
|
<li> <b>Previous message:</b> <a href="0037.html">David Mosberger-Tang: "Re: Question regarding known support: HP1150C Officejet PPA scanner"</a>
|
|
<li> <b>Maybe in reply to:</b> <a href="0029.html">Mathias Weigt: "image buffering"</a>
|
|
<!-- nextthread="start" -->
|
|
<li> <b>Next in thread:</b> <a href="0045.html">Michael K. Johnson: "Re: image buffering"</a>
|
|
<!-- reply="end" -->
|
|
</ul>
|
|
<!-- body="start" -->
|
|
David Mosberger-Tang writes:<br>
|
|
<i>>I don't see how to avoid the 2*imagesize worse-case with pipes. Since</i><br>
|
|
<i>>we don't have any problems in the other case, the question is how</i><br>
|
|
<i>>important do we think this case is. To me it seems it would be quite</i><br>
|
|
<i>>reasonable to say "look, if you use pipes, be prepared that you'll</i><br>
|
|
<i>>need more temp space than if you use a regular file".</i><br>
|
|
<p>
|
|
Yep. That is, in fact, how I decide what to do with three-pass scanners<br>
|
|
in the UMAX driver -- I try to mmap the output, and if it doesn't work,<br>
|
|
I malloc an area and write the whole thing out afterwards. The striping<br>
|
|
code is exactly the same, because I use the same variable to hold the<br>
|
|
malloced area as the mmaped area.<br>
|
|
<p>
|
|
<i>>Seriously though: I now think that using a temporary file is not such</i><br>
|
|
<i>>a bad idea. I think pipes could be supported easily as well: if a</i><br>
|
|
<i>>dummy lseek() fails, then a tmpfile(3) could be used as a temporary</i><br>
|
|
<i>>buffer.</i><br>
|
|
<p>
|
|
Like I say, that's not even necessary. Just mmap it and see if it<br>
|
|
fails. Here's sample code munged from the UMAX driver:<br>
|
|
<p>
|
|
write_after = 0;<br>
|
|
lseek(ofd, mmap_size, SEEK_SET);<br>
|
|
ftruncate(ofd, mmap_size);<br>
|
|
arena = mmap(NULL, mmap_size, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED,<br>
|
|
ofd, 0);<br>
|
|
if ((! arena) || arena == -1) {<br>
|
|
if (verbose) {<br>
|
|
fprintf(stderr, "mmap failed, errno=%d: %s\n", errno, strerror(errno));<br>
|
|
}<br>
|
|
arena = malloc(mmap_size);<br>
|
|
write_after = 1;<br>
|
|
}<br>
|
|
<p>
|
|
....<br>
|
|
<p>
|
|
/* note that image_size may be different than page-aligned size */<br>
|
|
if (write_after) {<br>
|
|
write(ofd, arena, image_size);<br>
|
|
free(arena);<br>
|
|
} else {<br>
|
|
munmap(us->arena, mmap_size);<br>
|
|
/* will always smaller, so no need to lseek first */<br>
|
|
ftruncate(ofd, image_size);<br>
|
|
}<br>
|
|
<p>
|
|
<p>
|
|
With that kind of code, the striping code shouldn't need any changes at all.<br>
|
|
<p>
|
|
michaelkjohnson<br>
|
|
<p>
|
|
"Ever wonder why the SAME PEOPLE make up ALL the conspiracy theories?"<br>
|
|
<p>
|
|
<p>
|
|
<pre>
|
|
--
|
|
Source code, list archive, and docs: <a href="http://www.azstarnet.com/~axplinux/sane/">http://www.azstarnet.com/~axplinux/sane/</a>
|
|
To unsubscribe: mail -s unsubscribe <a href="mailto:sane-devel-request@listserv.azstarnet.com">sane-devel-request@listserv.azstarnet.com</a>
|
|
</pre>
|
|
<!-- body="end" -->
|
|
<p>
|
|
<ul>
|
|
<!-- next="start" -->
|
|
<li> <b>Next message:</b> <a href="0039.html">becka@sunserver1.rz.uni-duesseldorf.de: "Re: image buffering"</a>
|
|
<li> <b>Previous message:</b> <a href="0037.html">David Mosberger-Tang: "Re: Question regarding known support: HP1150C Officejet PPA scanner"</a>
|
|
<li> <b>Maybe in reply to:</b> <a href="0029.html">Mathias Weigt: "image buffering"</a>
|
|
<!-- nextthread="start" -->
|
|
<li> <b>Next in thread:</b> <a href="0045.html">Michael K. Johnson: "Re: image buffering"</a>
|
|
<!-- reply="end" -->
|
|
</ul>
|