OK, this is driving me nuts!
This is the 3rd thread in my series about trying to get gapless audio recording working from the command line...
I'm having troubles with my FIFO buffer...
The Concept: Use arecord to send the raw audio input to a fifo buffer, and encode that raw data using oggenc. In order to split the output files, oggenc restarts periodically with a new filename. While it is restarting, the FIFO buffer is filling with the audio to be encoded once oggenc is running again. Ergo, not a millisecond of audio is missed.
There are 2 Problems with this.
1) arecord starts before oggenc. Therefore when oggenc reads the fifo, it just takes what's there, encodes it and says done. It doesn't keep going and going like if you piped arecord directly to oggenc. If oggenc is started before arecord, then it seem to work fine, however this isn't an option since oggenc has to restart regularly to change filenames, and arecord can not be stopped (otherwise we'll miss audio)
2) The fifo doesn't get emptied when it's read from. Example:
Code:
$ mkfifo /tmp/audio
$ ls -lh /tmp/audio
-rw-r--r-- 1 fukawi2 fukawi2 0 2008-12-12 15:08 /tmp/audio
$ arecord --format cd --file-type raw /tmp/audio &
$ cat /tmp/audio > /tmp/empty_the_damn_fifo
$ ls -lh /tmp/
-rw-r--r-- 1 fukawi2 fukawi2 30M 2008-12-12 15:08 /tmp/audio
-rw-r--r-- 1 fukawi2 fukawi2 29M 2008-12-12 15:09 /tmp/empty_the_damn_fifo
1) Create the fifo
2) Show that it's there and empty
3) Start arecord in the background
4) cat the fifo to a normal file. This should empty the fifo back to 0 bytes.
5) ls shows the nromal file we cat'ed to is 29M, and the fifo has not emptied and grown another 1M