]> git.sesse.net Git - kdenlive/commitdiff
Cleanup audio thumbnails thread handling
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 8 Apr 2009 16:47:00 +0000 (16:47 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 8 Apr 2009 16:47:00 +0000 (16:47 +0000)
svn path=/trunk/kdenlive/; revision=3259

src/kthumb.cpp
src/kthumb.h

index ec0f34c4b63ccf793446dfb514d2aee45aa87f7b..c92f72d4f51a4d187cc39c18ae773e29ef94d3d2 100644 (file)
 #include <QImage>
 #include <QApplication>
 
-void MyThread::init(QObject *parent, KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth)
+void MyThread::init(KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth)
 {
     stop_me = false;
-    m_parent = parent;
     m_isWorking = false;
     f.setFileName(target);
     m_url = url;
@@ -76,8 +75,6 @@ void MyThread::run()
         m_producer.attach(m_convert);
     }
 
-    //QApplication::postEvent(m_parent, new ProgressEvent(-1, (QEvent::Type)10005));
-
     int last_val = 0;
     int val = 0;
     kDebug() << "for " << m_frame << " " << m_frameLength << " " << m_producer.is_valid();
@@ -86,8 +83,6 @@ void MyThread::run()
         val = (int)((z - m_frame) / (m_frame + m_frameLength) * 100.0);
         if (last_val != val && val > 1) {
             emit audioThumbProgress(val);
-            //QApplication::postEvent(m_parent, new ProgressEvent(val, (QEvent::Type)10005));
-
             last_val = val;
         }
         m_producer.seek(z);
@@ -114,15 +109,12 @@ void MyThread::run()
         if (mlt_frame)
             delete mlt_frame;
     }
-    kDebug() << "done";
+    //kDebug() << "done";
     f.close();
     m_isWorking = false;
     if (stop_me) {
         f.remove();
-    }
-    emit audioThumbOver();
-    //QApplication::postEvent(m_parent, new ProgressEvent(-1, (QEvent::Type)10005));
-
+    } else emit audioThumbOver();
 }
 
 KThumb::KThumb(ClipManager *clipManager, KUrl url, const QString &id, const QString &hash, QObject * parent, const char */*name*/) :
@@ -145,9 +137,9 @@ KThumb::KThumb(ClipManager *clipManager, KUrl url, const QString &id, const QStr
 KThumb::~KThumb()
 {
     if (audioThumbProducer.isRunning()) {
-        slotAudioThumbOver();
         audioThumbProducer.stop_me = true;
-        audioThumbProducer.wait(300);
+        audioThumbProducer.wait();
+        slotAudioThumbOver();
     }
 }
 
@@ -436,7 +428,10 @@ void KThumb::getThumbs(KUrl url, int startframe, int endframe, int width, int he
 */
 void KThumb::stopAudioThumbs()
 {
-    if (audioThumbProducer.isRunning()) audioThumbProducer.stop_me = true;
+    if (audioThumbProducer.isRunning()) {
+        audioThumbProducer.stop_me = true;
+        slotAudioThumbOver();
+    }
 }
 
 void KThumb::removeAudioThumb()
@@ -485,9 +480,9 @@ void KThumb::getAudioThumbs(int channel, double frame, double frameLength, int a
         slotAudioThumbOver();
     } else {
         if (audioThumbProducer.isRunning()) return;
-        audioThumbProducer.init(this, m_url, m_thumbFile, frame, frameLength, m_frequency, m_channels, arrayWidth);
+        audioThumbProducer.init(m_url, m_thumbFile, frame, frameLength, m_frequency, m_channels, arrayWidth);
         audioThumbProducer.start(QThread::LowestPriority);
-        kDebug() << "STARTING GENERATE THMB FOR: " << m_url << " ................................";
+        kDebug() << "STARTING GENERATE THMB FOR: " << m_url << " ................................";
     }
 }
 
index 9a1dad8905f2a01140d18dead63e53a73ddb7fa4..3cb480c086d6f79d7ffbce1dbf38d168d1787368 100644 (file)
@@ -56,7 +56,7 @@ class MyThread : public QThread
     Q_OBJECT
 public:
     virtual void run();
-    void init(QObject *parent, KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth);
+    void init(KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth);
     bool isWorking();
     bool stop_me;
 
@@ -69,7 +69,6 @@ private:
     int m_channels;
     int m_arrayWidth;
     bool m_isWorking;
-    QObject *m_parent;
 
 signals:
     void audioThumbProgress(const int);