mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 15:08:53 +00:00
va: decoder: improve locks for member variable access
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1516>
This commit is contained in:
parent
e15a8fcbdd
commit
f755730b20
1 changed files with 11 additions and 5 deletions
|
@ -217,12 +217,13 @@ gst_va_decoder_open (GstVaDecoder * self, VAProfile profile, guint rt_format)
|
||||||
.type = VAConfigAttribRTFormat,
|
.type = VAConfigAttribRTFormat,
|
||||||
.value = rt_format,
|
.value = rt_format,
|
||||||
};
|
};
|
||||||
|
VAConfigID config;
|
||||||
VADisplay dpy;
|
VADisplay dpy;
|
||||||
VAStatus status;
|
VAStatus status;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_VA_DECODER (self), FALSE);
|
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;
|
return TRUE;
|
||||||
|
|
||||||
if (!gst_va_decoder_has_profile (self, profile)) {
|
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);
|
dpy = gst_va_display_get_va_dpy (self->display);
|
||||||
gst_va_display_lock (self->display);
|
gst_va_display_lock (self->display);
|
||||||
status = vaCreateConfig (dpy, profile, VAEntrypointVLD, &attrib, 1,
|
status = vaCreateConfig (dpy, profile, VAEntrypointVLD, &attrib, 1, &config);
|
||||||
&self->config);
|
|
||||||
gst_va_display_unlock (self->display);
|
gst_va_display_unlock (self->display);
|
||||||
if (status != VA_STATUS_SUCCESS) {
|
if (status != VA_STATUS_SUCCESS) {
|
||||||
GST_ERROR_OBJECT (self, "vaCreateConfig: %s", vaErrorStr (status));
|
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);
|
GST_OBJECT_LOCK (self);
|
||||||
|
self->config = config;
|
||||||
self->profile = profile;
|
self->profile = profile;
|
||||||
self->rt_format = rt_format;
|
self->rt_format = rt_format;
|
||||||
GST_OBJECT_UNLOCK (self);
|
GST_OBJECT_UNLOCK (self);
|
||||||
|
@ -294,6 +295,7 @@ gboolean
|
||||||
gst_va_decoder_set_format (GstVaDecoder * self, gint coded_width,
|
gst_va_decoder_set_format (GstVaDecoder * self, gint coded_width,
|
||||||
gint coded_height, GArray * surfaces)
|
gint coded_height, GArray * surfaces)
|
||||||
{
|
{
|
||||||
|
VAContextID context;
|
||||||
VADisplay dpy;
|
VADisplay dpy;
|
||||||
VAStatus status;
|
VAStatus status;
|
||||||
VASurfaceID *render_targets = NULL;
|
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);
|
g_return_val_if_fail (GST_IS_VA_DECODER (self), FALSE);
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (self);
|
||||||
if (self->context != VA_INVALID_ID) {
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
GST_OBJECT_UNLOCK (self);
|
||||||
|
|
||||||
if (!gst_va_decoder_is_open (self)) {
|
if (!gst_va_decoder_is_open (self)) {
|
||||||
GST_ERROR_OBJECT (self, "decoder has not been opened yet");
|
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);
|
gst_va_display_lock (self->display);
|
||||||
status = vaCreateContext (dpy, self->config, coded_width, coded_height,
|
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);
|
gst_va_display_unlock (self->display);
|
||||||
|
|
||||||
if (status != VA_STATUS_SUCCESS) {
|
if (status != VA_STATUS_SUCCESS) {
|
||||||
|
@ -329,6 +334,7 @@ gst_va_decoder_set_format (GstVaDecoder * self, gint coded_width,
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_OBJECT_LOCK (self);
|
GST_OBJECT_LOCK (self);
|
||||||
|
self->context = context;
|
||||||
self->coded_width = coded_width;
|
self->coded_width = coded_width;
|
||||||
self->coded_height = coded_height;
|
self->coded_height = coded_height;
|
||||||
GST_OBJECT_UNLOCK (self);
|
GST_OBJECT_UNLOCK (self);
|
||||||
|
|
Loading…
Reference in a new issue