aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/oggflac_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-11 19:25:15 +0100
committerMax Kellermann <max@duempel.org>2009-11-11 19:25:15 +0100
commit7b13776f2dd2feeb4bd28e8cf023ec81474e4eaa (patch)
treee8d91ee2f20a4af43a2fce380f5a5c744f0b61d8 /src/decoder/oggflac_plugin.c
parentf937ec9a7c6b2439cda68c9cfdaa603258f8a0d4 (diff)
downloadmpd-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/oggflac_plugin.c')
-rw-r--r--src/decoder/oggflac_plugin.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/decoder/oggflac_plugin.c b/src/decoder/oggflac_plugin.c
index 3f8d640f3..ffd622600 100644
--- a/src/decoder/oggflac_plugin.c
+++ b/src/decoder/oggflac_plugin.c
@@ -237,6 +237,12 @@ full_decoder_init_and_read_metadata(struct flac_data *data,
goto fail;
}
+ if (!data->have_stream_info) {
+ OggFLAC__seekable_stream_decoder_delete(decoder);
+ g_warning("no STREAMINFO packet found");
+ return NULL;
+ }
+
return decoder;
fail:
@@ -316,7 +322,9 @@ oggflac_decode(struct decoder * mpd_decoder, struct input_stream *input_stream)
}
decoder_initialized(mpd_decoder, &data.audio_format,
- input_stream->seekable, data.total_time);
+ input_stream->seekable,
+ (float)data.stream_info.total_samples /
+ (float)data.audio_format.sample_rate);
while (true) {
OggFLAC__seekable_stream_decoder_process_single(decoder);