[Flac] how to include FLAC in a CoreAudio wave player

Josh Coalson xflac at yahoo.com
Mon Nov 14 14:09:43 PST 2005


--- Matthew DeNardo <matt_denardo at yahoo.com> wrote:
> There is a CoreAudio wave player written in C++ to
> which I would like to add FLAC playback support. I
> have looked through the libFLAC++ API and think I have
> an idea of what files/functions to use, but am not
> really sure how to go about implementing them.
> 
> I think I want to use the file decoder class so I can
> just pass it the name of the FLAC file I want to play
> and use new, init, set and process_until_end_of_file
> functions to do what I need. I have an idea of how
> this will work in my head, but am having trouble
> translating it to code. I also am having trouble
> figuring out how this will hook back in to the
> existing application.

I don't know how deep you've gotten into the API docs,
but since the C++ library is mostly a wrapper around
the C one, most of the documentation is for at the C
level, but can be trivially applied to the C++ class
since the calls have similar names/signatures.  the
C++ just makes the C callbacks into virtual methods
mostly.

so I would say first look a
http://flac.sourceforge.net/api/group__flac__file__decoder.html#_details
and dive down into the individual functions for details (maybe you have
already done this).

there are also examples in the unit tests of how to
create a class derived from the file decoder; see
src/test_libFLAC++/decoders.c in the source distribution
and search for FileDecoder.  most of the code in there
is thousands of lines of tests but the actual class
setup is pretty simple.

it's hard to know how to help with hooking it into
the app without knowing the app.  the libFLAC decoder
is pull-based, i.e. one you process_until_end_of_file(),
control is only going to come back to you during
callbacks (mostly write) or end of stream.  if the
app is push based you will have to do frames at a time
into a fifo (see the source for the winamp or xmms
plugins), or use multiple threads.

Josh



		
__________________________________ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs


More information about the Flac mailing list