d3dvideosink: use class lock when creating overlay textures
This commit is contained in:
parent
51f823c98a
commit
52254ad31c
@ -181,11 +181,13 @@ _is_overlay_in_composition (GstVideoOverlayComposition * composition,
|
||||
GstFlowReturn
|
||||
gst_d3d9_overlay_prepare (GstD3DVideoSink * sink, GstBuffer * buf)
|
||||
{
|
||||
GstD3DVideoSinkClass *klass = GST_D3DVIDEOSINK_GET_CLASS (sink);
|
||||
GList *l = NULL;
|
||||
GstVideoOverlayComposition *composition = NULL;
|
||||
guint num_overlays, i;
|
||||
GstVideoOverlayCompositionMeta *composition_meta =
|
||||
gst_buffer_get_video_overlay_composition_meta (buf);
|
||||
gboolean found_new_overlay_rectangle = FALSE;
|
||||
|
||||
if (!composition_meta) {
|
||||
gst_d3d9_overlay_free (sink);
|
||||
@ -197,13 +199,32 @@ gst_d3d9_overlay_prepare (GstD3DVideoSink * sink, GstBuffer * buf)
|
||||
|
||||
GST_DEBUG_OBJECT (sink, "GstVideoOverlayCompositionMeta found.");
|
||||
|
||||
/* add new overlays to list */
|
||||
/* check for new overlays */
|
||||
for (i = 0; i < num_overlays; i++) {
|
||||
GstVideoOverlayRectangle *rectangle =
|
||||
gst_video_overlay_composition_get_rectangle (composition, i);
|
||||
|
||||
if (!_is_rectangle_in_overlays (sink->d3d.overlay, rectangle)) {
|
||||
found_new_overlay_rectangle = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* add new overlays to list */
|
||||
if (found_new_overlay_rectangle) {
|
||||
GST_DEBUG_OBJECT (sink, "New overlay composition rectangles found.");
|
||||
LOCK_CLASS (sink, klass);
|
||||
if (!klass->d3d.refs) {
|
||||
GST_ERROR_OBJECT (sink, "Direct3D object ref count = 0");
|
||||
gst_d3d9_overlay_free (sink);
|
||||
UNLOCK_CLASS (sink, klass);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
for (i = 0; i < num_overlays; i++) {
|
||||
GstVideoOverlayRectangle *rectangle =
|
||||
gst_video_overlay_composition_get_rectangle (composition, i);
|
||||
|
||||
if (!_is_rectangle_in_overlays (sink->d3d.overlay, rectangle)) {
|
||||
GstD3DVideoSinkClass *klass = GST_D3DVIDEOSINK_GET_CLASS (sink);
|
||||
GstVideoOverlayFormatFlags flags;
|
||||
gint x, y;
|
||||
guint width, height;
|
||||
@ -265,6 +286,8 @@ gst_d3d9_overlay_prepare (GstD3DVideoSink * sink, GstBuffer * buf)
|
||||
sink->d3d.overlay = g_list_append (sink->d3d.overlay, overlay);
|
||||
}
|
||||
}
|
||||
UNLOCK_CLASS (sink, klass);
|
||||
}
|
||||
/* remove old overlays from list */
|
||||
while (l != NULL) {
|
||||
GList *next = l->next;
|
||||
|
Loading…
x
Reference in New Issue
Block a user