diff options
author | Max Kellermann <max@duempel.org> | 2009-11-11 19:25:15 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-11-11 19:25:15 +0100 |
commit | 7b13776f2dd2feeb4bd28e8cf023ec81474e4eaa (patch) | |
tree | e8d91ee2f20a4af43a2fce380f5a5c744f0b61d8 /src/decoder/flac_plugin.c | |
parent | f937ec9a7c6b2439cda68c9cfdaa603258f8a0d4 (diff) | |
download | mpd-7b13776f2dd2feeb4bd28e8cf023ec81474e4eaa.tar.gz mpd-7b13776f2dd2feeb4bd28e8cf023ec81474e4eaa.tar.xz mpd-7b13776f2dd2feeb4bd28e8cf023ec81474e4eaa.zip |
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.
Diffstat (limited to 'src/decoder/flac_plugin.c')
-rw-r--r-- | src/decoder/flac_plugin.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c index 98bcd64d3..7a4f11451 100644 --- a/src/decoder/flac_plugin.c +++ b/src/decoder/flac_plugin.c @@ -400,6 +400,11 @@ flac_decoder_initialize(struct flac_data *data, FLAC__StreamDecoder *sd, return false; } + if (!data->have_stream_info) { + g_warning("no STREAMINFO packet found"); + return false; + } + if (!audio_format_valid(&data->audio_format)) { g_warning("Invalid audio format: %u:%u:%u\n", data->audio_format.sample_rate, @@ -408,12 +413,13 @@ flac_decoder_initialize(struct flac_data *data, FLAC__StreamDecoder *sd, return false; } - if (duration != 0) - data->total_time = (float)duration / - (float)data->audio_format.sample_rate; + if (duration == 0) + duration = data->stream_info.total_samples; decoder_initialized(data->decoder, &data->audio_format, - seekable, data->total_time); + seekable, + (float)duration / + (float)data->audio_format.sample_rate); return true; } |