v4l2bufferpool: Prevent num_queued from going negative

This commit is contained in:
Nicolas Dufresne 2014-05-23 19:10:21 -04:00 committed by Nicolas Dufresne
parent 57726911f8
commit 3a7bd8d479

View file

@ -990,12 +990,12 @@ gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool * pool, GstBuffer * buf)
GST_LOG_OBJECT (pool, "queuing buffer %i", index);
g_atomic_int_inc (&pool->num_queued);
pool->buffers[index] = buf;
if (!gst_v4l2_allocator_qbuf (pool->vallocator, group))
goto queue_failed;
pool->buffers[index] = buf;
g_atomic_int_inc (&pool->num_queued);
return GST_FLOW_OK;
already_queued:
@ -1008,6 +1008,8 @@ queue_failed:
GST_ERROR_OBJECT (pool, "could not queue a buffer %i", index);
/* Mark broken buffer to the allocator */
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_TAG_MEMORY);
g_atomic_int_add (&pool->num_queued, -1);
pool->buffers[index] = NULL;
return GST_FLOW_ERROR;
}
}