bufferpool: more tests and small doc fixes

This commit is contained in:
Stefan Sauer 2014-01-31 08:08:37 +01:00
parent c1ec592ec2
commit c42780db66
3 changed files with 64 additions and 4 deletions

View file

@ -409,7 +409,7 @@ do_stop (GstBufferPool * pool)
* @active: the new active state
*
* Control the active state of @pool. When the pool is inactive, new calls to
* gst_buffer_pool_acquire_buffer() will return with #GST_FLOW_FLUSHING.
* gst_buffer_pool_acquire_buffer() will return with %GST_FLOW_FLUSHING.
*
* Activating the bufferpool will preallocate all resources in the pool based on
* the configuration of the pool.
@ -1079,7 +1079,7 @@ default_reset_buffer (GstBufferPool * pool, GstBuffer * buffer)
* @params can be %NULL or contain optional parameters to influence the
* allocation.
*
* Returns: a #GstFlowReturn such as GST_FLOW_FLUSHING when the pool is
* Returns: a #GstFlowReturn such as %GST_FLOW_FLUSHING when the pool is
* inactive.
*/
GstFlowReturn

View file

@ -98,7 +98,6 @@ struct _GstBufferPoolAcquireParams {
/**
* GstBufferPool:
* @object: the parent structure
*
* The structure of a #GstBufferPool. Use the associated macros to access the public
* variables.
@ -148,7 +147,7 @@ struct _GstBufferPool {
struct _GstBufferPoolClass {
GstObjectClass object_class;
/* vmethods */
/*< public >*/
const gchar ** (*get_options) (GstBufferPool *pool);
gboolean (*set_config) (GstBufferPool *pool, GstStructure *config);

View file

@ -49,6 +49,7 @@ GST_START_TEST (test_new_buffer_from_empty_pool)
GST_END_TEST;
GST_START_TEST (test_buffer_is_recycled)
{
GstBufferPool *pool = create_pool (10, 0, 0);
@ -58,6 +59,7 @@ GST_START_TEST (test_buffer_is_recycled)
gst_buffer_pool_acquire_buffer (pool, &buf, NULL);
prev = buf;
gst_buffer_unref (buf);
gst_buffer_pool_acquire_buffer (pool, &buf, NULL);
fail_unless (buf == prev, "got a fresh buffer instead of previous");
@ -68,6 +70,62 @@ GST_START_TEST (test_buffer_is_recycled)
GST_END_TEST;
GST_START_TEST (test_buffer_out_of_order_reuse)
{
GstBufferPool *pool = create_pool (10, 0, 0);
GstBuffer *buf1 = NULL, *buf2 = NULL, *prev;
gst_buffer_pool_set_active (pool, TRUE);
gst_buffer_pool_acquire_buffer (pool, &buf1, NULL);
gst_buffer_pool_acquire_buffer (pool, &buf2, NULL);
prev = buf2;
gst_buffer_unref (buf2);
gst_buffer_pool_acquire_buffer (pool, &buf2, NULL);
fail_unless (buf2 == prev, "got a fresh buffer instead of previous");
gst_buffer_unref (buf1);
gst_buffer_unref (buf2);
gst_buffer_pool_set_active (pool, FALSE);
gst_object_unref (pool);
}
GST_END_TEST;
GST_START_TEST (test_pool_config_buffer_size)
{
GstBufferPool *pool = create_pool (10, 0, 0);
GstBuffer *buf = NULL;
gst_buffer_pool_set_active (pool, TRUE);
gst_buffer_pool_acquire_buffer (pool, &buf, NULL);
ck_assert_int_eq (gst_buffer_get_size (buf), 10);
gst_buffer_unref (buf);
gst_buffer_pool_set_active (pool, FALSE);
gst_object_unref (pool);
}
GST_END_TEST;
GST_START_TEST (test_inactive_pool_returns_flushing)
{
GstBufferPool *pool = create_pool (10, 0, 0);
GstFlowReturn ret;
GstBuffer *buf = NULL;
ret = gst_buffer_pool_acquire_buffer (pool, &buf, NULL);
ck_assert_int_eq (ret, GST_FLOW_FLUSHING);
gst_object_unref (pool);
}
GST_END_TEST;
static Suite *
gst_buffer_pool_suite (void)
{
@ -79,6 +137,9 @@ gst_buffer_pool_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_new_buffer_from_empty_pool);
tcase_add_test (tc_chain, test_buffer_is_recycled);
tcase_add_test (tc_chain, test_buffer_out_of_order_reuse);
tcase_add_test (tc_chain, test_pool_config_buffer_size);
tcase_add_test (tc_chain, test_inactive_pool_returns_flushing);
return s;
}