Several small adjustments for monitor switching

svn path=/trunk/kdenlive/; revision=5988
parent c8049387
......@@ -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;
}
......
......@@ -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()
......
......@@ -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 {
......
......@@ -215,7 +215,7 @@ public slots:
void slotSeek(int pos);
void stop();
void start();
void activateMonitor();
bool activateMonitor();
void slotPlay();
void slotPlayZone();
void slotLoopZone();
......
......@@ -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
......
......@@ -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();
......
......@@ -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()
......
......@@ -334,6 +334,7 @@ private:
QString m_activeProfile;
QTimer *m_osdTimer;
QTimer m_refreshTimer;
QMutex m_mutex;
QMutex m_infoMutex;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment