#include <gstv4l2bufferpool.h>
-#include "gstv4l2src.h"
-#include "gstv4l2sink.h"
#include "v4l2_calls.h"
#include "gst/gst-i18n-plugin.h"
#include <gst/glib-compat-private.h>
pool->copy_threshold = copy_threshold;
if (obj->mode == GST_V4L2_IO_DMABUF)
- allocator = gst_dmabuf_allocator_obtain ();
+ allocator = gst_dmabuf_allocator_obtain ();
if (pool->allocator)
gst_object_unref (pool->allocator);
ret = GST_BUFFER_POOL_CLASS (parent_class)->stop (bpool);
/* then free the remaining buffers */
- for (n = 0; n < pool->num_queued; n++) {
- gst_v4l2_buffer_pool_free_buffer (bpool, pool->buffers[n]);
+ for (n = 0; n < pool->num_buffers; n++) {
+ if (pool->buffers[n])
+ gst_v4l2_buffer_pool_free_buffer (bpool, pool->buffers[n]);
}
pool->num_queued = 0;
g_free (pool->buffers);
/* this can change at every frame, esp. with jpeg */
if (obj->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
gst_buffer_resize (outbuf, 0, vbuffer.bytesused);
- else
- gst_buffer_resize (outbuf, 0, vbuffer.length);
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
case GST_V4L2_IO_MMAP:
{
GstV4l2Meta *meta;
+ guint index;
meta = GST_V4L2_META_GET (buffer);
g_assert (meta != NULL);
- if (pool->buffers[meta->vbuffer.index] == NULL) {
- GST_LOG_OBJECT (pool, "buffer not queued, putting on free list");
+ index = meta->vbuffer.index;
+
+ if (pool->buffers[index] == NULL) {
+ GST_LOG_OBJECT (pool, "buffer %u not queued, putting on free list",
+ index);
+
+ /* reset to the full length, in case it was changed */
+ gst_buffer_resize (buffer, 0, meta->vbuffer.length);
+
/* playback, put the buffer back in the queue to refill later. */
GST_BUFFER_POOL_CLASS (parent_class)->release_buffer (bpool,
buffer);
/* the buffer is queued in the device but maybe not played yet. We just
* leave it there and not make it available for future calls to acquire
* for now. The buffer will be dequeued and reused later. */
- GST_LOG_OBJECT (pool, "buffer is queued");
+ GST_LOG_OBJECT (pool, "buffer %u is queued", index);
}
break;
}