typedef enum
{
- NOONE_WAITING,
- STREAM_WAITING, /* streaming thread is waiting for application thread */
- APP_WAITING, /* application thread is waiting for streaming thread */
+ NOONE_WAITING = 0,
+ STREAM_WAITING = 1 << 0, /* streaming thread is waiting for application thread */
+ APP_WAITING = 1 << 1, /* application thread is waiting for streaming thread */
} GstAppSinkWaitStatus;
struct _GstAppSinkPrivate
* consumed, which is a bit confusing for the application
*/
while (priv->num_buffers > 0 && !priv->flushing && priv->wait_on_eos) {
- priv->wait_status = STREAM_WAITING;
+ priv->wait_status |= STREAM_WAITING;
g_cond_wait (&priv->cond, &priv->mutex);
- priv->wait_status = NOONE_WAITING;
+ priv->wait_status &= ~STREAM_WAITING;
}
if (priv->flushing)
emit = FALSE;
GST_DEBUG_OBJECT (appsink, "setting preroll buffer %p", buffer);
gst_buffer_replace (&priv->preroll_buffer, buffer);
- if (priv->wait_status == APP_WAITING)
+ if ((priv->wait_status & APP_WAITING))
g_cond_signal (&priv->cond);
emit = priv->emit_signals;
}
/* wait for a buffer to be removed or flush */
- priv->wait_status = STREAM_WAITING;
+ priv->wait_status |= STREAM_WAITING;
g_cond_wait (&priv->cond, &priv->mutex);
- priv->wait_status = NOONE_WAITING;
+ priv->wait_status &= ~STREAM_WAITING;
if (priv->flushing)
goto flushing;
gst_queue_array_push_tail (priv->queue, gst_mini_object_ref (data));
priv->num_buffers++;
- if (priv->wait_status == APP_WAITING)
+ if ((priv->wait_status & APP_WAITING))
g_cond_signal (&priv->cond);
emit = priv->emit_signals;
g_mutex_lock (&priv->mutex);
GST_DEBUG_OBJECT (appsink, "waiting buffers to be consumed");
while (priv->num_buffers > 0 || priv->preroll_buffer) {
- priv->wait_status = STREAM_WAITING;
+ priv->wait_status |= STREAM_WAITING;
g_cond_wait (&priv->cond, &priv->mutex);
- priv->wait_status = NOONE_WAITING;
+ priv->wait_status &= ~STREAM_WAITING;
}
g_mutex_unlock (&priv->mutex);
ret = GST_BASE_SINK_CLASS (parent_class)->query (bsink, query);
/* nothing to return, wait */
GST_DEBUG_OBJECT (appsink, "waiting for the preroll buffer");
- priv->wait_status = APP_WAITING;
+ priv->wait_status |= APP_WAITING;
if (timeout_valid) {
if (!g_cond_wait_until (&priv->cond, &priv->mutex, end_time))
goto expired;
} else {
g_cond_wait (&priv->cond, &priv->mutex);
}
- priv->wait_status = NOONE_WAITING;
+ priv->wait_status &= ~APP_WAITING;
}
sample =
gst_sample_new (priv->preroll_buffer, priv->preroll_caps,
expired:
{
GST_DEBUG_OBJECT (appsink, "timeout expired, return NULL");
- priv->wait_status = NOONE_WAITING;
+ priv->wait_status &= ~APP_WAITING;
g_mutex_unlock (&priv->mutex);
return NULL;
}
/* nothing to return, wait */
GST_DEBUG_OBJECT (appsink, "waiting for a buffer");
- priv->wait_status = APP_WAITING;
+ priv->wait_status |= APP_WAITING;
if (timeout_valid) {
if (!g_cond_wait_until (&priv->cond, &priv->mutex, end_time))
goto expired;
} else {
g_cond_wait (&priv->cond, &priv->mutex);
}
- priv->wait_status = NOONE_WAITING;
+ priv->wait_status &= ~APP_WAITING;
}
obj = dequeue_buffer (appsink);
}
gst_mini_object_unref (obj);
- if (priv->wait_status == STREAM_WAITING)
+ if ((priv->wait_status & STREAM_WAITING))
g_cond_signal (&priv->cond);
g_mutex_unlock (&priv->mutex);
expired:
{
GST_DEBUG_OBJECT (appsink, "timeout expired, return NULL");
- priv->wait_status = NOONE_WAITING;
+ priv->wait_status &= ~APP_WAITING;
g_mutex_unlock (&priv->mutex);
return NULL;
}
typedef enum
{
- NOONE_WAITING,
- STREAM_WAITING, /* streaming thread is waiting for application thread */
- APP_WAITING, /* application thread is waiting for streaming thread */
+ NOONE_WAITING = 0,
+ STREAM_WAITING = 1 << 0, /* streaming thread is waiting for application thread */
+ APP_WAITING = 1 << 1, /* application thread is waiting for streaming thread */
} GstAppSrcWaitStatus;
struct _GstAppSrcPrivate
priv->offset += buf_size;
/* signal that we removed an item */
- if (priv->wait_status == APP_WAITING)
+ if ((priv->wait_status & APP_WAITING))
g_cond_broadcast (&priv->cond);
/* see if we go lower than the empty-percent */
goto eos;
/* nothing to return, wait a while for new data or flushing. */
- priv->wait_status = STREAM_WAITING;
+ priv->wait_status |= STREAM_WAITING;
g_cond_wait (&priv->cond, &priv->mutex);
- priv->wait_status = NOONE_WAITING;
+ priv->wait_status &= ~STREAM_WAITING;
}
g_mutex_unlock (&priv->mutex);
return ret;
GST_DEBUG_OBJECT (appsrc, "waiting for free space");
/* we are filled, wait until a buffer gets popped or when we
* flush. */
- priv->wait_status = APP_WAITING;
+ priv->wait_status |= APP_WAITING;
g_cond_wait (&priv->cond, &priv->mutex);
- priv->wait_status = NOONE_WAITING;
+ priv->wait_status &= ~APP_WAITING;
} else {
/* no need to wait for free space, we just pump more data into the
* queue hoping that the caller reacts to the enough-data signal and
priv->queued_bytes += gst_buffer_get_size (buffer);
}
- if (priv->wait_status == STREAM_WAITING)
+ if ((priv->wait_status & STREAM_WAITING))
g_cond_broadcast (&priv->cond);
g_mutex_unlock (&priv->mutex);