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:
Shinya Saito 2017-11-01 18:05:26 +09:00 committed by Nicolas Dufresne
parent 77321f62dd
commit 816d115317
2 changed files with 12 additions and 3 deletions

View file

@ -494,18 +494,20 @@ gst_wayland_create_pool (GstWaylandSink * sink, GstCaps * caps)
GstBufferPool *pool = NULL;
GstStructure *structure;
gsize size = sink->video_info.size;
GstAllocator *alloc;
pool = g_object_new (gst_wayland_pool_get_type (), NULL);
structure = gst_buffer_pool_get_config (pool);
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)) {
g_object_unref (pool);
pool = NULL;
}
g_object_unref (alloc);
return pool;
}
@ -569,6 +571,7 @@ gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
GstCaps *caps;
GstBufferPool *pool = NULL;
gboolean need_pool;
GstAllocator *alloc;
gst_query_parse_allocation (query, &caps, &need_pool);
@ -579,8 +582,10 @@ gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
if (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_meta (query, GST_VIDEO_META_API_TYPE, NULL);
g_object_unref (alloc);
return TRUE;
}

View file

@ -332,6 +332,7 @@ gst_wl_window_update_borders (GstWlWindow * window)
GstBuffer *buf;
struct wl_buffer *wlbuf;
GstWlBuffer *gwlbuf;
GstAllocator *alloc;
if (window->no_border_update)
return;
@ -354,7 +355,9 @@ gst_wl_window_update_borders (GstWlWindow * window)
/* draw the area_subsurface */
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);
wlbuf =
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
* alive and will free it on wl_buffer::release */
gst_buffer_unref (buf);
g_object_unref (alloc);
}
void