[Flac] C++ Set_Metadata Problem

Padfield, Nicholas Nicholas.Padfield at dsto.defence.gov.au
Thu May 11 00:17:34 PDT 2006

I refer to a problem that appeared on the flac list last August that was
either solved off-list or abandoned.

The problem is with using the C++ encoder classes, particularly the
function. JC said that the developers version of how to add a simple
metadata block looked right, but it did not work for him. I have tried
the same and also can not get it to work, but with a different error.

To recap... (I've left out is-valid checks in the listing for brevity)


// Create an application block
FLAC::Metadata::Application header_flac;
FLAC__byte header_flac_id[4] = { 1, 2, 3, 4 };

// Add the block to a metadata array and pass the array to the encoder
FLAC::Metadata::Prototype *meta[] = { &header_flac };
set_metadata(meta, sizeof(meta) / sizeof(meta[0]));
// Ready to go - initialise the encoder
if(init() != ::FLAC__FILE_ENCODER_OK)
	return die("Init failed");


And this returns the following ...

FAILED, Init failed, state = 2
      seekable stream encoder state = 1
      stream encoder state = 16 (FLAC__STREAM_ENCODER_INVALID_METADATA)

I have invalid metadata! I have tried the same with VorbisComment and
Padding objects, with similar results.

Do I need to set the is_last flag for the last block in my array or does
the decoder object do that?

Any ideas about what is wrong?


More information about the Flac mailing list