Mercurial > hg > svcore
diff data/fileio/MP3FileReader.cpp @ 375:f1ff248a793e
* Attempt to fix crash caused by race condition on threaded file decode
author | Chris Cannam |
---|---|
date | Thu, 07 Feb 2008 12:35:43 +0000 |
parents | b92513201610 |
children | e6d11871e4c9 |
line wrap: on
line diff
--- a/data/fileio/MP3FileReader.cpp Wed Feb 06 17:40:53 2008 +0000 +++ b/data/fileio/MP3FileReader.cpp Thu Feb 07 12:35:43 2008 +0000 @@ -135,7 +135,7 @@ m_decodeThread = new DecodeThread(this); m_decodeThread->start(); - while (m_channelCount == 0 && !m_done) { + while ((m_channelCount == 0 || m_fileRate == 0) && !m_done) { usleep(10); } } @@ -358,7 +358,8 @@ double bitrate = m_bitrateNum / m_bitrateDenom; double duration = double(m_fileSize * 8) / bitrate; double elapsed = double(m_frameCount) / m_sampleRate; - double percent = ((elapsed * 100.0) / duration); + double percent = 100; + if (duration > 0.0) percent = ((elapsed * 100.0) / duration); int p = int(percent); if (p < 1) p = 1; if (p > 99) p = 99;