aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/_flac_common.h
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-10 22:03:58 +0100
committerMax Kellermann <max@duempel.org>2009-11-10 22:03:58 +0100
commitc1a999c4927181d5b9621af7a7808266e17f64e2 (patch)
treec9268ba8554e9bc04a87d6977a209b91857b3e1e /src/decoder/_flac_common.h
parente51d9fc6a9902c2ef448abf8f1151964a441d788 (diff)
downloadmpd-c1a999c4927181d5b9621af7a7808266e17f64e2.tar.gz
mpd-c1a999c4927181d5b9621af7a7808266e17f64e2.tar.xz
mpd-c1a999c4927181d5b9621af7a7808266e17f64e2.zip
decoder/flac: don't use float to calculate song duration
Simple (up-rounding) integer division is good enough. We're casting the result back to an integer anyway.
Diffstat (limited to 'src/decoder/_flac_common.h')
-rw-r--r--src/decoder/_flac_common.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/decoder/_flac_common.h b/src/decoder/_flac_common.h
index fc240aa11..363f1ae8a 100644
--- a/src/decoder/_flac_common.h
+++ b/src/decoder/_flac_common.h
@@ -159,6 +159,13 @@ struct flac_data {
struct tag *tag;
};
+static inline unsigned
+flac_duration(const FLAC__StreamMetadata_StreamInfo *stream_info)
+{
+ return (stream_info->total_samples + stream_info->sample_rate - 1) /
+ stream_info->sample_rate;
+}
+
/* initializes a given FlacData struct */
void
flac_data_init(struct flac_data *data, struct decoder * decoder,