diff options
author | Tim Blechmann <tim@klingt.org> | 2024-03-01 11:02:05 +0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-03-06 13:24:52 +0000 |
commit | 9c405be6019d3b50d23b90b7c703bd9ed78e58d3 (patch) | |
tree | 9be3da957aa558e7a2926dd88d22d5176cc822a1 /src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp | |
parent | 6b9d1758989f79cd519974d127529a1cb4b504b6 (diff) |
GStreamer: use more RAII handle types
Small modernisation by avoiding the need for explicit memory management
Pick-to: 6.6 6.5
Change-Id: I6248be7c9a76780b980276ba444393dabf367281
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
(cherry picked from commit 3371efb74848a66560ad018366f8f26f592c160c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp')
-rw-r--r-- | src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp b/src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp index 66971a9a5..6c06ed067 100644 --- a/src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp +++ b/src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp @@ -4,6 +4,7 @@ #include "qgstreamervideosink_p.h" #include "qgstvideorenderersink_p.h" #include "qgstsubtitlesink_p.h" +#include <qgst_debug_p.h> #include <qgstutils_p.h> #include <rhi/qrhi.h> @@ -167,12 +168,8 @@ void QGstreamerVideoSink::updateSinkElement() void QGstreamerVideoSink::unrefGstContexts() { - if (m_gstGlDisplayContext) - gst_context_unref(m_gstGlDisplayContext); - m_gstGlDisplayContext = nullptr; - if (m_gstGlLocalContext) - gst_context_unref(m_gstGlLocalContext); - m_gstGlLocalContext = nullptr; + m_gstGlDisplayContext.close(); + m_gstGlLocalContext.close(); m_eglDisplay = nullptr; m_eglImageTargetTexture2D = nullptr; } @@ -244,26 +241,24 @@ void QGstreamerVideoSink::updateGstContexts() if (!appContext) qWarning() << "Could not create wrappped context for platform:" << glPlatform; - GError *error = nullptr; + QUniqueGErrorHandle error; QGstGLContextHandle displayContext; gst_gl_display_create_context(gstGlDisplay.get(), appContext.get(), &displayContext, &error); - if (error) { - qWarning() << "Could not create display context:" << error->message; - g_clear_error(&error); - } + if (error) + qWarning() << "Could not create display context:" << error; appContext.close(); - m_gstGlDisplayContext = gst_context_new(GST_GL_DISPLAY_CONTEXT_TYPE, false); - gst_context_set_gl_display(m_gstGlDisplayContext, gstGlDisplay.get()); + m_gstGlDisplayContext.reset(gst_context_new(GST_GL_DISPLAY_CONTEXT_TYPE, false)); + gst_context_set_gl_display(m_gstGlDisplayContext.get(), gstGlDisplay.get()); - m_gstGlLocalContext = gst_context_new("gst.gl.local_context", false); - GstStructure *structure = gst_context_writable_structure(m_gstGlLocalContext); + m_gstGlLocalContext.reset(gst_context_new("gst.gl.local_context", false)); + GstStructure *structure = gst_context_writable_structure(m_gstGlLocalContext.get()); gst_structure_set(structure, "context", GST_TYPE_GL_CONTEXT, displayContext.get(), nullptr); displayContext.close(); if (!gstPipeline.isNull()) - gst_element_set_context(gstPipeline.element(), m_gstGlLocalContext); + gst_element_set_context(gstPipeline.element(), m_gstGlLocalContext.get()); #endif // #if QT_CONFIG(gstreamer_gl) } |