summaryrefslogtreecommitdiffstats
path: root/src/gsttools/qvideosurfacegstsink.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gsttools/qvideosurfacegstsink.cpp')
-rw-r--r--src/gsttools/qvideosurfacegstsink.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/gsttools/qvideosurfacegstsink.cpp b/src/gsttools/qvideosurfacegstsink.cpp
index 36644581e..4a786ea16 100644
--- a/src/gsttools/qvideosurfacegstsink.cpp
+++ b/src/gsttools/qvideosurfacegstsink.cpp
@@ -162,6 +162,15 @@ void QVideoSurfaceGstDelegate::stop()
m_started = false;
}
+void QVideoSurfaceGstDelegate::unlock()
+{
+ QMutexLocker locker(&m_mutex);
+
+ m_startCanceled = true;
+ m_setupCondition.wakeAll();
+ m_renderCondition.wakeAll();
+}
+
bool QVideoSurfaceGstDelegate::isActive()
{
QMutexLocker locker(&m_mutex);
@@ -218,8 +227,9 @@ GstFlowReturn QVideoSurfaceGstDelegate::render(GstBuffer *buffer)
void QVideoSurfaceGstDelegate::queuedStart()
{
+ QMutexLocker locker(&m_mutex);
+
if (!m_startCanceled) {
- QMutexLocker locker(&m_mutex);
m_started = m_surface->start(m_format);
m_setupCondition.wakeAll();
}
@@ -238,6 +248,9 @@ void QVideoSurfaceGstDelegate::queuedRender()
{
QMutexLocker locker(&m_mutex);
+ if (!m_frame.isValid())
+ return;
+
if (m_surface.isNull()) {
qWarning() << "Rendering video frame to deleted surface, skip the frame";
m_renderReturn = GST_FLOW_OK;
@@ -347,6 +360,7 @@ void QVideoSurfaceGstSink::class_init(gpointer g_class, gpointer class_data)
base_sink_class->buffer_alloc = QVideoSurfaceGstSink::buffer_alloc;
base_sink_class->start = QVideoSurfaceGstSink::start;
base_sink_class->stop = QVideoSurfaceGstSink::stop;
+ base_sink_class->unlock = QVideoSurfaceGstSink::unlock;
GstElementClass *element_class = reinterpret_cast<GstElementClass *>(g_class);
element_class->change_state = QVideoSurfaceGstSink::change_state;
@@ -601,6 +615,13 @@ gboolean QVideoSurfaceGstSink::stop(GstBaseSink *base)
return TRUE;
}
+gboolean QVideoSurfaceGstSink::unlock(GstBaseSink *base)
+{
+ VO_SINK(base);
+ sink->delegate->unlock();
+ return TRUE;
+}
+
GstFlowReturn QVideoSurfaceGstSink::show_frame(GstVideoSink *base, GstBuffer *buffer)
{
VO_SINK(base);