From 7b13776f2dd2feeb4bd28e8cf023ec81474e4eaa Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 11 Nov 2009 19:25:15 +0100 Subject: decoder/flac: store the whole stream info object, not duration We don't want to work with floating point values if possible. Get the integer number of frames from the FLAC__StreamMetadata_StreamInfo object, and convert it into a float duration on demand. This patch adds a check if the STREAMINFO packet has been received yet. --- src/decoder/_flac_common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/decoder/_flac_common.c') diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c index 812ca6dae..fbeab43a7 100644 --- a/src/decoder/_flac_common.c +++ b/src/decoder/_flac_common.c @@ -35,6 +35,7 @@ flac_data_init(struct flac_data *data, struct decoder * decoder, { pcm_buffer_init(&data->buffer); + data->have_stream_info = false; data->next_frame = 0; data->time = 0; @@ -65,9 +66,11 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block, switch (block->type) { case FLAC__METADATA_TYPE_STREAMINFO: + data->stream_info = block->data.stream_info; + data->have_stream_info = true; + audio_format_init(&data->audio_format, si->sample_rate, si->bits_per_sample, si->channels); - data->total_time = ((float)si->total_samples) / (si->sample_rate); break; case FLAC__METADATA_TYPE_VORBIS_COMMENT: if (data->replay_gain_info) -- cgit v1.2.3