Fixed overflow with long audio files

This commit is contained in:
Daniel Wolf 2016-06-24 21:51:17 +02:00
parent c6c31a831c
commit faa3f2b4bb
2 changed files with 4 additions and 4 deletions

View File

@ -2,10 +2,10 @@
#include <stdexcept>
AudioStreamSegment::AudioStreamSegment(std::unique_ptr<AudioStream> audioStream, const TimeRange& range) :
audioStream(std::move(audioStream))
audioStream(std::move(audioStream)),
sampleOffset(static_cast<int64_t>(range.getStart().count()) * this->audioStream->getSampleRate() / 100),
sampleCount(static_cast<int64_t>(range.getLength().count()) * this->audioStream->getSampleRate() / 100)
{
sampleOffset = range.getStart().count() * this->audioStream->getSampleRate() / 100;
sampleCount = range.getLength().count() * this->audioStream->getSampleRate() / 100;
seek(0);
if (sampleOffset < 0 || sampleOffset + sampleCount > this->audioStream->getSampleCount()) {

View File

@ -15,7 +15,7 @@ public:
private:
std::unique_ptr<AudioStream> audioStream;
int64_t sampleOffset, sampleCount;
const int64_t sampleOffset, sampleCount;
};
std::unique_ptr<AudioStream> createSegment(std::unique_ptr<AudioStream> audioStream, const TimeRange& range);