improve resolution stream-length-in-millisecond calculation
diff --git a/src/plugin_winamp2/in_flac.c b/src/plugin_winamp2/in_flac.c
index d6f1640..ed41dbb 100644
--- a/src/plugin_winamp2/in_flac.c
+++ b/src/plugin_winamp2/in_flac.c
@@ -307,7 +307,7 @@
filename = lastfn_;
if (length_in_msec)
{
- *length_in_msec = file_info_.length_in_msec;
+ *length_in_msec = (int)file_info_.length_in_msec;
length_in_msec = 0; /* force skip in following code */
}
}
@@ -327,7 +327,7 @@
}
if (length_in_msec)
- *length_in_msec = (int)(streaminfo.data.stream_info.total_samples*10 / (streaminfo.data.stream_info.sample_rate/100));
+ *length_in_msec = (int)((double)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5);
}
/*
diff --git a/src/plugin_winamp2/playback.c b/src/plugin_winamp2/playback.c
index ef510f7..9648c34 100644
--- a/src/plugin_winamp2/playback.c
+++ b/src/plugin_winamp2/playback.c
@@ -72,7 +72,7 @@
file_info->abort_flag = true;
return;
}
- file_info->length_in_msec = file_info->total_samples * 10 / (file_info->sample_rate / 100);
+ file_info->length_in_msec = (unsigned)((double)file_info->total_samples / (double)file_info->sample_rate * 1000.0 + 0.5);
}
else if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT)
{
diff --git a/src/plugin_xmms/plugin.c b/src/plugin_xmms/plugin.c
index c6020c5..62bdc24 100644
--- a/src/plugin_xmms/plugin.c
+++ b/src/plugin_xmms/plugin.c
@@ -440,7 +440,7 @@
*title = flac_format_song_title(filename);
}
if(length_in_msec)
- *length_in_msec = streaminfo.data.stream_info.total_samples * 10 / (streaminfo.data.stream_info.sample_rate / 100);
+ *length_in_msec = (unsigned)((double)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5);
}
/***********************************************************************
@@ -794,7 +794,7 @@
file_info->bits_per_sample = metadata->data.stream_info.bits_per_sample;
file_info->channels = metadata->data.stream_info.channels;
file_info->sample_rate = metadata->data.stream_info.sample_rate;
- file_info->length_in_msec = (FLAC__uint64)file_info->total_samples * 10 / (file_info->sample_rate / 100);
+ file_info->length_in_msec = (unsigned)((double)file_info->total_samples / (double)file_info->sample_rate * 1000.0 + 0.5);
}
else if(metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
double gain, peak;