[linux-audio-dev] re: less and seeking on piped input

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: [linux-audio-dev] re: less and seeking on piped input
From: David Slomin (dgslomin_AT_CS.Princeton.EDU)
Date: to elo    19 1999 - 22:31:25 EDT


Nicola> how does a pager like 'less' do? less can read infinitely large
Nicola> files from a pipe and go back and forth. Or am I wrong?

Erik> Interesting observation Nicola! On read from a pipe it may well be
Erik> possible to seek back an forth thru the whole file. Write however
Erik> is quite a different matter. Once I get pipes working I'll do some
Erik> experimentation.

I always assumed that it copied stdin into a temp file, or at least into
buffers in memory. This is fine for text (as with less), but audio data
is orders of magnitude larger. This could be problematic because both
methods (temp file or buffers so large that they cause paging) mean extra
disk access, the latency of which might well defeat the whole purpose.

BTW, Erik, getting pipes to work is really trivial if you already have
code that reads a file (sequentially, not random access). Just do an
fdopen on file descriptor zero, and you're done.

You can also test the limits of what pipes can do without modifying your
code at all by using named pipes (fifos). These are wonderful but often
overlooked "files" (in the manner that devices are "files") which you can
open for reading and writing at once by different apps. Take a look at
the mkfifo man page. I have no idea why they're not used more often.

I had a lot of fun playing with piping MIDI messages between little filter
apps in realtime (transpose, add parallel chords, etc). MIDI itself is
low enough bandwidth that I didn't have any latency problems whatsoever,
although I didn't rig up anything to time down to the microsecond. I can
send my code if you'd like, although it's nothing fancy.

Div.


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : pe maalis 10 2000 - 07:25:52 EST