mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
bufferpool: more tests and small doc fixes
This commit is contained in:
parent
c1ec592ec2
commit
c42780db66
3 changed files with 64 additions and 4 deletions
|
@ -409,7 +409,7 @@ do_stop (GstBufferPool * pool)
|
||||||
* @active: the new active state
|
* @active: the new active state
|
||||||
*
|
*
|
||||||
* Control the active state of @pool. When the pool is inactive, new calls to
|
* 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
|
* Activating the bufferpool will preallocate all resources in the pool based on
|
||||||
* the configuration of the pool.
|
* 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
|
* @params can be %NULL or contain optional parameters to influence the
|
||||||
* allocation.
|
* 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.
|
* inactive.
|
||||||
*/
|
*/
|
||||||
GstFlowReturn
|
GstFlowReturn
|
||||||
|
|
|
@ -98,7 +98,6 @@ struct _GstBufferPoolAcquireParams {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstBufferPool:
|
* GstBufferPool:
|
||||||
* @object: the parent structure
|
|
||||||
*
|
*
|
||||||
* The structure of a #GstBufferPool. Use the associated macros to access the public
|
* The structure of a #GstBufferPool. Use the associated macros to access the public
|
||||||
* variables.
|
* variables.
|
||||||
|
@ -148,7 +147,7 @@ struct _GstBufferPool {
|
||||||
struct _GstBufferPoolClass {
|
struct _GstBufferPoolClass {
|
||||||
GstObjectClass object_class;
|
GstObjectClass object_class;
|
||||||
|
|
||||||
/* vmethods */
|
/*< public >*/
|
||||||
const gchar ** (*get_options) (GstBufferPool *pool);
|
const gchar ** (*get_options) (GstBufferPool *pool);
|
||||||
gboolean (*set_config) (GstBufferPool *pool, GstStructure *config);
|
gboolean (*set_config) (GstBufferPool *pool, GstStructure *config);
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ GST_START_TEST (test_new_buffer_from_empty_pool)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
|
||||||
GST_START_TEST (test_buffer_is_recycled)
|
GST_START_TEST (test_buffer_is_recycled)
|
||||||
{
|
{
|
||||||
GstBufferPool *pool = create_pool (10, 0, 0);
|
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);
|
gst_buffer_pool_acquire_buffer (pool, &buf, NULL);
|
||||||
prev = buf;
|
prev = buf;
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
gst_buffer_pool_acquire_buffer (pool, &buf, NULL);
|
gst_buffer_pool_acquire_buffer (pool, &buf, NULL);
|
||||||
fail_unless (buf == prev, "got a fresh buffer instead of previous");
|
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_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 *
|
static Suite *
|
||||||
gst_buffer_pool_suite (void)
|
gst_buffer_pool_suite (void)
|
||||||
{
|
{
|
||||||
|
@ -79,6 +137,9 @@ gst_buffer_pool_suite (void)
|
||||||
suite_add_tcase (s, tc_chain);
|
suite_add_tcase (s, tc_chain);
|
||||||
tcase_add_test (tc_chain, test_new_buffer_from_empty_pool);
|
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_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;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue