mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
waylandsink: Fix memory leak of shm allocator.
gst_allocator_find() needs gst_object_unref() after usage. https://bugzilla.gnome.org/show_bug.cgi?id=790042
This commit is contained in:
parent
77321f62dd
commit
816d115317
2 changed files with 12 additions and 3 deletions
|
@ -494,18 +494,20 @@ gst_wayland_create_pool (GstWaylandSink * sink, GstCaps * caps)
|
||||||
GstBufferPool *pool = NULL;
|
GstBufferPool *pool = NULL;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
gsize size = sink->video_info.size;
|
gsize size = sink->video_info.size;
|
||||||
|
GstAllocator *alloc;
|
||||||
|
|
||||||
pool = g_object_new (gst_wayland_pool_get_type (), NULL);
|
pool = g_object_new (gst_wayland_pool_get_type (), NULL);
|
||||||
|
|
||||||
structure = gst_buffer_pool_get_config (pool);
|
structure = gst_buffer_pool_get_config (pool);
|
||||||
gst_buffer_pool_config_set_params (structure, caps, size, 2, 0);
|
gst_buffer_pool_config_set_params (structure, caps, size, 2, 0);
|
||||||
gst_buffer_pool_config_set_allocator (structure, gst_wl_shm_allocator_get (),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
|
alloc = gst_wl_shm_allocator_get ();
|
||||||
|
gst_buffer_pool_config_set_allocator (structure, alloc, NULL);
|
||||||
if (!gst_buffer_pool_set_config (pool, structure)) {
|
if (!gst_buffer_pool_set_config (pool, structure)) {
|
||||||
g_object_unref (pool);
|
g_object_unref (pool);
|
||||||
pool = NULL;
|
pool = NULL;
|
||||||
}
|
}
|
||||||
|
g_object_unref (alloc);
|
||||||
|
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
@ -569,6 +571,7 @@ gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstBufferPool *pool = NULL;
|
GstBufferPool *pool = NULL;
|
||||||
gboolean need_pool;
|
gboolean need_pool;
|
||||||
|
GstAllocator *alloc;
|
||||||
|
|
||||||
gst_query_parse_allocation (query, &caps, &need_pool);
|
gst_query_parse_allocation (query, &caps, &need_pool);
|
||||||
|
|
||||||
|
@ -579,8 +582,10 @@ gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
|
||||||
if (pool)
|
if (pool)
|
||||||
g_object_unref (pool);
|
g_object_unref (pool);
|
||||||
|
|
||||||
|
alloc = gst_wl_shm_allocator_get ();
|
||||||
gst_query_add_allocation_param (query, gst_wl_shm_allocator_get (), NULL);
|
gst_query_add_allocation_param (query, gst_wl_shm_allocator_get (), NULL);
|
||||||
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
|
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
|
||||||
|
g_object_unref (alloc);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,6 +332,7 @@ gst_wl_window_update_borders (GstWlWindow * window)
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
struct wl_buffer *wlbuf;
|
struct wl_buffer *wlbuf;
|
||||||
GstWlBuffer *gwlbuf;
|
GstWlBuffer *gwlbuf;
|
||||||
|
GstAllocator *alloc;
|
||||||
|
|
||||||
if (window->no_border_update)
|
if (window->no_border_update)
|
||||||
return;
|
return;
|
||||||
|
@ -354,7 +355,9 @@ gst_wl_window_update_borders (GstWlWindow * window)
|
||||||
/* draw the area_subsurface */
|
/* draw the area_subsurface */
|
||||||
gst_video_info_set_format (&info, format, width, height);
|
gst_video_info_set_format (&info, format, width, height);
|
||||||
|
|
||||||
buf = gst_buffer_new_allocate (gst_wl_shm_allocator_get (), info.size, NULL);
|
alloc = gst_wl_shm_allocator_get ();
|
||||||
|
|
||||||
|
buf = gst_buffer_new_allocate (alloc, info.size, NULL);
|
||||||
gst_buffer_memset (buf, 0, 0, info.size);
|
gst_buffer_memset (buf, 0, 0, info.size);
|
||||||
wlbuf =
|
wlbuf =
|
||||||
gst_wl_shm_memory_construct_wl_buffer (gst_buffer_peek_memory (buf, 0),
|
gst_wl_shm_memory_construct_wl_buffer (gst_buffer_peek_memory (buf, 0),
|
||||||
|
@ -365,6 +368,7 @@ gst_wl_window_update_borders (GstWlWindow * window)
|
||||||
/* at this point, the GstWlBuffer keeps the buffer
|
/* at this point, the GstWlBuffer keeps the buffer
|
||||||
* alive and will free it on wl_buffer::release */
|
* alive and will free it on wl_buffer::release */
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
g_object_unref (alloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue