]> git.sesse.net Git - kdenlive/commitdiff
Several small adjustments for monitor switching
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 25 Oct 2011 16:46:03 +0000 (16:46 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 25 Oct 2011 16:46:03 +0000 (16:46 +0000)
svn path=/trunk/kdenlive/; revision=5988

src/docclipbase.cpp
src/mainwindow.cpp
src/monitor.cpp
src/monitor.h
src/monitormanager.cpp
src/monitormanager.h
src/renderer.cpp
src/renderer.h

index 4d3a3bf02bc3e344fa4877da3173547b0cbe6037..bc399d6a7b724581e90e375b46af6cc05dc06779 100644 (file)
@@ -649,6 +649,11 @@ Mlt::Producer *DocClipBase::getCloneProducer()
     }
     if (prod) {
         adjustProducerProperties(prod, getId() + "_", false, false);
+        if (!m_properties.contains("proxy_out")) {
+            // Adjust length in case...
+            prod->set("length", m_properties.value("duration").toInt());
+            prod->set("out", m_properties.value("out").toInt());
+        }
     }
     return prod;
 }
index caf53edbba8471175cd8496109639708d2d565cc..e72108fe541a3596ed3627f5801d8e4e1ab62329 100644 (file)
@@ -841,14 +841,13 @@ void MainWindow::slotUpdateClip(const QString &id)
 {
     if (!m_activeDocument) return;
     DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
+    if (!clip) return;
     if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
     if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
         Mlt::Producer *monitorProducer = clip->getCloneProducer();
-        if (clip) m_clipMonitor->updateClipProducer(monitorProducer);
-    }
-    if (clip) {
-        clip->cleanupProducers();
+        m_clipMonitor->updateClipProducer(monitorProducer);
     }
+    clip->cleanupProducers();
 }
 
 void MainWindow::slotConnectMonitors()
index 19819ca5ef921227d57a39831f72caf0d16c8333..c1c755ca72f1b416e97105db8ecd6749439fa511 100644 (file)
@@ -587,9 +587,9 @@ bool Monitor::isActive() const
     return m_monitorManager->isActive(m_name);
 }
 
-void Monitor::activateMonitor()
+bool Monitor::activateMonitor()
 {
-    m_monitorManager->activateMonitor(m_name);
+    return m_monitorManager->activateMonitor(m_name);
 }
 
 void Monitor::setTimePos(const QString &pos)
@@ -739,8 +739,10 @@ void Monitor::start()
 void Monitor::refreshMonitor(bool visible)
 {
     if (visible && render) {
-        activateMonitor();
-        render->doRefresh(); //askForRefresh();
+        if (!activateMonitor()) {
+            // the monitor was already active, simply refreshClipThumbnail
+            render->doRefresh();
+        }
     }
 }
 
@@ -764,7 +766,7 @@ void Monitor::slotPlay()
 {
     if (render == NULL) return;
     activateMonitor();
-    if (render->playSpeed() == 0) {
+    if (render->playSpeed() == 0.0) {
         m_playAction->setIcon(m_pauseIcon);
         render->switchPlay(true);
     } else {
index 5dc9113d2b3f4e98761088d5f03644ef958cf629..9bb72f1db0897b0fd73cf7c3e46bb861295526d4 100644 (file)
@@ -215,7 +215,7 @@ public slots:
     void slotSeek(int pos);
     void stop();
     void start();
-    void activateMonitor();
+    bool activateMonitor();
     void slotPlay();
     void slotPlayZone();
     void slotLoopZone();
index 466501913cb8b6fa9f971152792affd4862ef80b..8d0d2341b83929e018a35c8de7f50efd1cd09201 100644 (file)
@@ -62,12 +62,12 @@ void MonitorManager::removeMonitor(AbstractMonitor *monitor)
     m_monitorsList.removeAll(monitor);
 }
 
-void MonitorManager::activateMonitor(QString name)
+bool MonitorManager::activateMonitor(const QString &name)
 {
     if (m_clipMonitor == NULL || m_projectMonitor == NULL)
-        return;
+        return false;
     if (m_activeMonitor && m_activeMonitor->name() == name)
-        return;
+        return false;
     m_activeMonitor = NULL;
     for (int i = 0; i < m_monitorsList.count(); i++) {
         if (m_monitorsList.at(i)->name() == name) {
@@ -76,10 +76,13 @@ void MonitorManager::activateMonitor(QString name)
         else m_monitorsList.at(i)->stop();
     }
     if (m_activeMonitor) {
+        m_activeMonitor->blockSignals(true);
         m_activeMonitor->parentWidget()->raise();
         m_activeMonitor->start();
+        m_activeMonitor->blockSignals(false);
     }
     emit checkColorScopes();
+    return (m_activeMonitor != NULL);
 }
 
 bool MonitorManager::isActive(const QString &name) const
index 9369c5ace6bceeede8cc26929a24b8c8cab1853d..eb58634486ba0fa957173f7242ae62a170dcca49 100644 (file)
@@ -46,7 +46,7 @@ public slots:
 
     /** @brief Activates a monitor.
      * @param name name of the monitor to activate */
-    void activateMonitor(QString name = QString());
+    bool activateMonitor(const QString &name = QString());
     bool isActive(const QString &name) const;
     void slotPlay();
     void slotPause();
index 5d8b75d88defd3b6b6a8b2aac728ec9982ed03ea..8aefda7abce5ccc225746ba92aba7015e7051d07 100644 (file)
@@ -121,6 +121,9 @@ Render::Render(const QString & rendererName, int winid, QString profile, QWidget
     m_mltProducer = m_blackClip->cut(0, 1);
     m_mltConsumer->connect(*m_mltProducer);
     m_mltProducer->set_speed(0.0);
+    m_refreshTimer.setSingleShot(true);
+    m_refreshTimer.setInterval(50);
+    connect(&m_refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
 }
 
 Render::~Render()
@@ -298,6 +301,7 @@ bool Render::hasProfile(const QString &profileName) const
 
 int Render::resetProfile(const QString &profileName, bool dropSceneList)
 {
+    m_refreshTimer.stop();
     if (m_mltConsumer) {
         if (m_externalConsumer == KdenliveSettings::external_display()) {
             if (KdenliveSettings::external_display() && m_activeProfile == profileName) return 1;
@@ -994,6 +998,7 @@ void Render::initSceneList()
 
 int Render::setProducer(Mlt::Producer *producer, int position)
 {
+    m_refreshTimer.stop();
     QMutexLocker locker(&m_mutex);
     QString currentId;
     int consumerPosition = 0;
@@ -1048,6 +1053,7 @@ int Render::setSceneList(QDomDocument list, int position)
 
 int Render::setSceneList(QString playlist, int position)
 {
+    m_refreshTimer.stop();
     QMutexLocker locker(&m_mutex);
     if (m_winid == -1) return -1;
     int error = 0;
@@ -1388,8 +1394,8 @@ void Render::switchPlay(bool play)
         if (m_mltConsumer->is_stopped()) {
             m_mltConsumer->start();
         }
-        m_mltConsumer->set("refresh", "1");
         m_mltProducer->set_speed(1.0);
+        m_mltConsumer->set("refresh", "1");
     } else if (!play) {
         m_mltProducer->set_speed(0.0);
         m_mltConsumer->set("refresh", 0);
@@ -1484,12 +1490,16 @@ void Render::seekToFrameDiff(int diff)
 
 void Render::doRefresh()
 {
-    // Use a Timer so that we don't refresh too much
-    QMutexLocker locker(&m_mutex);
+    m_refreshTimer.start();
+    /*QMutexLocker locker(&m_mutex);
     if (m_mltConsumer) {
-        if (m_mltConsumer->is_stopped()) m_mltConsumer->start();
+        if (m_mltConsumer->is_stopped()) {
+            kDebug()<<"pppppppppppppppp\n\nSTARTING CONSUMER: "<<m_name<<m_mltConsumer->start();
+        }
+        //m_mltProducer->set_speed(1);
         m_mltConsumer->set("refresh", 1);
-    }
+        //m_mltProducer->set_speed(0);
+    }*/
 }
 
 void Render::refresh()
index ea8b858ff80aa400c46a2aef2763a449b6cfcc8e..0b28916c9b8174c265ef795cf80b276924031e15 100644 (file)
@@ -334,6 +334,7 @@ private:
     QString m_activeProfile;
 
     QTimer *m_osdTimer;
+    QTimer m_refreshTimer;
     QMutex m_mutex;
     QMutex m_infoMutex;