[flac-dev] Newbie question about those callbacks
Erik de Castro Lopo
mle+la at mega-nerd.com
Sat Feb 9 17:37:47 PST 2013
Johnny Rosenberg wrote:
> For instance the write_callback thing:
> client_data – can it be a pointer to just about anything?
I assume you mean:
https://www.xiph.org/flac/api/group__flac__stream__decoder.html#ga13
which defines the type:
typedef FLAC__StreamDecoderWriteStatus
(* FLAC__StreamDecoderWriteCallback)
(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame
, const FLAC__int32 *const buffer[], void *client_data)
Yes, client_data can point at anything. You the callee are responsible
to cast your pointer_to_anything to and from 'void*'
> For instance a pointer to a two-dimensional array?
Yes. They can even be NULL.
Whatever pointer you pass as the client_data parameter in the finction
FLAC__stream_decoder_init_stream () will be passed back to you in the
callbacks client_data.
> Are those FLAC-WAV and WAV-FLAC examples the only examples available?
There are examples in the examples/ directory of the FLAC source code
tarball. They are in Git here:
https://git.xiph.org/?p=flac.git;a=tree;f=examples/c;h=dbcb345dcd699ca3f1a1b1d334f5a48d45385558;hb=HEAD
> What would be the best approach to read a FLAC file to an array of
> some kind? Passing a pointer to the array as ”client_data”? I'd like
> to use a two-dimensional array, but it's a little tricky (for a
> newbie) to pass to functions as a pointer.
I agree, coding to the FLAC API is not something that is easy or obvious
for a newbie C programmer.
Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
More information about the flac-dev
mailing list