bufferpool: rename 'flushing' to 'active'

Rename the flushing variable and methods to active to better match
the other gstreamer name conventions
This commit is contained in:
Wim Taymans 2011-02-18 12:50:21 +01:00
parent 2496523b3e
commit dd16af7a6c
2 changed files with 26 additions and 26 deletions

View file

@ -63,7 +63,7 @@ static void gst_buffer_pool_finalize (GObject * object);
G_DEFINE_TYPE (GstBufferPool, gst_buffer_pool, GST_TYPE_OBJECT); G_DEFINE_TYPE (GstBufferPool, gst_buffer_pool, GST_TYPE_OBJECT);
static void default_set_flushing (GstBufferPool * pool, gboolean flushing); static void default_set_active (GstBufferPool * pool, gboolean active);
static gboolean default_set_config (GstBufferPool * pool, static gboolean default_set_config (GstBufferPool * pool,
GstStructure * config); GstStructure * config);
static GstFlowReturn default_alloc_buffer (GstBufferPool * pool, static GstFlowReturn default_alloc_buffer (GstBufferPool * pool,
@ -80,7 +80,7 @@ gst_buffer_pool_class_init (GstBufferPoolClass * klass)
gobject_class->finalize = gst_buffer_pool_finalize; gobject_class->finalize = gst_buffer_pool_finalize;
klass->set_flushing = default_set_flushing; klass->set_active = default_set_active;
klass->set_config = default_set_config; klass->set_config = default_set_config;
klass->acquire_buffer = default_acquire_buffer; klass->acquire_buffer = default_acquire_buffer;
klass->alloc_buffer = default_alloc_buffer; klass->alloc_buffer = default_alloc_buffer;
@ -102,7 +102,7 @@ gst_buffer_pool_init (GstBufferPool * pool)
GST_QUARK (ALIGN), G_TYPE_UINT, 1, NULL); GST_QUARK (ALIGN), G_TYPE_UINT, 1, NULL);
pool->poll = gst_poll_new_timer (); pool->poll = gst_poll_new_timer ();
pool->queue = gst_atomic_queue_new (10); pool->queue = gst_atomic_queue_new (10);
default_set_flushing (pool, TRUE); default_set_active (pool, FALSE);
GST_DEBUG_OBJECT (pool, "created"); GST_DEBUG_OBJECT (pool, "created");
} }
@ -147,14 +147,14 @@ flush_buffers (GstBufferPool * pool)
} }
/* the default implementation for allocating and freeing the /* the default implementation for allocating and freeing the
* buffers when changing the flushing state */ * buffers when changing the active state */
static void static void
default_set_flushing (GstBufferPool * pool, gboolean flushing) default_set_active (GstBufferPool * pool, gboolean active)
{ {
guint i; guint i;
GstBufferPoolPrivate *priv = pool->priv; GstBufferPoolPrivate *priv = pool->priv;
if (flushing) { if (!active) {
/* clear the pool */ /* clear the pool */
flush_buffers (pool); flush_buffers (pool);
} else { } else {
@ -177,15 +177,15 @@ default_set_flushing (GstBufferPool * pool, gboolean flushing)
} }
/** /**
* gst_buffer_pool_set_flushing: * gst_buffer_pool_set_active:
* @pool: a #GstBufferPool * @pool: a #GstBufferPool
* @flushing: the new flushing state * @active: the new active state
* *
* Control the flushing state of @pool. When the pool is flushing, new calls to * Control the active state of @pool. When the pool is active, new calls to
* gst_buffer_pool_acquire_buffer() will return with GST_FLOW_WRONG_STATE. * gst_buffer_pool_acquire_buffer() will return with GST_FLOW_WRONG_STATE.
*/ */
void void
gst_buffer_pool_set_flushing (GstBufferPool * pool, gboolean flushing) gst_buffer_pool_set_active (GstBufferPool * pool, gboolean active)
{ {
GstBufferPoolClass *pclass; GstBufferPoolClass *pclass;
@ -193,16 +193,16 @@ gst_buffer_pool_set_flushing (GstBufferPool * pool, gboolean flushing)
pclass = GST_BUFFER_POOL_GET_CLASS (pool); pclass = GST_BUFFER_POOL_GET_CLASS (pool);
if (!g_atomic_int_compare_and_exchange (&pool->flushing, !flushing, flushing)) if (!g_atomic_int_compare_and_exchange (&pool->active, !active, active))
return; return;
if (flushing) if (!active)
gst_poll_write_control (pool->poll); gst_poll_write_control (pool->poll);
if (G_LIKELY (pclass->set_flushing)) if (G_LIKELY (pclass->set_active))
pclass->set_flushing (pool, flushing); pclass->set_active (pool, active);
if (!flushing) if (active)
gst_poll_read_control (pool->poll); gst_poll_read_control (pool->poll);
} }
@ -223,7 +223,7 @@ default_set_config (GstBufferPool * pool, GstStructure * config)
* @pool: a #GstBufferPool * @pool: a #GstBufferPool
* @config: a #GstStructure * @config: a #GstStructure
* *
* Set the configuration of the pool. The pool must be flushing or else this * Set the configuration of the pool. The pool must be inactive or else this
* function will do nothing and return FALSE. * function will do nothing and return FALSE.
* *
* @condfig is a #GstStructure that contains the configuration parameters for * @condfig is a #GstStructure that contains the configuration parameters for
@ -241,12 +241,12 @@ gst_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), FALSE); g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), FALSE);
g_return_val_if_fail (config != NULL, FALSE); g_return_val_if_fail (config != NULL, FALSE);
if (!g_atomic_int_get (&pool->flushing)) if (g_atomic_int_get (&pool->active))
return FALSE; return FALSE;
pclass = GST_BUFFER_POOL_GET_CLASS (pool); pclass = GST_BUFFER_POOL_GET_CLASS (pool);
/* free the buffer when we are flushing */ /* free the buffer when we are inactive */
if (G_LIKELY (pclass->set_config)) if (G_LIKELY (pclass->set_config))
result = pclass->set_config (pool, config); result = pclass->set_config (pool, config);
else else
@ -368,7 +368,7 @@ default_acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer,
pclass = GST_BUFFER_POOL_GET_CLASS (pool); pclass = GST_BUFFER_POOL_GET_CLASS (pool);
while (TRUE) { while (TRUE) {
if (g_atomic_int_get (&pool->flushing)) if (!g_atomic_int_get (&pool->active))
return GST_FLOW_WRONG_STATE; return GST_FLOW_WRONG_STATE;
/* try to get a buffer from the queue */ /* try to get a buffer from the queue */
@ -414,7 +414,7 @@ default_acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer,
* @params can be NULL or contain optional parameters to influence the allocation. * @params can be NULL or contain optional parameters to influence the allocation.
* *
* Returns: a #GstFlowReturn such as GST_FLOW_WRONG_STATE when the pool is * Returns: a #GstFlowReturn such as GST_FLOW_WRONG_STATE when the pool is
* flushing. * inactive.
*/ */
GstFlowReturn GstFlowReturn
gst_buffer_pool_acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer, gst_buffer_pool_acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer,
@ -445,13 +445,13 @@ default_free_buffer (GstBufferPool * pool, GstBuffer * buffer)
static void static void
default_release_buffer (GstBufferPool * pool, GstBuffer * buffer) default_release_buffer (GstBufferPool * pool, GstBuffer * buffer)
{ {
/* keep it around in our queue, we might be flushing but that's ok because we /* keep it around in our queue, we might be inactive but that's ok because we
* handle that unlikely case below. */ * handle that unlikely case below. */
gst_atomic_queue_push (pool->queue, buffer); gst_atomic_queue_push (pool->queue, buffer);
gst_poll_write_control (pool->poll); gst_poll_write_control (pool->poll);
if (G_UNLIKELY (g_atomic_int_get (&pool->flushing))) { if (G_UNLIKELY (!g_atomic_int_get (&pool->active))) {
/* we are flushing, remove the buffers again */ /* we are inactive, remove the buffers again */
flush_buffers (pool); flush_buffers (pool);
} }
} }

View file

@ -96,7 +96,7 @@ struct _GstBufferPool {
GstObject object; GstObject object;
/*< private >*/ /*< private >*/
gboolean flushing; gboolean active;
GstAtomicQueue *queue; GstAtomicQueue *queue;
GstPoll *poll; GstPoll *poll;
@ -111,7 +111,7 @@ struct _GstBufferPoolClass {
GstObjectClass object_class; GstObjectClass object_class;
/* vmethods */ /* vmethods */
void (*set_flushing) (GstBufferPool *pool, gboolean flushing); void (*set_active) (GstBufferPool *pool, gboolean active);
gboolean (*set_config) (GstBufferPool *pool, GstStructure *config); gboolean (*set_config) (GstBufferPool *pool, GstStructure *config);
GstFlowReturn (*acquire_buffer) (GstBufferPool *pool, GstBuffer **buffer, GstFlowReturn (*acquire_buffer) (GstBufferPool *pool, GstBuffer **buffer,
@ -130,7 +130,7 @@ GType gst_buffer_pool_get_type (void);
GstBufferPool * gst_buffer_pool_new (void); GstBufferPool * gst_buffer_pool_new (void);
/* state management */ /* state management */
void gst_buffer_pool_set_flushing (GstBufferPool *pool, gboolean flushing); void gst_buffer_pool_set_active (GstBufferPool *pool, gboolean active);
gboolean gst_buffer_pool_set_config (GstBufferPool *pool, GstStructure *config); gboolean gst_buffer_pool_set_config (GstBufferPool *pool, GstStructure *config);
const GstStructure * gst_buffer_pool_get_config (GstBufferPool *pool); const GstStructure * gst_buffer_pool_get_config (GstBufferPool *pool);