[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.
(http://lists.xiph.org/pipermail/flac/2005-August/000468.html)

The problem is with using the C++ encoder classes, particularly the
FLAC::Encoder::File:set_metadata
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 };
header_flac.set_id(header_flac_id);
header_flac.set_data((FLAC__byte*)(header_str.begin()),header_str.size()
);

// Add the block to a metadata array and pass the array to the encoder
object
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
(FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR)
      seekable stream encoder state = 1
(FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR)
      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?

Thanks
Paddy


More information about the Flac mailing list