[Flac] Application Metadata

Josh Coalson xflac at yahoo.com
Mon Aug 8 13:45:22 PDT 2005


--- Paul <elegant_dice at yahoo.com> wrote:
> Hi,
> 
> I'm sorry to say that I've found the libFLAC++ interface and 
> documentation pretty slim and baffling.

yes, libFLAC++ is just a thin wrapper around libFLAC.  if you
follow the api links down into the libFLAC equivalent, there is
much more info.  e.g. starting at

http://flac.sourceforge.net/api/group__flacpp__file__encoder.html

for the C++ FLAC::Encoder::File docs, follow the link into the
libFLAC file encoder module
(http://flac.sourceforge.net/api/group__flac__file__encoder.html)

hit the link for FLAC__file_encoder_set_metadata
(http://flac.sourceforge.net/api/group__flac__file__encoder.html#a21)
and follow the inheritance link to
FLAC__seekable_stream_encoder_set_metadata()
(http://flac.sourceforge.net/api/group__flac__seekable__stream__encoder.html#a25)
to FLAC__stream_encoder_set_metadata()
(http://flac.sourceforge.net/api/group__flac__stream__encoder.html#a23)

I don't really know any other way to do the docs without duplicating
a lot of info in several places.

> What I need to do is add some application-specific metadata to a FLAC
> file (i'm using the FLAC++ fileencoder).  It is currently just a
> string of characters, which doesn't need to be null-terminated.

that is the way if you are adding the metadata while encoding to
FLAC.  if you want to add metadata to an existing FLAC file you
should use one of the iterator interfaces, not the encoder.

> Based on some of the test code, I had assumed I would do something
> like:
> 
> FLAC::Metadata::Application header_flac;
> FLAC__byte header_flac_id[4] = { 1, 2, 3, 4 };
> header_flac.set_id(header_flac_id);
>
header_flac.set_data((FLAC__byte*)(header_str.begin()),header_str.size());
> 
> // set the metadata
> FLAC::Metadata::Prototype *metadata_sequence[] = { &header_flac };
>
enc.set_metadata(metadata_sequence,sizeof(metadata_sequence)/sizeof(metadata_sequence[0]));
> // and now i continue to init(), process_interleaved() and finish()
> 
> 
> 
> But that kept giving me segmentation faults.

that looks fine, can you send the backtrace?

> So I tried the following, 
> and it still gave me segmentation faults.
> 
> 
> 
> 
> FLAC__byte header_flac_id[4] = { 1, 2, 3, 4 };
> 
> FLAC__byte * header_byte = new FLAC__byte[header_str.size()];
> copy(header_str.begin(),header_str.end(),header_byte);
> 
> // set the metadata
> FLAC::Metadata::Application * header_flac = new
> FLAC::Metadata::Application;
> header_flac->set_id(header_flac_id);
> header_flac->set_data(header_byte,header_str.size());
> 
> FLAC::Metadata::Prototype **metadata_sequence = new 
> (FLAC::Metadata::Prototype*)[1];
> metadata_sequence[0] = header_flac;
> 
> cnc.set_metadata(metadata_sequence,1);
> 
> // and now i continue to init(), process_interleaved() and finish()

that looks fine too but shouldn't be necessary, as the first
version should work.

Josh


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Flac mailing list