Commit 05fda675 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix possible freeze changing monitor real time

CCBUG: 429228
parent 57a9f96f
......@@ -3619,15 +3619,16 @@ void MainWindow::slotSwitchMonitorOverlay(QAction *action)
void MainWindow::slotSwitchDropFrames(bool drop)
{
m_clipMonitor->switchDropFrames(drop);
m_projectMonitor->switchDropFrames(drop);
KdenliveSettings::setMonitor_dropframes(drop);
m_clipMonitor->restart();
m_projectMonitor->restart();
}
void MainWindow::slotSetMonitorGamma(int gamma)
{
KdenliveSettings::setMonitor_gamma(gamma);
m_clipMonitor->updateMonitorGamma();
m_projectMonitor->updateMonitorGamma();
m_clipMonitor->restart();
m_projectMonitor->restart();
}
void MainWindow::slotInsertZoneToTree()
......
......@@ -1333,11 +1333,6 @@ std::shared_ptr<Mlt::Consumer> GLWidget::consumer()
return m_consumer;
}
void GLWidget::updateGamma()
{
reconfigure();
}
void GLWidget::resetConsumer(bool fullReset)
{
if (fullReset && m_consumer) {
......@@ -1770,20 +1765,14 @@ double GLWidget::playSpeed() const
return 0.0;
}
void GLWidget::setDropFrames(bool drop)
void GLWidget::restart()
{
// why this lock?
QMutexLocker locker(&m_mltMutex);
if (m_consumer) {
int dropFrames = 1;
if (!drop) {
dropFrames = -dropFrames;
}
// Make sure to delete and rebuild consumer to match profile
m_consumer->purge();
m_consumer->stop();
m_consumer->set("real_time", dropFrames);
if (m_consumer->start() == -1) {
qCWarning(KDENLIVE_LOG) << "ERROR, Cannot start monitor";
}
reconfigure();
}
}
......
......@@ -107,7 +107,6 @@ public:
QRect displayRect() const;
/** @brief set to true if we want to emit a QImage of the frame for analysis */
bool sendFrameForAnalysis;
void updateGamma();
/** @brief delete and rebuild consumer, for example when external display is switched */
void resetConsumer(bool fullReset);
void lockMonitor();
......@@ -128,8 +127,8 @@ public:
int rulerHeight() const;
/** @brief return current play producer's playing speed */
double playSpeed() const;
/** @brief Turn drop frame feature on/off */
void setDropFrames(bool drop);
/** @brief Purge and restart consumer */
void restart();
/** @brief Returns current audio volume */
int volume() const;
/** @brief Set audio volume on consumer */
......
......@@ -1707,9 +1707,9 @@ void Monitor::updateClipZone(const QPoint zone)
m_controller->setZone(zone);
}
void Monitor::switchDropFrames(bool drop)
void Monitor::restart()
{
m_glMonitor->setDropFrames(drop);
m_glMonitor->restart();
}
void Monitor::switchMonitorInfo(int code)
......@@ -1731,17 +1731,6 @@ void Monitor::switchMonitorInfo(int code)
}
}
void Monitor::updateMonitorGamma()
{
if (isActive()) {
stop();
m_glMonitor->updateGamma();
start();
} else {
m_glMonitor->updateGamma();
}
}
void Monitor::slotEditMarker()
{
if (m_editMarker) {
......
......@@ -125,8 +125,7 @@ public:
void sendFrameForAnalysis(bool analyse);
void updateAudioForAnalysis();
void switchMonitorInfo(int code);
void switchDropFrames(bool drop);
void updateMonitorGamma();
void restart();
void mute(bool, bool updateIconOnly = false) override;
/** @brief Returns the action displaying record toolbar */
QAction *recAction();
......
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