projects.bag

News

Download

Development

Also, think about contributing (contact me for CVS login) to CVS tree (which we use for develop).

README

File from bag distribution: (it may not be current!)

bag is used to buffer data.

We use it to backup stuff on DAT. You shouldn't. It's still beta :-) It could also be used to buffer audio data before playing...

Read INSTALL file for compilation and installation instructions.

History: Why did we took it from timidity package and did things to it ? Well, it was just a quick hack to make DAT drive work faster, when backuping over network. So we added few switches in to make it work nicely and few other which sounded like neat ideas. It was just a quick hack to bag.c, no docs, no makefile, no anything.

And then, much later, we needed something to test CVS installation, so we took it, added some docs, added autoconf support while learning it, added RPM .spec file while learning it, and learning CVS features along the way.

So, here it is. We would appreciate all ideas, patches etc.

ObDisclaimer about usability, reliability and fitness for any purpose: WE DISCLAIM!!!

Example of usage:

    (a) backup to DAT

    > tar cfvp - / | bag -v -v -w 4096 -m0 -b10M -t9M -o /dev/nrmt0h

    I'm using very verbose mode to get nice statistics output, 10Mb of buffer with threshold of 9Mb and 0 seconds wait. Output is on nrmt0h, which is DAT. My tar is really a network pipe in real-world, and network is slower than DAT, so bag prevents constant seeks on DAT.

    (b) playing music

    > l3dec -sto song.mp3 | bag -b1m -t512k | aplay -m

    This one takes raw output of l3dec MP3 decoder, buffers it (1Mb buffer, 512Kb threshold), and plays it out (aplay -m is from ALSA sound project). Net effect is that if l3dec is temporary slowed down or stopped (like waiting for CD to spin-up, or big load average, or disk thrashing peak), audio will continue to play without pops and cracks.

Links

If bag doesn't fit your need, maybe cstream will. It's more throughput limiting kind of tool, but...
On the other hand, there is also a buffer by Lee McLoughlin which does exactly same job as bag, but using shared memory and locks. There is also m(easuring)buffer by Thomas Maier-Komor which is a replacement for buffer with additional functionality. Take a look at Buffer Copy which copies data efficiently from its stdin to its stdout. It works by spawning two subprocesses, one for reading, and one for writing.