comparison 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
comparison
equal deleted inserted replaced
374:7cc6b7b0d819 375:f1ff248a793e
133 } else { 133 } else {
134 134
135 m_decodeThread = new DecodeThread(this); 135 m_decodeThread = new DecodeThread(this);
136 m_decodeThread->start(); 136 m_decodeThread->start();
137 137
138 while (m_channelCount == 0 && !m_done) { 138 while ((m_channelCount == 0 || m_fileRate == 0) && !m_done) {
139 usleep(10); 139 usleep(10);
140 } 140 }
141 } 141 }
142 } 142 }
143 143
356 356
357 if (m_bitrateDenom > 0) { 357 if (m_bitrateDenom > 0) {
358 double bitrate = m_bitrateNum / m_bitrateDenom; 358 double bitrate = m_bitrateNum / m_bitrateDenom;
359 double duration = double(m_fileSize * 8) / bitrate; 359 double duration = double(m_fileSize * 8) / bitrate;
360 double elapsed = double(m_frameCount) / m_sampleRate; 360 double elapsed = double(m_frameCount) / m_sampleRate;
361 double percent = ((elapsed * 100.0) / duration); 361 double percent = 100;
362 if (duration > 0.0) percent = ((elapsed * 100.0) / duration);
362 int p = int(percent); 363 int p = int(percent);
363 if (p < 1) p = 1; 364 if (p < 1) p = 1;
364 if (p > 99) p = 99; 365 if (p > 99) p = 99;
365 if (m_completion != p || (m_progress && !m_progress->isVisible())) { 366 if (m_completion != p || (m_progress && !m_progress->isVisible())) {
366 m_completion = p; 367 m_completion = p;