M src/MiniMP3ReadStream.cpp +6 -1
@@ 90,7 90,12 @@ MiniMP3ReadStream::MiniMP3ReadStream(std
m_channelCount = m_d->dec.info.channels;
m_sampleRate = m_d->dec.info.hz;
- m_estimatedFrameCount = m_d->dec.samples / m_channelCount;
+
+ if (m_channelCount > 0) {
+ m_estimatedFrameCount = m_d->dec.samples / m_channelCount;
+ } else {
+ m_estimatedFrameCount = 0;
+ }
}
size_t
M src/OpusReadStream.cpp +3 -1
@@ 112,8 112,10 @@ OpusReadStream::OpusReadStream(std::stri
m_sampleRate = 48000; // libopusfile always decodes to 48kHz! I like that
ogg_int64_t total = op_pcm_total(m_d->file, -1);
- if (total > 0) {
+ if (total > 0 && m_channelCount > 0) {
m_estimatedFrameCount = total / m_channelCount;
+ } else {
+ m_estimatedFrameCount = 0;
}
}
M src/SimpleWavFileReadStream.cpp +5 -1
@@ 143,7 143,11 @@ SimpleWavFileReadStream::readHeader()
}
m_dataChunkSize = readExpectedChunkSize("data");
- m_estimatedFrameCount = m_dataChunkSize / bytesPerFrame;
+ if (bytesPerFrame > 0) {
+ m_estimatedFrameCount = m_dataChunkSize / bytesPerFrame;
+ } else {
+ m_estimatedFrameCount = 0;
+ }
m_dataReadOffset = 0;
}