diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2016-09-19 12:04:52 -0400 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2016-09-21 11:02:40 -0400 |
commit | 94a565269414dcae6a33c847298ab33cb50efd00 (patch) | |
tree | a260e0ba6a9b455743d36097a00091123e130337 | |
parent | 1c81b0bb6ef7b791f11ed7b75fb31ed60c58ba8b (diff) |
waylandsink: Factor-out the pool creation
-rw-r--r-- | ext/wayland/gstwaylandsink.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index 048b7da629..d368a06784 100644 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -426,6 +426,28 @@ gst_wayland_sink_get_caps (GstBaseSink * bsink, GstCaps * filter) return caps; } +static GstBufferPool * +gst_wayland_create_pool (GstWaylandSink * sink, GstCaps * caps) +{ + GstBufferPool *pool = NULL; + GstStructure *structure; + gsize size = sink->video_info.size; + + pool = gst_video_buffer_pool_new (); + + 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); + + if (!gst_buffer_pool_set_config (pool, structure)) { + g_object_unref (pool); + pool = NULL; + } + + return pool; +} + static gboolean gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps) { @@ -435,7 +457,6 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps) enum wl_shm_format format; GArray *formats; gint i; - GstStructure *structure; sink = GST_WAYLAND_SINK (bsink); @@ -459,21 +480,15 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps) if (i >= formats->len) goto unsupported_format; + /* store the video info */ + sink->video_info = info; + sink->video_info_changed = TRUE; + /* create a new pool for the new configuration */ - newpool = gst_video_buffer_pool_new (); + newpool = gst_wayland_create_pool (sink, caps); if (!newpool) goto pool_failed; - structure = gst_buffer_pool_get_config (newpool); - gst_buffer_pool_config_set_params (structure, caps, info.size, 2, 0); - gst_buffer_pool_config_set_allocator (structure, gst_wl_shm_allocator_get (), - NULL); - if (!gst_buffer_pool_set_config (newpool, structure)) - goto config_failed; - - /* store the video info */ - sink->video_info = info; - sink->video_info_changed = TRUE; gst_object_replace ((GstObject **) & sink->pool, (GstObject *) newpool); gst_object_unref (newpool); @@ -494,13 +509,7 @@ unsupported_format: } pool_failed: { - GST_DEBUG_OBJECT (sink, "Failed to create new pool"); - return FALSE; - } -config_failed: - { - GST_DEBUG_OBJECT (bsink, "failed setting config"); - gst_object_unref (newpool); + GST_ERROR_OBJECT (sink, "Failed to create new pool"); return FALSE; } } |