View Single Post
  #23 (permalink)  
Old May 23rd 15, 09:57 AM posted to uk.comp.os.linux,uk.rec.audio
Jim Lesurf[_2_]
external usenet poster
 
Posts: 2,668
Default Flac and Audio CD Health Checks

In article , Martin Gregorie
wrote:
On Fri, 22 May 2015 14:57:59 +0100, Jim Lesurf wrote:



AIUI tmpfile() will give me a file 'handle' (FILE*) but no name. How
would I use that as part of the command string for flac?

I did find a man page for tmpname() but having given the details it
says to "Never use it!".

There are a couple of other ways to do this:


1) use a script to run flac and pipe its output directly into your
program like this:


flac inputfile | yourprogram



Your program will use a loop to copy bytes from flac's stdout stream
into a temporary file created using something like:


#include stdio.h ... FILE flacfile = tmpfile();


This is a nameless file which will vanish when you close it or exit
from the program. You'd fill it by reading stdin and after that you
can reposition to its start by calling rewind() and read through the
file as many times as you want.


That looks like worth trying. However I'm not clear on details so would
like to check some points:

1) When calling flac using system() can I just replace the flac command's
final switch/setting

-o outputfile

with something like

inputfile | RunImage

(The program by default is being run with a process name 'RunImage',
although I can of course change that. Or can I get and use a process
number?)

Will the output be readable as a stream of bytes/chars I can use to fill a
buffer?

Will it pipe out until system() is done, so will be readable afterwards?

And is it the case that simply using

FILE flacfile = tmpfile();

will mean it will read as stdin when I use flacfile as the 'handle'?

Can I also use fread() of the correctly sized block rather than read as a
series of bytes/chars/etc?

Is there an example I can see of this? I'll do a websearch, but as yet
don't know anything about it!

Thanks again, this is interesting. I've know of the existence and general
pupose of pipes, but no idea how to use them.

Jim

--
Please use the address on the audiomisc page if you wish to email me.
Electronics http://www.st-and.ac.uk/~www_pa/Scot...o/electron.htm
Armstrong Audio http://www.audiomisc.co.uk/Armstrong/armstrong.html
Audio Misc http://www.audiomisc.co.uk/index.html