summaryrefslogtreecommitdiff
path: root/plugins/flac/flac.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-17 20:30:53 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-17 20:30:53 +0200
commitd5eeb44a9d05a1b8072fc090fe07d7a13a8bfb06 (patch)
tree07c6fd2ab4fe23e49c5c90a334dda203a367da29 /plugins/flac/flac.c
parent0aeffd99630b041515f330d25c287de378719cc4 (diff)
fix flac avg bitrate to work with cuesheets
Diffstat (limited to 'plugins/flac/flac.c')
-rw-r--r--plugins/flac/flac.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/plugins/flac/flac.c b/plugins/flac/flac.c
index a1f26f16..43b1b1c0 100644
--- a/plugins/flac/flac.c
+++ b/plugins/flac/flac.c
@@ -250,6 +250,23 @@ cflac_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
trace ("cflac_init not a flac stream\n");
return -1;
}
+
+ // bitrate
+ size_t fsize = deadbeef->fgetlength (info->file);
+ FLAC__uint64 position;
+ FLAC__bool res = FLAC__stream_decoder_get_decode_position (info->decoder, &position);
+ if (res) {
+ fsize -= position;
+ }
+ FLAC__uint64 flac_totalsamples = FLAC__stream_decoder_get_total_samples (info->decoder);
+ float sec = flac_totalsamples / _info->samplerate;
+ if (sec > 0) {
+ info->bitrate = fsize / sec * 8 / 1000;
+ }
+ else {
+ info->bitrate = -1;
+ }
+
info->buffer = malloc (BUFFERSIZE);
info->remaining = 0;
if (it->endsample > 0) {
@@ -273,20 +290,6 @@ cflac_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
return -1;
}
- size_t fsize = deadbeef->fgetlength (info->file);
- FLAC__uint64 position;
- FLAC__bool res = FLAC__stream_decoder_get_decode_position (info->decoder, &position);
- if (res) {
- fsize -= position;
- }
- FLAC__uint64 flac_totalsamples = FLAC__stream_decoder_get_total_samples (info->decoder);
- float sec = flac_totalsamples / _info->samplerate;
- if (sec > 0) {
- info->bitrate = fsize / sec * 8 / 1000;
- }
- else {
- info->bitrate = -1;
- }
return 0;
}