aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/flac_plugin.c
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_plugin.c
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_plugin.c')
-rw-r--r--src/decoder/flac_plugin.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c
index e2620c676..1694f71fc 100644
--- a/src/decoder/flac_plugin.c
+++ b/src/decoder/flac_plugin.c
@@ -272,8 +272,7 @@ flac_tag_load(const char *file, const char *char_tnum)
flac_vorbis_comments_to_tag(tag, char_tnum,
&block->data.vorbis_comment);
} else if (block->type == FLAC__METADATA_TYPE_STREAMINFO) {
- tag->time = ((float)block->data.stream_info.total_samples) /
- block->data.stream_info.sample_rate + 0.5;
+ tag->time = flac_duration(&block->data.stream_info);
}
FLAC__metadata_object_delete(block);
} while (FLAC__metadata_simple_iterator_next(it));
@@ -853,9 +852,7 @@ oggflac_tag_dup(const char *file)
flac_vorbis_comments_to_tag(ret, NULL,
&block->data.vorbis_comment);
} else if (block->type == FLAC__METADATA_TYPE_STREAMINFO) {
- ret->time = ((float)block->data.stream_info.
- total_samples) /
- block->data.stream_info.sample_rate + 0.5;
+ ret->time = flac_duration(&block->data.stream_info);
}
} while (FLAC__metadata_iterator_next(it));
FLAC__metadata_iterator_delete(it);