Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Created Issue: Mp3FileReader.Length property calculated as int instead of as long [16356]

$
0
0
I've got a very big mp3 recording (a 4 hours recording) that I need to process. When openned with Mp3FileReader I get a Length of -1 755 258 880. At first I thought the problem was that the file was to big a file, bigger than a long Length!!!, but then I took a look at Lenght implementation:

public override long Length
{
get
{
return this.totalSamples * this.bytesPerSample;
}
}

The problem here is that both totalSamples and bytesPerSample are ints, and the result of multiplying two ints is another int, so, fr a file being bigger in bytes than int.MaxValue (as is mine), the Length property won't be correct even if the file is smaller ib bytes than long.MaxValue.
I've fixed Length implementation as follows, but it would be nice to check all similar scenarios.

public override long Length
{
get
{
return ((long)this.totalSamples) * this.bytesPerSample;
}
}

Thanks a lot,

Amanda

Viewing all articles
Browse latest Browse all 738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>