pool-nego: Retry setting configuration with modified config

Buffer pool set_config() may return FALSE if requested configuration needed
small changes. Reget the config and try setting it again (validating the
changes first). This ensure we have a configured pool if possible.

https://bugzilla.gnome.org/show_bug.cgi?id=727916
This commit is contained in:
Nicolas Dufresne 2014-04-15 14:17:00 -04:00
parent 194db480e0
commit 23e69d98d8
2 changed files with 46 additions and 2 deletions

View file

@ -3055,7 +3055,23 @@ gst_base_src_decide_allocation_default (GstBaseSrc * basesrc, GstQuery * query)
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set_params (config, outcaps, size, min, max);
gst_buffer_pool_config_set_allocator (config, allocator, &params);
gst_buffer_pool_set_config (pool, config);
/* buffer pool may have to do some changes */
if (!gst_buffer_pool_set_config (pool, config)) {
config = gst_buffer_pool_get_config (pool);
/* If change are not acceptable, fallback to generic pool */
if (!gst_buffer_pool_config_validate_params (config, outcaps, size, min,
max)) {
GST_DEBUG_OBJECT (basesrc, "unsuported pool, making new pool");
gst_object_unref (pool);
pool = gst_buffer_pool_new ();
}
if (!gst_buffer_pool_set_config (pool, config))
goto config_failed;
}
}
if (update_allocator)
@ -3071,6 +3087,12 @@ gst_base_src_decide_allocation_default (GstBaseSrc * basesrc, GstQuery * query)
}
return TRUE;
config_failed:
GST_ELEMENT_ERROR (basesrc, RESOURCE, SETTINGS,
("Failed to configure the buffer pool"),
("Configuration is most likely invalid, please report this issue."));
return FALSE;
}
static gboolean

View file

@ -899,7 +899,23 @@ gst_base_transform_default_decide_allocation (GstBaseTransform * trans,
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set_params (config, outcaps, size, min, max);
gst_buffer_pool_config_set_allocator (config, allocator, &params);
gst_buffer_pool_set_config (pool, config);
/* buffer pool may have to do some changes */
if (!gst_buffer_pool_set_config (pool, config)) {
config = gst_buffer_pool_get_config (pool);
/* If change are not acceptable, fallback to generic pool */
if (!gst_buffer_pool_config_validate_params (config, outcaps, size, min,
max)) {
GST_DEBUG_OBJECT (trans, "unsuported pool, making new pool");
gst_object_unref (pool);
pool = gst_buffer_pool_new ();
}
if (!gst_buffer_pool_set_config (pool, config))
goto config_failed;
}
}
if (update_allocator)
@ -915,6 +931,12 @@ gst_base_transform_default_decide_allocation (GstBaseTransform * trans,
}
return TRUE;
config_failed:
GST_ELEMENT_ERROR (trans, RESOURCE, SETTINGS,
("Failed to configure the buffer pool"),
("Configuration is most likely invalid, please report this issue."));
return FALSE;
}
static gboolean