Commit f2cc2707 authored by Josh Coalson's avatar Josh Coalson
Browse files

update to match new way of passing metadata to stream encoder

parent 134a4e90
......@@ -85,7 +85,7 @@ FLAC__bool file_utils__remove_file(const char *filename)
return file_utils__change_stats(filename, /*read_only=*/false) && 0 == unlink(filename);
}
FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned length, const FLAC__StreamMetaData *streaminfo, int padding_length)
FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned length, const FLAC__StreamMetaData *streaminfo, FLAC__StreamMetaData **metadata, unsigned num_metadata)
{
FLAC__int32 samples[1024];
FLAC__StreamEncoder *encoder;
......@@ -95,7 +95,7 @@ FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned l
FLAC__ASSERT(0 != output_filename);
FLAC__ASSERT(0 != streaminfo);
FLAC__ASSERT(streaminfo->type == FLAC__METADATA_TYPE_STREAMINFO);
FLAC__ASSERT((streaminfo->is_last && padding_length < 0) || (!streaminfo->is_last && padding_length >= 0));
FLAC__ASSERT((streaminfo->is_last && num_metadata == 0) || (!streaminfo->is_last && num_metadata > 0));
if(0 == (encoder_client_data.file = fopen(output_filename, "wb")))
return false;
......@@ -122,9 +122,7 @@ FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned l
FLAC__stream_encoder_set_max_residual_partition_order(encoder, 0);
FLAC__stream_encoder_set_rice_parameter_search_dist(encoder, 0);
FLAC__stream_encoder_set_total_samples_estimate(encoder, streaminfo->data.stream_info.total_samples);
FLAC__stream_encoder_set_seek_table(encoder, 0);
FLAC__stream_encoder_set_padding(encoder, padding_length);
FLAC__stream_encoder_set_last_metadata_is_last(encoder, true);
FLAC__stream_encoder_set_metadata(encoder, metadata, num_metadata);
FLAC__stream_encoder_set_write_callback(encoder, encoder_write_callback_);
FLAC__stream_encoder_set_metadata_callback(encoder, encoder_metadata_callback_);
FLAC__stream_encoder_set_client_data(encoder, &encoder_client_data);
......
......@@ -22,4 +22,4 @@ FLAC__bool file_utils__change_stats(const char *filename, FLAC__bool read_only);
FLAC__bool file_utils__remove_file(const char *filename);
FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned length, const FLAC__StreamMetaData *streaminfo, int padding_length);
FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned length, const FLAC__StreamMetaData *streaminfo, FLAC__StreamMetaData **metadata, unsigned num_metadata);
......@@ -264,6 +264,7 @@ static void decoder_metadata_callback_compare_(const FLAC__FileDecoder *decoder,
static FLAC__bool generate_file_()
{
FLAC__StreamMetaData streaminfo, padding;
FLAC__StreamMetaData *metadata[1];
printf("generating FLAC file for test\n");
......@@ -287,10 +288,12 @@ static FLAC__bool generate_file_()
padding.type = FLAC__METADATA_TYPE_PADDING;
padding.length = 1234;
metadata[0] = &padding;
if(!insert_to_our_metadata_(&streaminfo, 0, /*copy=*/true) || !insert_to_our_metadata_(&padding, 1, /*copy=*/true))
return die_("priming our metadata");
if(!file_utils__generate_flacfile(flacfile_, 512 * 1024, &streaminfo, padding.length))
if(!file_utils__generate_flacfile(flacfile_, 512 * 1024, &streaminfo, metadata, 1))
return die_("creating the encoded file");
return true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment