glfilter: Don't chain downstream pool

Chaining a downstream pool would lead to two owner of the same
pool. In dynamic pipeline, if one owner is removed from the pipeline
the pool will be stopped, and the rest of the pipeline will fail
since the pool will now be flushing. Also fix proposed pool caching,
filter->pool was never set, never unrefed.

https://bugzilla.gnome.org/show_bug.cgi?id=745705
This commit is contained in:
Nicolas Dufresne 2015-03-05 16:28:36 -05:00
parent fb4d769425
commit 7a3b34de79

View file

@ -268,6 +268,11 @@ gst_gl_filter_reset (GstGLFilter * filter)
filter->uploaded_buffer = NULL; filter->uploaded_buffer = NULL;
} }
if (filter->pool) {
gst_object_unref (filter->pool);
filter->pool = NULL;
}
if (filter->context) { if (filter->context) {
if (filter_class->onReset) if (filter_class->onReset)
filter_class->onReset (filter); filter_class->onReset (filter);
@ -276,7 +281,7 @@ gst_gl_filter_reset (GstGLFilter * filter)
gst_gl_context_thread_add (filter->context, gst_gl_filter_stop_gl, gst_gl_context_thread_add (filter->context, gst_gl_filter_stop_gl,
filter); filter);
} }
//blocking call, delete the FBO /* blocking call, delete the FBO */
if (filter->fbo != 0) { if (filter->fbo != 0) {
gst_gl_context_del_fbo (filter->context, filter->fbo, gst_gl_context_del_fbo (filter->context, filter->fbo,
filter->depthbuffer); filter->depthbuffer);
@ -907,9 +912,8 @@ gst_gl_filter_propose_allocation (GstBaseTransform * trans,
GstQuery * decide_query, GstQuery * query) GstQuery * decide_query, GstQuery * query)
{ {
GstGLFilter *filter = GST_GL_FILTER (trans); GstGLFilter *filter = GST_GL_FILTER (trans);
GstBufferPool *pool;
GstStructure *config; GstStructure *config;
GstCaps *caps, *decide_caps; GstCaps *caps;
guint size; guint size;
gboolean need_pool; gboolean need_pool;
@ -918,64 +922,44 @@ gst_gl_filter_propose_allocation (GstBaseTransform * trans,
if (caps == NULL) if (caps == NULL)
goto no_caps; goto no_caps;
if ((pool = filter->pool)) if (need_pool) {
gst_object_ref (pool); if (filter->pool) {
GstCaps *pcaps;
if (pool != NULL) { /* we had a pool, check caps */
GstCaps *pcaps; GST_DEBUG_OBJECT (filter, "check existing pool caps");
config = gst_buffer_pool_get_config (filter->pool);
gst_buffer_pool_config_get_params (config, &pcaps, &size, NULL, NULL);
/* we had a pool, check caps */ if (!gst_caps_is_equal (caps, pcaps)) {
GST_DEBUG_OBJECT (filter, "check existing pool caps"); GST_DEBUG_OBJECT (filter, "pool has different caps");
config = gst_buffer_pool_get_config (pool); /* different caps, we can't use this pool */
gst_buffer_pool_config_get_params (config, &pcaps, &size, NULL, NULL); gst_object_unref (filter->pool);
filter->pool = NULL;
if (!gst_caps_is_equal (caps, pcaps)) { }
GST_DEBUG_OBJECT (filter, "pool has different caps");
/* different caps, we can't use this pool */
gst_object_unref (pool);
pool = NULL;
}
gst_structure_free (config);
}
if (pool == NULL && need_pool) {
GstVideoInfo info;
GstBufferPool *decide_pool = NULL;
if (!gst_video_info_from_caps (&info, caps))
goto invalid_caps;
if (decide_query) {
gst_query_parse_allocation (decide_query, &decide_caps, NULL);
decide_pool = gst_base_transform_get_buffer_pool (trans);
}
if (decide_pool && GST_IS_GL_BUFFER_POOL (decide_pool)
&& gst_caps_is_equal_fixed (decide_caps, caps)) {
config = gst_buffer_pool_get_config (decide_pool);
gst_buffer_pool_config_get_params (config, NULL, &size, NULL, NULL);
gst_structure_free (config); gst_structure_free (config);
}
pool = decide_pool; if (filter->pool == NULL) {
} else { GstVideoInfo info;
GST_DEBUG_OBJECT (filter, "create new pool");
if (decide_pool) if (!gst_video_info_from_caps (&info, caps))
gst_object_unref (decide_pool); goto invalid_caps;
pool = gst_gl_buffer_pool_new (filter->context);
/* the normal size of a frame */ /* the normal size of a frame */
size = info.size; size = info.size;
config = gst_buffer_pool_get_config (pool); GST_DEBUG_OBJECT (filter, "create new pool");
filter->pool = gst_gl_buffer_pool_new (filter->context);
config = gst_buffer_pool_get_config (filter->pool);
gst_buffer_pool_config_set_params (config, caps, size, 0, 0); gst_buffer_pool_config_set_params (config, caps, size, 0, 0);
if (!gst_buffer_pool_set_config (pool, config))
if (!gst_buffer_pool_set_config (filter->pool, config))
goto config_failed; goto config_failed;
} }
}
/* we need at least 2 buffer because we hold on to the last one */ gst_query_add_allocation_pool (query, filter->pool, size, 1, 0);
if (pool) {
gst_query_add_allocation_pool (query, pool, size, 1, 0);
gst_object_unref (pool);
} }
if (!_ensure_input_chain (filter)) if (!_ensure_input_chain (filter))