mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
d3d11: Use WIN32 API directly for locking with RAII pattern
Such abstraction is unnecessary for this library/plugin. Use WIN32 API directly instead of GLib wrappers. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2848>
This commit is contained in:
parent
a75e88fdd2
commit
05dae94352
5 changed files with 33 additions and 112 deletions
|
@ -626,7 +626,7 @@ struct _GstD3D11ConverterPrivate
|
||||||
|
|
||||||
GstVideoOrientationMethod video_direction;
|
GstVideoOrientationMethod video_direction;
|
||||||
|
|
||||||
GMutex prop_lock;
|
SRWLOCK prop_lock;
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
gint src_x;
|
gint src_x;
|
||||||
|
@ -762,7 +762,6 @@ gst_d3d11_converter_init (GstD3D11Converter * self)
|
||||||
{
|
{
|
||||||
self->priv = (GstD3D11ConverterPrivate *)
|
self->priv = (GstD3D11ConverterPrivate *)
|
||||||
gst_d3d11_converter_get_instance_private (self);
|
gst_d3d11_converter_get_instance_private (self);
|
||||||
g_mutex_init (&self->priv->prop_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -813,8 +812,6 @@ gst_d3d11_converter_finalize (GObject * object)
|
||||||
g_free (priv->in_cll_str);
|
g_free (priv->in_cll_str);
|
||||||
g_free (priv->out_cll_str);
|
g_free (priv->out_cll_str);
|
||||||
|
|
||||||
g_mutex_clear (&priv->prop_lock);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -867,7 +864,7 @@ gst_d3d11_converter_set_property (GObject * object, guint prop_id,
|
||||||
GstD3D11Converter *self = GST_D3D11_CONVERTER (object);
|
GstD3D11Converter *self = GST_D3D11_CONVERTER (object);
|
||||||
GstD3D11ConverterPrivate *priv = self->priv;
|
GstD3D11ConverterPrivate *priv = self->priv;
|
||||||
|
|
||||||
g_mutex_lock (&priv->prop_lock);
|
GstD3D11SRWLockGuard (&priv->prop_lock);
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_SRC_X:
|
case PROP_SRC_X:
|
||||||
update_src_rect (self, &priv->src_x, value);
|
update_src_rect (self, &priv->src_x, value);
|
||||||
|
@ -974,7 +971,6 @@ gst_d3d11_converter_set_property (GObject * object, guint prop_id,
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
g_mutex_unlock (&priv->prop_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -984,7 +980,7 @@ gst_d3d11_converter_get_property (GObject * object, guint prop_id,
|
||||||
GstD3D11Converter *self = GST_D3D11_CONVERTER (object);
|
GstD3D11Converter *self = GST_D3D11_CONVERTER (object);
|
||||||
GstD3D11ConverterPrivate *priv = self->priv;
|
GstD3D11ConverterPrivate *priv = self->priv;
|
||||||
|
|
||||||
g_mutex_lock (&priv->prop_lock);
|
GstD3D11SRWLockGuard (&priv->prop_lock);
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_SRC_X:
|
case PROP_SRC_X:
|
||||||
g_value_set_int (value, priv->src_x);
|
g_value_set_int (value, priv->src_x);
|
||||||
|
@ -1056,7 +1052,6 @@ gst_d3d11_converter_get_property (GObject * object, guint prop_id,
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
g_mutex_unlock (&priv->prop_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -3096,7 +3091,6 @@ gst_d3d11_converter_convert_internal (GstD3D11Converter * self,
|
||||||
UINT offsets = 0;
|
UINT offsets = 0;
|
||||||
UINT vertex_stride = sizeof (VertexData);
|
UINT vertex_stride = sizeof (VertexData);
|
||||||
ID3D11ShaderResourceView *clear_view[GST_VIDEO_MAX_PLANES] = { nullptr, };
|
ID3D11ShaderResourceView *clear_view[GST_VIDEO_MAX_PLANES] = { nullptr, };
|
||||||
gboolean ret = TRUE;
|
|
||||||
|
|
||||||
priv = self->priv;
|
priv = self->priv;
|
||||||
cinfo = &priv->convert_info;
|
cinfo = &priv->convert_info;
|
||||||
|
@ -3107,11 +3101,9 @@ gst_d3d11_converter_convert_internal (GstD3D11Converter * self,
|
||||||
resource.As (&texture);
|
resource.As (&texture);
|
||||||
texture->GetDesc (&desc);
|
texture->GetDesc (&desc);
|
||||||
|
|
||||||
g_mutex_lock (&priv->prop_lock);
|
|
||||||
if (priv->update_dest_rect && !gst_d3d11_converter_update_dest_rect (self)) {
|
if (priv->update_dest_rect && !gst_d3d11_converter_update_dest_rect (self)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to update dest rect");
|
GST_ERROR_OBJECT (self, "Failed to update dest rect");
|
||||||
ret = FALSE;
|
return FALSE;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->update_src_rect ||
|
if (priv->update_src_rect ||
|
||||||
|
@ -3125,8 +3117,7 @@ gst_d3d11_converter_convert_internal (GstD3D11Converter * self,
|
||||||
|
|
||||||
if (!gst_d3d11_converter_update_src_rect (self)) {
|
if (!gst_d3d11_converter_update_src_rect (self)) {
|
||||||
GST_ERROR_OBJECT (self, "Cannot update src rect");
|
GST_ERROR_OBJECT (self, "Cannot update src rect");
|
||||||
ret = FALSE;
|
return FALSE;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3140,8 +3131,7 @@ gst_d3d11_converter_convert_internal (GstD3D11Converter * self,
|
||||||
if (!gst_d3d11_result (hr, self->device)) {
|
if (!gst_d3d11_result (hr, self->device)) {
|
||||||
GST_ERROR_OBJECT (self,
|
GST_ERROR_OBJECT (self,
|
||||||
"Couldn't map constant buffer, hr: 0x%x", (guint) hr);
|
"Couldn't map constant buffer, hr: 0x%x", (guint) hr);
|
||||||
ret = FALSE;
|
return FALSE;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const_buffer = (PSConstBuffer *) map.pData;
|
const_buffer = (PSConstBuffer *) map.pData;
|
||||||
|
@ -3197,10 +3187,7 @@ gst_d3d11_converter_convert_internal (GstD3D11Converter * self,
|
||||||
context->PSSetShaderResources (0, 4, clear_view);
|
context->PSSetShaderResources (0, 4, clear_view);
|
||||||
context->OMSetRenderTargets (0, nullptr, nullptr);
|
context->OMSetRenderTargets (0, nullptr, nullptr);
|
||||||
|
|
||||||
out:
|
return TRUE;
|
||||||
g_mutex_unlock (&priv->prop_lock);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -3652,7 +3639,7 @@ gst_d3d11_converter_convert_buffer_internal (GstD3D11Converter * self,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_lock (&priv->prop_lock);
|
GstD3D11SRWLockGuard (&priv->prop_lock);
|
||||||
gst_d3d11_converter_update_hdr10_meta (self);
|
gst_d3d11_converter_update_hdr10_meta (self);
|
||||||
|
|
||||||
if (priv->blend && priv->blend_desc.RenderTarget[0].BlendEnable) {
|
if (priv->blend && priv->blend_desc.RenderTarget[0].BlendEnable) {
|
||||||
|
@ -3706,14 +3693,12 @@ gst_d3d11_converter_convert_buffer_internal (GstD3D11Converter * self,
|
||||||
if (use_processor) {
|
if (use_processor) {
|
||||||
if (!pov) {
|
if (!pov) {
|
||||||
GST_ERROR_OBJECT (self, "POV is unavailable");
|
GST_ERROR_OBJECT (self, "POV is unavailable");
|
||||||
g_mutex_unlock (&priv->prop_lock);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!piv) {
|
if (!piv) {
|
||||||
if (!gst_d3d11_converter_ensure_fallback_inbuf (self, in_buf, in_info)) {
|
if (!gst_d3d11_converter_ensure_fallback_inbuf (self, in_buf, in_info)) {
|
||||||
GST_ERROR_OBJECT (self, "Couldn't copy into fallback texture");
|
GST_ERROR_OBJECT (self, "Couldn't copy into fallback texture");
|
||||||
g_mutex_unlock (&priv->prop_lock);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3723,7 +3708,6 @@ gst_d3d11_converter_convert_buffer_internal (GstD3D11Converter * self,
|
||||||
if (!gst_d3d11_converter_map_buffer (self,
|
if (!gst_d3d11_converter_map_buffer (self,
|
||||||
in_buf, in_info, (GstMapFlags) (GST_MAP_READ | GST_MAP_D3D11))) {
|
in_buf, in_info, (GstMapFlags) (GST_MAP_READ | GST_MAP_D3D11))) {
|
||||||
GST_ERROR_OBJECT (self, "Couldn't map fallback buffer");
|
GST_ERROR_OBJECT (self, "Couldn't map fallback buffer");
|
||||||
g_mutex_unlock (&priv->prop_lock);
|
|
||||||
in_buf = nullptr;
|
in_buf = nullptr;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -3733,7 +3717,6 @@ gst_d3d11_converter_convert_buffer_internal (GstD3D11Converter * self,
|
||||||
priv->video_device, priv->enumerator);
|
priv->video_device, priv->enumerator);
|
||||||
if (!piv) {
|
if (!piv) {
|
||||||
GST_ERROR_OBJECT (self, "Couldn't get POV from fallback buffer");
|
GST_ERROR_OBJECT (self, "Couldn't get POV from fallback buffer");
|
||||||
g_mutex_unlock (&priv->prop_lock);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3748,13 +3731,11 @@ gst_d3d11_converter_convert_buffer_internal (GstD3D11Converter * self,
|
||||||
|
|
||||||
if (priv->update_dest_rect && !gst_d3d11_converter_update_dest_rect (self)) {
|
if (priv->update_dest_rect && !gst_d3d11_converter_update_dest_rect (self)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to update dest rect");
|
GST_ERROR_OBJECT (self, "Failed to update dest rect");
|
||||||
g_mutex_unlock (&priv->prop_lock);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->update_src_rect && !gst_d3d11_converter_update_src_rect (self)) {
|
if (priv->update_src_rect && !gst_d3d11_converter_update_src_rect (self)) {
|
||||||
GST_ERROR_OBJECT (self, "Cannot update src rect");
|
GST_ERROR_OBJECT (self, "Cannot update src rect");
|
||||||
g_mutex_unlock (&priv->prop_lock);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3807,14 +3788,11 @@ gst_d3d11_converter_convert_buffer_internal (GstD3D11Converter * self,
|
||||||
GST_TRACE_OBJECT (self, "Converting using processor");
|
GST_TRACE_OBJECT (self, "Converting using processor");
|
||||||
|
|
||||||
hr = video_ctx->VideoProcessorBlt (proc, pov, 0, 1, &stream);
|
hr = video_ctx->VideoProcessorBlt (proc, pov, 0, 1, &stream);
|
||||||
g_mutex_unlock (&priv->prop_lock);
|
|
||||||
|
|
||||||
ret = gst_d3d11_result (hr, self->device);;
|
ret = gst_d3d11_result (hr, self->device);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_unlock (&priv->prop_lock);
|
|
||||||
|
|
||||||
if ((priv->supported_backend & GST_D3D11_CONVERTER_BACKEND_SHADER) == 0) {
|
if ((priv->supported_backend & GST_D3D11_CONVERTER_BACKEND_SHADER) == 0) {
|
||||||
GST_ERROR_OBJECT (self, "Conversion is not supported");
|
GST_ERROR_OBJECT (self, "Conversion is not supported");
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -114,7 +114,7 @@ struct _GstD3D11DevicePrivate
|
||||||
GArray *format_table;
|
GArray *format_table;
|
||||||
|
|
||||||
CRITICAL_SECTION extern_lock;
|
CRITICAL_SECTION extern_lock;
|
||||||
GMutex resource_lock;
|
SRWLOCK resource_lock;
|
||||||
|
|
||||||
LARGE_INTEGER frequency;
|
LARGE_INTEGER frequency;
|
||||||
|
|
||||||
|
@ -411,7 +411,6 @@ gst_d3d11_device_init (GstD3D11Device * self)
|
||||||
sizeof (GstD3D11Format), GST_D3D11_N_FORMATS);
|
sizeof (GstD3D11Format), GST_D3D11_N_FORMATS);
|
||||||
|
|
||||||
InitializeCriticalSection (&priv->extern_lock);
|
InitializeCriticalSection (&priv->extern_lock);
|
||||||
g_mutex_init (&priv->resource_lock);
|
|
||||||
|
|
||||||
self->priv = priv;
|
self->priv = priv;
|
||||||
}
|
}
|
||||||
|
@ -740,7 +739,6 @@ gst_d3d11_device_finalize (GObject * object)
|
||||||
|
|
||||||
g_array_unref (priv->format_table);
|
g_array_unref (priv->format_table);
|
||||||
DeleteCriticalSection (&priv->extern_lock);
|
DeleteCriticalSection (&priv->extern_lock);
|
||||||
g_mutex_clear (&priv->resource_lock);
|
|
||||||
g_free (priv->description);
|
g_free (priv->description);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
@ -1253,7 +1251,7 @@ gst_d3d11_device_get_video_device_handle (GstD3D11Device * device)
|
||||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||||
|
|
||||||
priv = device->priv;
|
priv = device->priv;
|
||||||
g_mutex_lock (&priv->resource_lock);
|
GstD3D11SRWLockGuard lk (&priv->resource_lock);
|
||||||
if (!priv->video_device) {
|
if (!priv->video_device) {
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
ID3D11VideoDevice *video_device = NULL;
|
ID3D11VideoDevice *video_device = NULL;
|
||||||
|
@ -1262,7 +1260,6 @@ gst_d3d11_device_get_video_device_handle (GstD3D11Device * device)
|
||||||
if (gst_d3d11_result (hr, device))
|
if (gst_d3d11_result (hr, device))
|
||||||
priv->video_device = video_device;
|
priv->video_device = video_device;
|
||||||
}
|
}
|
||||||
g_mutex_unlock (&priv->resource_lock);
|
|
||||||
|
|
||||||
return priv->video_device;
|
return priv->video_device;
|
||||||
}
|
}
|
||||||
|
@ -1287,7 +1284,7 @@ gst_d3d11_device_get_video_context_handle (GstD3D11Device * device)
|
||||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||||
|
|
||||||
priv = device->priv;
|
priv = device->priv;
|
||||||
g_mutex_lock (&priv->resource_lock);
|
GstD3D11SRWLockGuard lk (&priv->resource_lock);
|
||||||
if (!priv->video_context) {
|
if (!priv->video_context) {
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
ID3D11VideoContext *video_context = NULL;
|
ID3D11VideoContext *video_context = NULL;
|
||||||
|
@ -1296,7 +1293,6 @@ gst_d3d11_device_get_video_context_handle (GstD3D11Device * device)
|
||||||
if (gst_d3d11_result (hr, device))
|
if (gst_d3d11_result (hr, device))
|
||||||
priv->video_context = video_context;
|
priv->video_context = video_context;
|
||||||
}
|
}
|
||||||
g_mutex_unlock (&priv->resource_lock);
|
|
||||||
|
|
||||||
return priv->video_context;
|
return priv->video_context;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ struct _GstD3D11BaseConvert
|
||||||
/* method previously selected and used for negotiation */
|
/* method previously selected and used for negotiation */
|
||||||
GstVideoOrientationMethod active_method;
|
GstVideoOrientationMethod active_method;
|
||||||
|
|
||||||
GMutex lock;
|
SRWLOCK lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,7 +102,6 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstD3D11BaseConvert, gst_d3d11_base_convert,
|
||||||
"d3d11convert"));
|
"d3d11convert"));
|
||||||
|
|
||||||
static void gst_d3d11_base_convert_dispose (GObject * object);
|
static void gst_d3d11_base_convert_dispose (GObject * object);
|
||||||
static void gst_d3d11_base_convert_finalize (GObject * object);
|
|
||||||
static GstCaps *gst_d3d11_base_convert_transform_caps (GstBaseTransform *
|
static GstCaps *gst_d3d11_base_convert_transform_caps (GstBaseTransform *
|
||||||
trans, GstPadDirection direction, GstCaps * caps, GstCaps * filter);
|
trans, GstPadDirection direction, GstCaps * caps, GstCaps * filter);
|
||||||
static GstCaps *gst_d3d11_base_convert_fixate_caps (GstBaseTransform *
|
static GstCaps *gst_d3d11_base_convert_fixate_caps (GstBaseTransform *
|
||||||
|
@ -259,7 +258,6 @@ gst_d3d11_base_convert_class_init (GstD3D11BaseConvertClass * klass)
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
gobject_class->dispose = gst_d3d11_base_convert_dispose;
|
gobject_class->dispose = gst_d3d11_base_convert_dispose;
|
||||||
gobject_class->finalize = gst_d3d11_base_convert_finalize;
|
|
||||||
|
|
||||||
caps = gst_d3d11_get_updated_template_caps (&sink_template_caps);
|
caps = gst_d3d11_get_updated_template_caps (&sink_template_caps);
|
||||||
gst_element_class_add_pad_template (element_class,
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
@ -300,8 +298,6 @@ gst_d3d11_base_convert_init (GstD3D11BaseConvert * self)
|
||||||
self->border_color = DEFAULT_BORDER_COLOR;
|
self->border_color = DEFAULT_BORDER_COLOR;
|
||||||
self->gamma_mode = DEFAULT_GAMMA_MODE;
|
self->gamma_mode = DEFAULT_GAMMA_MODE;
|
||||||
self->primaries_mode = DEFAULT_PRIMARIES_MODE;
|
self->primaries_mode = DEFAULT_PRIMARIES_MODE;
|
||||||
|
|
||||||
g_mutex_init (&self->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -309,23 +305,11 @@ gst_d3d11_base_convert_dispose (GObject * object)
|
||||||
{
|
{
|
||||||
GstD3D11BaseConvert *self = GST_D3D11_BASE_CONVERT (object);
|
GstD3D11BaseConvert *self = GST_D3D11_BASE_CONVERT (object);
|
||||||
|
|
||||||
g_mutex_lock (&self->lock);
|
|
||||||
gst_clear_object (&self->converter);
|
gst_clear_object (&self->converter);
|
||||||
g_mutex_unlock (&self->lock);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gst_d3d11_base_convert_finalize (GObject * object)
|
|
||||||
{
|
|
||||||
GstD3D11BaseConvert *self = GST_D3D11_BASE_CONVERT (object);
|
|
||||||
|
|
||||||
g_mutex_clear (&self->lock);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
gst_d3d11_base_convert_transform_caps (GstBaseTransform *
|
gst_d3d11_base_convert_transform_caps (GstBaseTransform *
|
||||||
trans, GstPadDirection direction, GstCaps * caps, GstCaps * filter)
|
trans, GstPadDirection direction, GstCaps * caps, GstCaps * filter)
|
||||||
|
@ -687,7 +671,7 @@ gst_d3d11_base_convert_fixate_size (GstBaseTransform * base,
|
||||||
* assume that missing PAR on the sinkpad means 1/1 and
|
* assume that missing PAR on the sinkpad means 1/1 and
|
||||||
* missing PAR on the srcpad means undefined
|
* missing PAR on the srcpad means undefined
|
||||||
*/
|
*/
|
||||||
g_mutex_lock (&self->lock);
|
GstD3D11SRWLockGuard lk (&self->lock);
|
||||||
switch (self->selected_method) {
|
switch (self->selected_method) {
|
||||||
case GST_VIDEO_ORIENTATION_90R:
|
case GST_VIDEO_ORIENTATION_90R:
|
||||||
case GST_VIDEO_ORIENTATION_90L:
|
case GST_VIDEO_ORIENTATION_90L:
|
||||||
|
@ -1140,7 +1124,6 @@ done:
|
||||||
g_value_unset (&fpar);
|
g_value_unset (&fpar);
|
||||||
if (to_par == &tpar)
|
if (to_par == &tpar)
|
||||||
g_value_unset (&tpar);
|
g_value_unset (&tpar);
|
||||||
g_mutex_unlock (&self->lock);
|
|
||||||
|
|
||||||
return othercaps;
|
return othercaps;
|
||||||
}
|
}
|
||||||
|
@ -1465,7 +1448,7 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
|
||||||
gint in_width, in_height, in_par_n, in_par_d;
|
gint in_width, in_height, in_par_n, in_par_d;
|
||||||
GstStructure *config;
|
GstStructure *config;
|
||||||
|
|
||||||
g_mutex_lock (&self->lock);
|
GstD3D11SRWLockGuard lk (&self->lock);
|
||||||
self->active_method = self->selected_method;
|
self->active_method = self->selected_method;
|
||||||
|
|
||||||
if (self->active_method != GST_VIDEO_ORIENTATION_IDENTITY)
|
if (self->active_method != GST_VIDEO_ORIENTATION_IDENTITY)
|
||||||
|
@ -1473,7 +1456,6 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
|
||||||
|
|
||||||
if (!need_flip && gst_caps_is_equal (incaps, outcaps)) {
|
if (!need_flip && gst_caps_is_equal (incaps, outcaps)) {
|
||||||
self->same_caps = TRUE;
|
self->same_caps = TRUE;
|
||||||
g_mutex_unlock (&self->lock);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
self->same_caps = FALSE;
|
self->same_caps = FALSE;
|
||||||
|
@ -1544,7 +1526,6 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
|
||||||
/* if present, these must match */
|
/* if present, these must match */
|
||||||
if (in_info->interlace_mode != out_info->interlace_mode) {
|
if (in_info->interlace_mode != out_info->interlace_mode) {
|
||||||
GST_ERROR_OBJECT (self, "input and output formats do not match");
|
GST_ERROR_OBJECT (self, "input and output formats do not match");
|
||||||
g_mutex_unlock (&self->lock);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1553,7 +1534,6 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
|
||||||
self->borders_h == 0 && !need_flip &&
|
self->borders_h == 0 && !need_flip &&
|
||||||
!gst_d3d11_base_convert_needs_color_convert (self, in_info, out_info)) {
|
!gst_d3d11_base_convert_needs_color_convert (self, in_info, out_info)) {
|
||||||
self->same_caps = TRUE;
|
self->same_caps = TRUE;
|
||||||
g_mutex_unlock (&self->lock);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1567,7 +1547,6 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
|
||||||
config);
|
config);
|
||||||
if (!self->converter) {
|
if (!self->converter) {
|
||||||
GST_ERROR_OBJECT (self, "Couldn't create converter");
|
GST_ERROR_OBJECT (self, "Couldn't create converter");
|
||||||
g_mutex_unlock (&self->lock);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1614,8 +1593,6 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
|
||||||
self->border_color, nullptr);
|
self->border_color, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_unlock (&self->lock);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1923,11 +1900,10 @@ static void
|
||||||
gst_d3d11_base_convert_set_border_color (GstD3D11BaseConvert * self,
|
gst_d3d11_base_convert_set_border_color (GstD3D11BaseConvert * self,
|
||||||
guint64 border_color)
|
guint64 border_color)
|
||||||
{
|
{
|
||||||
g_mutex_lock (&self->lock);
|
GstD3D11SRWLockGuard lk (&self->lock);
|
||||||
self->border_color = border_color;
|
self->border_color = border_color;
|
||||||
if (self->converter)
|
if (self->converter)
|
||||||
g_object_set (self->converter, "border-color", self->border_color, nullptr);
|
g_object_set (self->converter, "border-color", self->border_color, nullptr);
|
||||||
g_mutex_unlock (&self->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1939,7 +1915,7 @@ gst_d3d11_base_convert_set_orientation (GstD3D11BaseConvert * self,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_lock (&self->lock);
|
GstD3D11SRWLockGuard lk (&self->lock);
|
||||||
if (from_tag)
|
if (from_tag)
|
||||||
self->tag_method = method;
|
self->tag_method = method;
|
||||||
else
|
else
|
||||||
|
@ -1957,28 +1933,25 @@ gst_d3d11_base_convert_set_orientation (GstD3D11BaseConvert * self,
|
||||||
|
|
||||||
gst_base_transform_reconfigure_src (GST_BASE_TRANSFORM (self));
|
gst_base_transform_reconfigure_src (GST_BASE_TRANSFORM (self));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_unlock (&self->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_d3d11_base_convert_set_gamma_mode (GstD3D11BaseConvert * self,
|
gst_d3d11_base_convert_set_gamma_mode (GstD3D11BaseConvert * self,
|
||||||
GstVideoGammaMode mode)
|
GstVideoGammaMode mode)
|
||||||
{
|
{
|
||||||
g_mutex_lock (&self->lock);
|
GstD3D11SRWLockGuard lk (&self->lock);
|
||||||
if (self->gamma_mode != mode) {
|
if (self->gamma_mode != mode) {
|
||||||
GST_DEBUG_OBJECT (self, "Gamma mode %d -> %d", self->gamma_mode, mode);
|
GST_DEBUG_OBJECT (self, "Gamma mode %d -> %d", self->gamma_mode, mode);
|
||||||
self->gamma_mode = mode;
|
self->gamma_mode = mode;
|
||||||
gst_base_transform_reconfigure_src (GST_BASE_TRANSFORM (self));
|
gst_base_transform_reconfigure_src (GST_BASE_TRANSFORM (self));
|
||||||
}
|
}
|
||||||
g_mutex_unlock (&self->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_d3d11_base_convert_set_primaries_mode (GstD3D11BaseConvert * self,
|
gst_d3d11_base_convert_set_primaries_mode (GstD3D11BaseConvert * self,
|
||||||
GstVideoPrimariesMode mode)
|
GstVideoPrimariesMode mode)
|
||||||
{
|
{
|
||||||
g_mutex_lock (&self->lock);
|
GstD3D11SRWLockGuard lk (&self->lock);
|
||||||
if (self->primaries_mode != mode) {
|
if (self->primaries_mode != mode) {
|
||||||
gboolean prev_enabled = TRUE;
|
gboolean prev_enabled = TRUE;
|
||||||
gboolean new_enabled = TRUE;
|
gboolean new_enabled = TRUE;
|
||||||
|
@ -1997,7 +1970,6 @@ gst_d3d11_base_convert_set_primaries_mode (GstD3D11BaseConvert * self,
|
||||||
if (prev_enabled != new_enabled)
|
if (prev_enabled != new_enabled)
|
||||||
gst_base_transform_reconfigure_src (GST_BASE_TRANSFORM (self));
|
gst_base_transform_reconfigure_src (GST_BASE_TRANSFORM (self));
|
||||||
}
|
}
|
||||||
g_mutex_unlock (&self->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -159,7 +159,7 @@ struct _GstD3D11Decoder
|
||||||
GstVideoCodecState *output_state;
|
GstVideoCodecState *output_state;
|
||||||
|
|
||||||
/* Protect internal pool */
|
/* Protect internal pool */
|
||||||
GMutex internal_pool_lock;
|
SRWLOCK internal_pool_lock;
|
||||||
|
|
||||||
GstBufferPool *internal_pool;
|
GstBufferPool *internal_pool;
|
||||||
/* Internal pool params */
|
/* Internal pool params */
|
||||||
|
@ -221,7 +221,6 @@ gst_d3d11_decoder_class_init (GstD3D11DecoderClass * klass)
|
||||||
static void
|
static void
|
||||||
gst_d3d11_decoder_init (GstD3D11Decoder * self)
|
gst_d3d11_decoder_init (GstD3D11Decoder * self)
|
||||||
{
|
{
|
||||||
g_mutex_init (&self->internal_pool_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -292,12 +291,11 @@ gst_d3d11_decoder_get_property (GObject * object, guint prop_id,
|
||||||
static void
|
static void
|
||||||
gst_d3d11_decoder_clear_resource (GstD3D11Decoder * self)
|
gst_d3d11_decoder_clear_resource (GstD3D11Decoder * self)
|
||||||
{
|
{
|
||||||
g_mutex_lock (&self->internal_pool_lock);
|
GstD3D11SRWLockGuard lk (&self->internal_pool_lock);
|
||||||
if (self->internal_pool) {
|
if (self->internal_pool) {
|
||||||
gst_buffer_pool_set_active (self->internal_pool, FALSE);
|
gst_buffer_pool_set_active (self->internal_pool, FALSE);
|
||||||
gst_clear_object (&self->internal_pool);
|
gst_clear_object (&self->internal_pool);
|
||||||
}
|
}
|
||||||
g_mutex_unlock (&self->internal_pool_lock);
|
|
||||||
|
|
||||||
GST_D3D11_CLEAR_COM (self->decoder_handle);
|
GST_D3D11_CLEAR_COM (self->decoder_handle);
|
||||||
GST_D3D11_CLEAR_COM (self->staging);
|
GST_D3D11_CLEAR_COM (self->staging);
|
||||||
|
@ -339,16 +337,14 @@ gst_d3d11_decoder_dispose (GObject * obj)
|
||||||
static void
|
static void
|
||||||
gst_d3d11_decoder_finalize (GObject * obj)
|
gst_d3d11_decoder_finalize (GObject * obj)
|
||||||
{
|
{
|
||||||
|
#if HAVE_WINMM
|
||||||
GstD3D11Decoder *self = GST_D3D11_DECODER (obj);
|
GstD3D11Decoder *self = GST_D3D11_DECODER (obj);
|
||||||
|
|
||||||
#if HAVE_WINMM
|
|
||||||
/* Restore clock precision */
|
/* Restore clock precision */
|
||||||
if (self->timer_resolution)
|
if (self->timer_resolution)
|
||||||
timeEndPeriod (self->timer_resolution);
|
timeEndPeriod (self->timer_resolution);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_mutex_clear (&self->internal_pool_lock);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,12 +443,11 @@ gst_d3d11_decoder_prepare_output_view_pool (GstD3D11Decoder * self)
|
||||||
GstVideoInfo *info = &self->info;
|
GstVideoInfo *info = &self->info;
|
||||||
guint pool_size;
|
guint pool_size;
|
||||||
|
|
||||||
g_mutex_lock (&self->internal_pool_lock);
|
GstD3D11SRWLockGuard lk (&self->internal_pool_lock);
|
||||||
if (self->internal_pool) {
|
if (self->internal_pool) {
|
||||||
gst_buffer_pool_set_active (self->internal_pool, FALSE);
|
gst_buffer_pool_set_active (self->internal_pool, FALSE);
|
||||||
gst_clear_object (&self->internal_pool);
|
gst_clear_object (&self->internal_pool);
|
||||||
}
|
}
|
||||||
g_mutex_unlock (&self->internal_pool_lock);
|
|
||||||
|
|
||||||
if (!self->use_array_of_texture) {
|
if (!self->use_array_of_texture) {
|
||||||
alloc_flags = GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY;
|
alloc_flags = GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY;
|
||||||
|
@ -516,9 +511,7 @@ gst_d3d11_decoder_prepare_output_view_pool (GstD3D11Decoder * self)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_lock (&self->internal_pool_lock);
|
|
||||||
self->internal_pool = pool;
|
self->internal_pool = pool;
|
||||||
g_mutex_unlock (&self->internal_pool_lock);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -1860,10 +1853,9 @@ gst_d3d11_decoder_set_flushing (GstD3D11Decoder * decoder,
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GST_IS_D3D11_DECODER (decoder), FALSE);
|
g_return_val_if_fail (GST_IS_D3D11_DECODER (decoder), FALSE);
|
||||||
|
|
||||||
g_mutex_lock (&decoder->internal_pool_lock);
|
GstD3D11SRWLockGuard lk (&decoder->internal_pool_lock);
|
||||||
if (decoder->internal_pool)
|
if (decoder->internal_pool)
|
||||||
gst_buffer_pool_set_flushing (decoder->internal_pool, flushing);
|
gst_buffer_pool_set_flushing (decoder->internal_pool, flushing);
|
||||||
g_mutex_unlock (&decoder->internal_pool_lock);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,8 @@ struct _GstD3D11WindowWin32
|
||||||
{
|
{
|
||||||
GstD3D11Window parent;
|
GstD3D11Window parent;
|
||||||
|
|
||||||
GMutex lock;
|
SRWLOCK lock;
|
||||||
GCond cond;
|
CONDITION_VARIABLE cond;
|
||||||
|
|
||||||
GMainContext *main_context;
|
GMainContext *main_context;
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
|
@ -101,7 +101,6 @@ G_DEFINE_TYPE (GstD3D11WindowWin32, gst_d3d11_window_win32,
|
||||||
|
|
||||||
static void gst_d3d11_window_win32_constructed (GObject * object);
|
static void gst_d3d11_window_win32_constructed (GObject * object);
|
||||||
static void gst_d3d11_window_win32_dispose (GObject * object);
|
static void gst_d3d11_window_win32_dispose (GObject * object);
|
||||||
static void gst_d3d11_window_win32_finalize (GObject * object);
|
|
||||||
|
|
||||||
static void gst_d3d11_window_win32_show (GstD3D11Window * window);
|
static void gst_d3d11_window_win32_show (GstD3D11Window * window);
|
||||||
static void gst_d3d11_window_win32_update_swap_chain (GstD3D11Window * window);
|
static void gst_d3d11_window_win32_update_swap_chain (GstD3D11Window * window);
|
||||||
|
@ -140,7 +139,6 @@ gst_d3d11_window_win32_class_init (GstD3D11WindowWin32Class * klass)
|
||||||
|
|
||||||
gobject_class->constructed = gst_d3d11_window_win32_constructed;
|
gobject_class->constructed = gst_d3d11_window_win32_constructed;
|
||||||
gobject_class->dispose = gst_d3d11_window_win32_dispose;
|
gobject_class->dispose = gst_d3d11_window_win32_dispose;
|
||||||
gobject_class->finalize = gst_d3d11_window_win32_finalize;
|
|
||||||
|
|
||||||
window_class->show = GST_DEBUG_FUNCPTR (gst_d3d11_window_win32_show);
|
window_class->show = GST_DEBUG_FUNCPTR (gst_d3d11_window_win32_show);
|
||||||
window_class->update_swap_chain =
|
window_class->update_swap_chain =
|
||||||
|
@ -163,9 +161,6 @@ gst_d3d11_window_win32_class_init (GstD3D11WindowWin32Class * klass)
|
||||||
static void
|
static void
|
||||||
gst_d3d11_window_win32_init (GstD3D11WindowWin32 * self)
|
gst_d3d11_window_win32_init (GstD3D11WindowWin32 * self)
|
||||||
{
|
{
|
||||||
g_mutex_init (&self->lock);
|
|
||||||
g_cond_init (&self->cond);
|
|
||||||
|
|
||||||
self->main_context = g_main_context_new ();
|
self->main_context = g_main_context_new ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,13 +175,13 @@ gst_d3d11_window_win32_constructed (GObject * object)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_lock (&self->lock);
|
AcquireSRWLockExclusive (&self->lock);
|
||||||
self->loop = g_main_loop_new (self->main_context, FALSE);
|
self->loop = g_main_loop_new (self->main_context, FALSE);
|
||||||
self->thread = g_thread_new ("GstD3D11WindowWin32",
|
self->thread = g_thread_new ("GstD3D11WindowWin32",
|
||||||
(GThreadFunc) gst_d3d11_window_win32_thread_func, self);
|
(GThreadFunc) gst_d3d11_window_win32_thread_func, self);
|
||||||
while (!g_main_loop_is_running (self->loop))
|
while (!g_main_loop_is_running (self->loop))
|
||||||
g_cond_wait (&self->cond, &self->lock);
|
SleepConditionVariableSRW (&self->cond, &self->lock, INFINITE, 0);
|
||||||
g_mutex_unlock (&self->lock);
|
ReleaseSRWLockExclusive (&self->lock);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
G_OBJECT_CLASS (parent_class)->constructed (object);
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
||||||
|
@ -299,17 +294,6 @@ gst_d3d11_window_win32_set_title (GstD3D11Window * window, const gchar * title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gst_d3d11_window_win32_finalize (GObject * object)
|
|
||||||
{
|
|
||||||
GstD3D11WindowWin32 *self = GST_D3D11_WINDOW_WIN32 (object);
|
|
||||||
|
|
||||||
g_mutex_clear (&self->lock);
|
|
||||||
g_cond_clear (&self->cond);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
running_cb (gpointer user_data)
|
running_cb (gpointer user_data)
|
||||||
{
|
{
|
||||||
|
@ -317,9 +301,9 @@ running_cb (gpointer user_data)
|
||||||
|
|
||||||
GST_TRACE_OBJECT (self, "Main loop running now");
|
GST_TRACE_OBJECT (self, "Main loop running now");
|
||||||
|
|
||||||
g_mutex_lock (&self->lock);
|
AcquireSRWLockExclusive (&self->lock);
|
||||||
g_cond_signal (&self->cond);
|
WakeConditionVariable (&self->cond);
|
||||||
g_mutex_unlock (&self->lock);
|
ReleaseSRWLockExclusive (&self->lock);
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
@ -834,7 +818,7 @@ sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
MoveWindow (self->internal_hwnd, 0, 0, LOWORD (lParam), HIWORD (lParam),
|
MoveWindow (self->internal_hwnd, 0, 0, LOWORD (lParam), HIWORD (lParam),
|
||||||
FALSE);
|
FALSE);
|
||||||
} else if (uMsg == WM_CLOSE || uMsg == WM_DESTROY) {
|
} else if (uMsg == WM_CLOSE || uMsg == WM_DESTROY) {
|
||||||
g_mutex_lock (&self->lock);
|
GstD3D11SRWLockGuard lk (&self->lock);
|
||||||
GST_WARNING_OBJECT (self, "external window is closing");
|
GST_WARNING_OBJECT (self, "external window is closing");
|
||||||
gst_d3d11_window_win32_release_external_handle (self->external_hwnd);
|
gst_d3d11_window_win32_release_external_handle (self->external_hwnd);
|
||||||
self->external_hwnd = NULL;
|
self->external_hwnd = NULL;
|
||||||
|
@ -846,7 +830,6 @@ sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
self->internal_hwnd_thread = NULL;
|
self->internal_hwnd_thread = NULL;
|
||||||
|
|
||||||
self->overlay_state = GST_D3D11_WINDOW_WIN32_OVERLAY_STATE_CLOSED;
|
self->overlay_state = GST_D3D11_WINDOW_WIN32_OVERLAY_STATE_CLOSED;
|
||||||
g_mutex_unlock (&self->lock);
|
|
||||||
} else {
|
} else {
|
||||||
gst_d3d11_window_win32_handle_window_proc (self, hWnd, uMsg, wParam,
|
gst_d3d11_window_win32_handle_window_proc (self, hWnd, uMsg, wParam,
|
||||||
lParam);
|
lParam);
|
||||||
|
|
Loading…
Reference in a new issue