GstD3D11DeinterlaceMethod method;
- GRecMutex lock;
+ CRITICAL_SECTION lock;
GQueue past_frame_queue;
GQueue future_frame_queue;
GstBuffer *to_process;
#define GST_D3D11_DEINTERLACE_GET_CLASS(object) \
(G_TYPE_INSTANCE_GET_CLASS ((object),G_TYPE_FROM_INSTANCE (object), \
GstD3D11DeinterlaceClass))
-#define GST_D3D11_DEINTERLACE_LOCK(self) \
- g_rec_mutex_lock (&GST_D3D11_DEINTERLACE (self)->lock);
-#define GST_D3D11_DEINTERLACE_UNLOCK(self) \
- g_rec_mutex_unlock (&GST_D3D11_DEINTERLACE (self)->lock);
static gboolean
gst_d3d11_deinterlace_update_method (GstD3D11Deinterlace * self);
g_queue_init (&self->past_frame_queue);
g_queue_init (&self->future_frame_queue);
- g_rec_mutex_init (&self->lock);
+ InitializeCriticalSection (&self->lock);
}
static void
{
GstD3D11Deinterlace *self = GST_D3D11_DEINTERLACE (object);
- g_rec_mutex_clear (&self->lock);
+ DeleteCriticalSection (&self->lock);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gst_d3d11_deinterlace_reset (GstD3D11Deinterlace * self)
{
- GST_D3D11_DEINTERLACE_LOCK (self);
+ GstD3D11CSLockGuard lk (&self->lock);
+
if (self->fallback_in_pool) {
gst_buffer_pool_set_active (self->fallback_in_pool, FALSE);
gst_object_unref (self->fallback_in_pool);
gst_d3d11_deinterlace_reset_history (self);
self->default_buffer_duration = GST_CLOCK_TIME_NONE;
-
- GST_D3D11_DEINTERLACE_UNLOCK (self);
}
static void
gst_d3d11_deinterlace_drain (self);
break;
case GST_EVENT_FLUSH_STOP:
- GST_D3D11_DEINTERLACE_LOCK (self);
+ EnterCriticalSection (&self->lock);
gst_d3d11_deinterlace_reset_history (self);
- GST_D3D11_DEINTERLACE_UNLOCK (self);
+ LeaveCriticalSection (&self->lock);
break;
default:
break;
GstFlowReturn ret = GST_FLOW_OK;
GstBuffer *outbuf = NULL;
- GST_D3D11_DEINTERLACE_LOCK (self);
+ EnterCriticalSection (&self->lock);
+
if (gst_base_transform_is_passthrough (trans)) {
/* If we were passthrough, nothing to do */
goto done;
ret = gst_d3d11_deinterlace_generate_output (trans, &outbuf);
if (outbuf != NULL) {
/* Release lock during push buffer */
- GST_D3D11_DEINTERLACE_UNLOCK (self);
+ LeaveCriticalSection (&self->lock);
ret = gst_pad_push (trans->srcpad, outbuf);
- GST_D3D11_DEINTERLACE_LOCK (self);
+ EnterCriticalSection (&self->lock);
}
} while (ret == GST_FLOW_OK && outbuf != NULL);
}
done:
gst_d3d11_deinterlace_reset_history (self);
- GST_D3D11_DEINTERLACE_UNLOCK (self);
+ LeaveCriticalSection (&self->lock);
return ret;
}
gboolean prepared;
gint64 adapter_luid;
- GRecMutex lock;
+ CRITICAL_SECTION lock;
};
static void gst_d3d11_screen_capture_constructed (GObject * object);
static void
gst_d3d11_screen_capture_init (GstD3D11ScreenCapture * self)
{
- g_rec_mutex_init (&self->lock);
+ InitializeCriticalSection (&self->lock);
memset (&self->desktop_coordinates, 0, sizeof (RECT));
}
{
GstD3D11ScreenCapture *self = GST_D3D11_SCREEN_CAPTURE (object);
- g_rec_mutex_clear (&self->lock);
+ DeleteCriticalSection (&self->lock);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
g_return_val_if_fail (GST_IS_D3D11_SCREEN_CAPTURE (capture), GST_FLOW_ERROR);
g_return_val_if_fail (capture->device != nullptr, GST_FLOW_ERROR);
- g_rec_mutex_lock (&capture->lock);
+ GstD3D11CSLockGuard lk (&capture->lock);
+
if (capture->prepared) {
GST_DEBUG_OBJECT (capture, "Already prepared");
- g_rec_mutex_unlock (&capture->lock);
return GST_FLOW_OK;
}
delete capture->dupl_obj;
capture->dupl_obj = nullptr;
- g_rec_mutex_unlock (&capture->lock);
return ret;
}
capture->prepared = TRUE;
- g_rec_mutex_unlock (&capture->lock);
return GST_FLOW_OK;
}
g_return_val_if_fail (width != nullptr, FALSE);
g_return_val_if_fail (height != nullptr, FALSE);
- g_rec_mutex_lock (&capture->lock);
+ GstD3D11CSLockGuard lk (&capture->lock);
*width = 0;
*height = 0;
*width = capture->cached_width;
*height = capture->cached_height;
- g_rec_mutex_unlock (&capture->lock);
return TRUE;
}
shared_device = TRUE;
}
- g_rec_mutex_lock (&capture->lock);
+ GstD3D11CSLockGuard lk (&capture->lock);
if (!capture->prepared)
ret = gst_d3d11_screen_capture_prepare (capture);
if (ret != GST_FLOW_OK) {
GST_WARNING_OBJECT (capture, "We are not prepared");
- g_rec_mutex_unlock (&capture->lock);
return ret;
}
"Capture area (%u, %u, %u, %u) doesn't fit into screen size %ux%u",
crop_box->left, crop_box->right, crop_box->top,
crop_box->bottom, width, height);
- g_rec_mutex_unlock (&capture->lock);
return GST_D3D11_SCREEN_CAPTURE_FLOW_SIZE_CHANGED;
}
GST_ERROR_OBJECT (capture, "Unexpected failure during capture");
}
- g_rec_mutex_unlock (&capture->lock);
return ret;
}
gst_d3d11_device_unlock (device);
gst_d3d11_device_unlock (capture->device);
- g_rec_mutex_unlock (&capture->lock);
return ret;
}
/* For drawing on user texture */
gboolean drawing;
GstBuffer *current_buffer;
- GRecMutex lock;
+ CRITICAL_SECTION lock;
gchar *title;
GstVideoOrientationMethod selected_method;
};
-#define GST_D3D11_VIDEO_SINK_GET_LOCK(d) (&(GST_D3D11_VIDEO_SINK_CAST(d)->lock))
-#define GST_D3D11_VIDEO_SINK_LOCK(d) G_STMT_START { \
- GST_TRACE_OBJECT (d, "Locking from thread %p", g_thread_self()); \
- g_rec_mutex_lock (GST_D3D11_VIDEO_SINK_GET_LOCK (d)); \
- GST_TRACE_OBJECT (d, "Locked from thread %p", g_thread_self()); \
- } G_STMT_END
-
-#define GST_D3D11_VIDEO_SINK_UNLOCK(d) G_STMT_START { \
- GST_TRACE_OBJECT (d, "Unlocking from thread %p", g_thread_self()); \
- g_rec_mutex_unlock (GST_D3D11_VIDEO_SINK_GET_LOCK (d)); \
- } G_STMT_END
-
static void gst_d3d11_videosink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_d3d11_videosink_get_property (GObject * object, guint prop_id,
self->gamma_mode = DEFAULT_GAMMA_MODE;
self->primaries_mode = DEFAULT_PRIMARIES_MODE;
- g_rec_mutex_init (&self->lock);
+ InitializeCriticalSection (&self->lock);
}
static void
const GValue * value, GParamSpec * pspec)
{
GstD3D11VideoSink *self = GST_D3D11_VIDEO_SINK (object);
+ GstD3D11CSLockGuard lk (&self->lock);
- GST_D3D11_VIDEO_SINK_LOCK (self);
switch (prop_id) {
case PROP_ADAPTER:
self->adapter = g_value_get_int (value);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
}
static void
GValue * value, GParamSpec * pspec)
{
GstD3D11VideoSink *self = GST_D3D11_VIDEO_SINK (object);
+ GstD3D11CSLockGuard lk (&self->lock);
- GST_D3D11_VIDEO_SINK_LOCK (self);
switch (prop_id) {
case PROP_ADAPTER:
g_value_set_int (value, self->adapter);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
}
static void
{
GstD3D11VideoSink *self = GST_D3D11_VIDEO_SINK (object);
- g_rec_mutex_clear (&self->lock);
+ DeleteCriticalSection (&self->lock);
g_free (self->title);
G_OBJECT_CLASS (parent_class)->finalize (object);
self->caps_updated = FALSE;
- GST_D3D11_VIDEO_SINK_LOCK (self);
+ EnterCriticalSection (&self->lock);
if (!gst_d3d11_video_sink_prepare_window (self)) {
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
+ LeaveCriticalSection (&self->lock);
GST_ELEMENT_ERROR (self, RESOURCE, NOT_FOUND, (nullptr),
("Failed to open window."));
if (!gst_video_info_from_caps (&self->info, caps)) {
GST_DEBUG_OBJECT (self,
"Could not locate image format from caps %" GST_PTR_FORMAT, caps);
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
+ LeaveCriticalSection (&self->lock);
return FALSE;
}
if (!gst_video_calculate_display_ratio (&num, &den, video_width,
video_height, video_par_n, video_par_d, display_par_n,
display_par_d)) {
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
+ LeaveCriticalSection (&self->lock);
GST_ELEMENT_ERROR (self, CORE, NEGOTIATION, (nullptr),
("Error calculating the output display ratio of the video."));
self->video_height = video_height;
if (GST_VIDEO_SINK_WIDTH (self) <= 0 || GST_VIDEO_SINK_HEIGHT (self) <= 0) {
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
+ LeaveCriticalSection (&self->lock);
GST_ELEMENT_ERROR (self, CORE, NEGOTIATION, (nullptr),
("Error calculating the output display ratio of the video."));
GST_VIDEO_SINK_HEIGHT (self), caps, config, &error)) {
GstMessage *error_msg;
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
+ LeaveCriticalSection (&self->lock);
GST_ERROR_OBJECT (self, "cannot create swapchain");
error_msg = gst_message_new_error (GST_OBJECT_CAST (self),
g_clear_pointer (&self->title, g_free);
}
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
+ LeaveCriticalSection (&self->lock);
return TRUE;
}
gst_d3d11_video_sink_stop (GstBaseSink * sink)
{
GstD3D11VideoSink *self = GST_D3D11_VIDEO_SINK (sink);
+ GstD3D11CSLockGuard lk (&self->lock);
GST_DEBUG_OBJECT (self, "Stop");
- GST_D3D11_VIDEO_SINK_LOCK (self);
if (self->window)
gst_d3d11_window_unprepare (self->window);
gst_clear_object (&self->window);
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
-
gst_clear_object (&self->device);
-
g_clear_pointer (&self->title, g_free);
return TRUE;
gst_d3d11_video_sink_unlock (GstBaseSink * sink)
{
GstD3D11VideoSink *self = GST_D3D11_VIDEO_SINK (sink);
+ GstD3D11CSLockGuard lk (&self->lock);
- GST_D3D11_VIDEO_SINK_LOCK (self);
if (self->window)
gst_d3d11_window_unlock (self->window);
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
return TRUE;
}
gst_d3d11_video_sink_unlock_stop (GstBaseSink * sink)
{
GstD3D11VideoSink *self = GST_D3D11_VIDEO_SINK (sink);
+ GstD3D11CSLockGuard lk (&self->lock);
- GST_D3D11_VIDEO_SINK_LOCK (self);
if (self->window)
gst_d3d11_window_unlock_stop (self->window);
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
return TRUE;
}
if (title) {
const gchar *app_name = g_get_application_name ();
std::string title_string;
+ GstD3D11CSLockGuard lk (&self->lock);
if (app_name) {
title_string = std::string (title) + " : " + std::string (app_name);
title_string = std::string (title);
}
- GST_D3D11_VIDEO_SINK_LOCK (self);
if (self->window) {
gst_d3d11_window_set_title (self->window, title_string.c_str ());
} else {
g_free (self->title);
self->title = g_strdup (title_string.c_str ());
}
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
g_free (title);
}
if (gst_video_orientation_from_tag (taglist, &method)) {
- GST_D3D11_VIDEO_SINK_LOCK (self);
+ GstD3D11CSLockGuard lk (&self->lock);
gst_d3d11_video_sink_set_orientation (self, method, TRUE);
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
}
break;
}
gst_d3d11_window_show (self->window);
if (self->draw_on_shared_texture) {
- GST_D3D11_VIDEO_SINK_LOCK (self);
+ GstD3D11CSLockGuard lk (&self->lock);
+
self->current_buffer = buf;
self->drawing = TRUE;
GST_LOG_OBJECT (self, "End drawing");
self->drawing = FALSE;
self->current_buffer = nullptr;
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
} else {
ret = gst_d3d11_window_render (self->window, buf);
}
gint y, gint width, gint height)
{
GstD3D11VideoSink *self = GST_D3D11_VIDEO_SINK (overlay);
+ GstD3D11CSLockGuard lk (&self->lock);
GST_DEBUG_OBJECT (self,
"render rect x: %d, y: %d, width: %d, height %d", x, y, width, height);
- GST_D3D11_VIDEO_SINK_LOCK (self);
if (self->window) {
GstVideoRectangle rect;
self->render_rect.h = height;
self->pending_render_rect = TRUE;
}
-
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
}
static void
gst_d3d11_video_sink_expose (GstVideoOverlay * overlay)
{
GstD3D11VideoSink *self = GST_D3D11_VIDEO_SINK (overlay);
+ GstD3D11CSLockGuard lk (&self->lock);
- GST_D3D11_VIDEO_SINK_LOCK (self);
if (self->window && self->window->swap_chain)
gst_d3d11_window_render (self->window, nullptr);
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
}
static void
return FALSE;
}
- GST_D3D11_VIDEO_SINK_LOCK (self);
+ GstD3D11CSLockGuard lk (&self->lock);
if (!self->drawing || !self->current_buffer) {
GST_WARNING_OBJECT (self, "Nothing to draw");
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
return FALSE;
}
ret = gst_d3d11_window_render_on_shared_handle (self->window,
self->current_buffer, shared_handle, texture_misc_flags, acquire_key,
release_key);
- GST_D3D11_VIDEO_SINK_UNLOCK (self);
return ret == GST_FLOW_OK;
}