Fix playing clip monitor seems to pause a few frames before end and seeking allowed past clip end

parent 05b122c6
...@@ -680,10 +680,9 @@ void GLWidget::refresh() ...@@ -680,10 +680,9 @@ void GLWidget::refresh()
m_consumer->set("refresh", 1); m_consumer->set("refresh", 1);
} }
bool GLWidget::checkFrameNumber(int pos, int offset) bool GLWidget::checkFrameNumber(int pos, int offset, bool isPlaying)
{ {
const double speed = m_producer->get_speed(); const double speed = m_producer->get_speed();
bool isPlaying = !qFuzzyIsNull(speed);
m_proxy->positionFromConsumer(pos, isPlaying); m_proxy->positionFromConsumer(pos, isPlaying);
int maxPos = m_producer->get_int("out"); int maxPos = m_producer->get_int("out");
if (m_isLoopMode || m_isZoneMode) { if (m_isLoopMode || m_isZoneMode) {
...@@ -716,7 +715,7 @@ bool GLWidget::checkFrameNumber(int pos, int offset) ...@@ -716,7 +715,7 @@ bool GLWidget::checkFrameNumber(int pos, int offset)
return false; return false;
} }
} }
return true; return isPlaying;
} }
void GLWidget::mousePressEvent(QMouseEvent *event) void GLWidget::mousePressEvent(QMouseEvent *event)
...@@ -1387,7 +1386,6 @@ void GLWidget::on_gl_nosync_frame_show(mlt_consumer, void *self, mlt_frame frame ...@@ -1387,7 +1386,6 @@ void GLWidget::on_gl_nosync_frame_show(mlt_consumer, void *self, mlt_frame frame
void GLWidget::on_gl_frame_show(mlt_consumer, void *self, mlt_frame frame_ptr) void GLWidget::on_gl_frame_show(mlt_consumer, void *self, mlt_frame frame_ptr)
{ {
Mlt::Frame frame(frame_ptr); Mlt::Frame frame(frame_ptr);
qDebug()<<"== SHOWING GL FRAME: "<<frame.get_position();
if (frame.get_int("rendered") != 0) { if (frame.get_int("rendered") != 0) {
auto *widget = static_cast<GLWidget *>(self); auto *widget = static_cast<GLWidget *>(self);
int timeout = (widget->consumer()->get_int("real_time") > 0) ? 0 : 1000; int timeout = (widget->consumer()->get_int("real_time") > 0) ? 0 : 1000;
......
...@@ -115,7 +115,7 @@ public: ...@@ -115,7 +115,7 @@ public:
int realTime() const; int realTime() const;
int droppedFrames() const; int droppedFrames() const;
void resetDrops(); void resetDrops();
bool checkFrameNumber(int pos, int offset); bool checkFrameNumber(int pos, int offset, bool isPlaying);
/** @brief Return current timeline position */ /** @brief Return current timeline position */
int getCurrentPos() const; int getCurrentPos() const;
/** @brief Requests a monitor refresh */ /** @brief Requests a monitor refresh */
......
...@@ -143,6 +143,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren ...@@ -143,6 +143,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
, m_editMarker(nullptr) , m_editMarker(nullptr)
, m_forceSizeFactor(0) , m_forceSizeFactor(0)
, m_lastMonitorSceneType(MonitorSceneDefault) , m_lastMonitorSceneType(MonitorSceneDefault)
, m_offset(id == Kdenlive::ClipMonitor ? 0 : TimelineModel::seekDuration)
{ {
auto *layout = new QVBoxLayout; auto *layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
...@@ -1179,7 +1180,11 @@ void Monitor::slotRewindOneFrame(int diff) ...@@ -1179,7 +1180,11 @@ void Monitor::slotRewindOneFrame(int diff)
void Monitor::slotForwardOneFrame(int diff) void Monitor::slotForwardOneFrame(int diff)
{ {
slotActivateMonitor(); slotActivateMonitor();
m_glMonitor->getControllerProxy()->setPosition(m_glMonitor->getCurrentPos() + diff); if (m_id == Kdenlive::ClipMonitor) {
m_glMonitor->getControllerProxy()->setPosition(qMin(m_glMonitor->duration(), m_glMonitor->getCurrentPos() + diff));
} else {
m_glMonitor->getControllerProxy()->setPosition(m_glMonitor->getCurrentPos() + diff);
}
} }
void Monitor::adjustRulerSize(int length, const std::shared_ptr<MarkerListModel> &markerModel) void Monitor::adjustRulerSize(int length, const std::shared_ptr<MarkerListModel> &markerModel)
...@@ -1650,7 +1655,7 @@ void Monitor::updateAudioForAnalysis() ...@@ -1650,7 +1655,7 @@ void Monitor::updateAudioForAnalysis()
void Monitor::onFrameDisplayed(const SharedFrame &frame) void Monitor::onFrameDisplayed(const SharedFrame &frame)
{ {
if (!m_glMonitor->checkFrameNumber(frame.get_position(), m_id == Kdenlive::ClipMonitor ? 0 : TimelineModel::seekDuration)) { if (!m_glMonitor->checkFrameNumber(frame.get_position(), m_offset, m_playAction->isActive())) {
m_playAction->setActive(false); m_playAction->setActive(false);
} }
m_monitorManager->frameDisplayed(frame); m_monitorManager->frameDisplayed(frame);
......
...@@ -217,6 +217,7 @@ private: ...@@ -217,6 +217,7 @@ private:
QAction *m_editMarker; QAction *m_editMarker;
KMessageWidget *m_infoMessage; KMessageWidget *m_infoMessage;
int m_forceSizeFactor; int m_forceSizeFactor;
int m_offset;
MonitorSceneType m_lastMonitorSceneType; MonitorSceneType m_lastMonitorSceneType;
MonitorAudioLevel *m_audioMeterWidget; MonitorAudioLevel *m_audioMeterWidget;
QElapsedTimer m_droppedTimer; QElapsedTimer m_droppedTimer;
......
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