improve resolution stream-length-in-millisecond calculation

This commit is contained in:
Josh Coalson
2005-01-26 03:19:29 +00:00
parent 08ccb1f132
commit d2e010e704
3 changed files with 5 additions and 5 deletions

View File

@@ -307,7 +307,7 @@ static void getfileinfo(char *filename, char *title, int *length_in_msec)
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 @@ static void getfileinfo(char *filename, char *title, int *length_in_msec)
}
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);
}
/*

View File

@@ -72,7 +72,7 @@ static void metadata_callback(const FLAC__FileDecoder *decoder, const FLAC__Stre
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)
{