summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2020-08-18 11:38:46 +0200
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-08-24 19:35:57 +0000
commitf755730b2045686c8c70c457cebc49a21fa6044b (patch)
tree440effe44b91531ccbaba060736a0f1d260c9ac5 /sys
parente15a8fcbdd1f6e84cac603de345f19d01c8207e8 (diff)
downloadgstreamer-plugins-bad-f755730b2045686c8c70c457cebc49a21fa6044b.tar.gz
va: decoder: improve locks for member variable access
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1516>
Diffstat (limited to 'sys')
-rw-r--r--sys/va/gstvadecoder.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/va/gstvadecoder.c b/sys/va/gstvadecoder.c
index e23728d83..af5351799 100644
--- a/sys/va/gstvadecoder.c
+++ b/sys/va/gstvadecoder.c
@@ -217,12 +217,13 @@ gst_va_decoder_open (GstVaDecoder * self, VAProfile profile, guint rt_format)
.type = VAConfigAttribRTFormat,
.value = rt_format,
};
+ VAConfigID config;
VADisplay dpy;
VAStatus status;
g_return_val_if_fail (GST_IS_VA_DECODER (self), FALSE);
- if (self->config != VA_INVALID_ID)
+ if (gst_va_decoder_is_open (self))
return TRUE;
if (!gst_va_decoder_has_profile (self, profile)) {
@@ -232,8 +233,7 @@ gst_va_decoder_open (GstVaDecoder * self, VAProfile profile, guint rt_format)
dpy = gst_va_display_get_va_dpy (self->display);
gst_va_display_lock (self->display);
- status = vaCreateConfig (dpy, profile, VAEntrypointVLD, &attrib, 1,
- &self->config);
+ status = vaCreateConfig (dpy, profile, VAEntrypointVLD, &attrib, 1, &config);
gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
GST_ERROR_OBJECT (self, "vaCreateConfig: %s", vaErrorStr (status));
@@ -241,6 +241,7 @@ gst_va_decoder_open (GstVaDecoder * self, VAProfile profile, guint rt_format)
}
GST_OBJECT_LOCK (self);
+ self->config = config;
self->profile = profile;
self->rt_format = rt_format;
GST_OBJECT_UNLOCK (self);
@@ -294,6 +295,7 @@ gboolean
gst_va_decoder_set_format (GstVaDecoder * self, gint coded_width,
gint coded_height, GArray * surfaces)
{
+ VAContextID context;
VADisplay dpy;
VAStatus status;
VASurfaceID *render_targets = NULL;
@@ -301,10 +303,13 @@ gst_va_decoder_set_format (GstVaDecoder * self, gint coded_width,
g_return_val_if_fail (GST_IS_VA_DECODER (self), FALSE);
+ GST_OBJECT_LOCK (self);
if (self->context != VA_INVALID_ID) {
- GST_WARNING_OBJECT (self, "decoder already has a format");
+ GST_OBJECT_UNLOCK (self);
+ GST_INFO_OBJECT (self, "decoder already has a format");
return TRUE;
}
+ GST_OBJECT_UNLOCK (self);
if (!gst_va_decoder_is_open (self)) {
GST_ERROR_OBJECT (self, "decoder has not been opened yet");
@@ -320,7 +325,7 @@ gst_va_decoder_set_format (GstVaDecoder * self, gint coded_width,
gst_va_display_lock (self->display);
status = vaCreateContext (dpy, self->config, coded_width, coded_height,
- VA_PROGRESSIVE, render_targets, num_render_targets, &self->context);
+ VA_PROGRESSIVE, render_targets, num_render_targets, &context);
gst_va_display_unlock (self->display);
if (status != VA_STATUS_SUCCESS) {
@@ -329,6 +334,7 @@ gst_va_decoder_set_format (GstVaDecoder * self, gint coded_width,
}
GST_OBJECT_LOCK (self);
+ self->context = context;
self->coded_width = coded_width;
self->coded_height = coded_height;
GST_OBJECT_UNLOCK (self);