minor improvement for forward/rewind playback

parent 9021c9fd
......@@ -1057,21 +1057,23 @@ void Monitor::slotRewind(double speed)
slotActivateMonitor();
if (speed == 0) {
double currentspeed = render->playSpeed();
if (currentspeed >= 0) render->play(-1);
if (currentspeed >= 0)
speed = -1;
else switch((int) currentspeed) {
case -1:
render->play(-2);
speed = -2;
break;
case -2:
render->play(-3);
speed = -3;
break;
case -3:
render->play(-5);
speed = -5;
break;
default:
render->play(-8);
speed = -8;
}
} else render->play(speed);
}
render->switchPlay(true, speed);
m_playAction->setActive(true);
}
......@@ -1080,23 +1082,22 @@ void Monitor::slotForward(double speed)
slotActivateMonitor();
if (speed == 0) {
double currentspeed = render->playSpeed();
if (currentspeed <= 0) render->play(1);
if (currentspeed <= 0) speed = 1;
else switch((int) currentspeed) {
case 1:
render->play(2);
speed = 2;
break;
case 2:
render->play(3);
speed = 3;
break;
case 3:
render->play(5);
speed = 5;
break;
default:
render->play(8);
speed = 8;
}
} else {
render->play(speed);
}
render->switchPlay(true, speed);
m_playAction->setActive(true);
}
......
......@@ -707,7 +707,7 @@ void Render::setActiveMonitor()
if (!m_isActive) emit activateMonitor(m_name);
}
void Render::switchPlay(bool play)
void Render::switchPlay(bool play, double speed)
{
QMutexLocker locker(&m_mutex);
requestedSeekPosition = SEEK_INACTIVE;
......@@ -715,6 +715,7 @@ void Render::switchPlay(bool play)
return;
if (m_isZoneMode) resetZoneMode();
if (play) {
double currentSpeed = m_mltProducer->get_speed();
if (m_name == Kdenlive::ClipMonitor && m_mltConsumer->position() == m_mltProducer->get_out()) m_mltProducer->seek(0);
if (m_mltConsumer->get_int("real_time") != m_qmlView->realTime()) {
m_mltConsumer->set("real_time", m_qmlView->realTime());
......@@ -725,10 +726,14 @@ void Render::switchPlay(bool play)
m_mltConsumer->stop();
}
}
m_mltConsumer->start();
m_isRefreshing = true;
m_mltConsumer->set("refresh", 1);
m_mltProducer->set_speed(1.0);
if (currentSpeed == 0) {
m_mltConsumer->start();
m_isRefreshing = true;
m_mltConsumer->set("refresh", 1);
} else {
m_mltConsumer->purge();
}
m_mltProducer->set_speed(speed);
} else {
m_mltConsumer->purge();
m_mltProducer->set_speed(0.0);
......@@ -747,14 +752,21 @@ void Render::play(double speed)
double current_speed = m_mltProducer->get_speed();
if (current_speed == speed) return;
if (m_isZoneMode) resetZoneMode();
m_mltProducer->set_speed(speed);
if (m_mltConsumer->is_stopped() && speed != 0.0) {
m_mltConsumer->start();
if (speed != 0 && m_mltConsumer->get_int("real_time") != m_qmlView->realTime()) {
m_mltConsumer->set("real_time", m_qmlView->realTime());
m_mltConsumer->set("buffer", 25);
m_mltConsumer->set("prefill", 1);
// Changes to real_time require a consumer restart if running.
if (!m_mltConsumer->is_stopped()) {
m_mltConsumer->stop();
}
}
if (current_speed == 0.0 && speed != 0.0) {
if (current_speed == 0) {
m_mltConsumer->start();
m_isRefreshing = true;
m_mltConsumer->set("refresh", 1);
}
m_mltProducer->set_speed(speed);
}
void Render::play(const GenTime & startTime)
......
......@@ -139,7 +139,7 @@ class Render: public AbstractRender
* The speed is relative to normal playback, e.g. 1.0 is normal speed, 0.0
* is paused, -1.0 means play backwards. It does not specify start/stop */
void play(double speed);
void switchPlay(bool play);
void switchPlay(bool play, double speed = 1.0);
/** @brief Stops playing.
* @param startTime time to seek to */
......
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