|
From: Tapio V. <aa...@us...> - 2011-01-24 11:14:46
|
Module: editor
Branch: master
Commit: ad30b03e91a89861400a0b15e92e7af676790066
Author: Tapio Vierros <tap...@gm...>
Date: Mon Jan 24 13:13:58 2011 +0200
Handle FFmpeg not being able to open file.
---
notegraphwidget.cc | 6 ++++--
pitchvis.cc | 8 ++++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 740d4c0..d3e4a4c 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -130,8 +130,10 @@ void NoteGraphWidget::timerEvent(QTimerEvent *event)
if (!m_pitch.isNull()) {
QMutexLocker locker(&m_pitch->mutex);
if (m_pitch->newDataAvailable()) setPixmap(QPixmap::fromImage(m_pitch->getImage()));
- if (m_pitch->isFinished()) killTimer(m_analyzeTimer);
- emit analyzeProgress(m_pitch->getXValue(), width());
+ if (m_pitch->isFinished()) {
+ killTimer(m_analyzeTimer);
+ emit analyzeProgress(0, 0); // Reset progressbar
+ } else emit analyzeProgress(m_pitch->getXValue(), width());
}
}
diff --git a/pitchvis.cc b/pitchvis.cc
index d7929a3..20aea67 100644
--- a/pitchvis.cc
+++ b/pitchvis.cc
@@ -29,10 +29,14 @@ void PitchVis::run()
{
// Initialize FFmpeg decoding
FFmpeg mpeg(false, true, fileName.toStdString(), rate);
- while(std::isnan(mpeg.duration())) msleep(1000); // Wait for ffmpeg to be ready
+ while(std::isnan(mpeg.duration()) || std::isinf(mpeg.duration())) {
+ if (mpeg.terminating()) // Check if FFMPEG has failed
+ return;
+ msleep(1000); // Wait for ffmpeg to be ready
+ }
msleep(1000); // Wait some more
setWidth(mpeg.duration() * rate / step); // Estimation
-
+
curX = 0;
for (std::vector<float> data(step*2); mpeg.audioQueue(&*data.begin(), &*data.end(), curX * step * 2); ++curX) {
// Mix stereo into mono
|