{
GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (bpool);
GstV4l2Object *obj = pool->obj;
+ GstBuffer *buffers[VIDEO_MAX_FRAME];
gint i;
GST_DEBUG_OBJECT (pool, "stop flushing");
if (pool->other_pool)
gst_buffer_pool_set_flushing (pool->other_pool, FALSE);
+ GST_OBJECT_LOCK (pool);
gst_v4l2_buffer_pool_streamoff (pool);
+ /* Remember buffers to re-enqueue */
+ memcpy(buffers, pool->buffers, sizeof(buffers));
+ memset(pool->buffers, 0, sizeof(pool->buffers));
+ GST_OBJECT_UNLOCK (pool);
/* Reset our state */
switch (obj->mode) {
{
for (i = 0; i < VIDEO_MAX_FRAME; i++) {
/* Re-enqueue buffers */
- if (pool->buffers[i]) {
+ if (buffers[i]) {
GstBufferPool *bpool = (GstBufferPool *) pool;
- GstBuffer *buffer = pool->buffers[i];
-
- pool->buffers[i] = NULL;
+ GstBuffer *buffer = buffers[i];
/* Remove qdata, this will unmap any map data in
* userptr/dmabuf-import */
GST_LOG_OBJECT (pool, "queuing buffer %i", index);
- g_atomic_int_inc (&pool->num_queued);
- pool->buffers[index] = buf;
-
if (V4L2_TYPE_IS_OUTPUT (obj->type)) {
enum v4l2_field field;
GST_TIME_TO_TIMEVAL (timestamp, group->buffer.timestamp);
}
+ GST_OBJECT_LOCK (pool);
+ g_atomic_int_inc (&pool->num_queued);
+ pool->buffers[index] = buf;
+
if (!gst_v4l2_allocator_qbuf (pool->vallocator, group))
goto queue_failed;
- GST_OBJECT_LOCK (pool);
pool->empty = FALSE;
g_cond_signal (&pool->empty_cond);
GST_OBJECT_UNLOCK (pool);
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_TAG_MEMORY);
g_atomic_int_add (&pool->num_queued, -1);
pool->buffers[index] = NULL;
+ GST_OBJECT_UNLOCK (pool);
return GST_FLOW_ERROR;
}
}