summaryrefslogtreecommitdiff
path: root/spa
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2019-07-25 12:10:05 +0200
committerWim Taymans <wtaymans@redhat.com>2019-07-25 12:10:05 +0200
commit18776b155b6231e3a81c2c4a4c5f4fc87150f19c (patch)
treed9006c08f230a966e1b3d54baad1bc88bf59cd1b /spa
parent5aa0ff21c6b5b287940766438777c968f5589df0 (diff)
mem: Add tag to memmap
Add a tag field when creating a memmap so that we can do lookup on it. This makes it easier to implement the tracking of mappings for io areas. Remove custom io memory tracking and use the tags. Add flags to spa_chunk to make data corrupted. The flags on the buffer stay constant for the life of the buffer. Add flags to mark memory readable and writable. Mark memory readonly in v4l2-source. Pass the daemon activation area to the client in the transport event. This never changes and need to be handled differently from the other activation areas. Use the right flags when importing memory. Add the (desired) memory type to mempool_alloc. improve some debug.
Diffstat (limited to 'spa')
-rw-r--r--spa/include/spa/buffer/buffer.h14
-rw-r--r--spa/plugins/v4l2/v4l2-utils.c6
2 files changed, 15 insertions, 5 deletions
diff --git a/spa/include/spa/buffer/buffer.h b/spa/include/spa/buffer/buffer.h
index 1a123ba8..db52bc56 100644
--- a/spa/include/spa/buffer/buffer.h
+++ b/spa/include/spa/buffer/buffer.h
@@ -48,7 +48,7 @@ enum spa_data_type {
SPA_DATA_LAST, /**< not part of ABI */
};
-/** Chunk of memory */
+/** Chunk of memory, can change for each buffer */
struct spa_chunk {
uint32_t offset; /**< offset of valid data. Should be taken
* modulo the data maxsize to get the offset
@@ -56,15 +56,19 @@ struct spa_chunk {
uint32_t size; /**< size of valid data. Should be clamped to
* maxsize. */
int32_t stride; /**< stride of valid data */
- int32_t dummy; /**< dummy field for alignment */
+#define SPA_CHUNK_FLAG_NONE 0
+#define SPA_CHUNK_FLAG_CORRUPTED (1u<<0) /**< chunk data is corrupted in some way */
+ int32_t flags; /**< chunk flags */
};
-/** Data for a buffer */
+/** Data for a buffer this stays constant for a buffer */
struct spa_data {
uint32_t type; /**< memory type, one of enum spa_data_type */
#define SPA_DATA_FLAG_NONE 0
-#define SPA_DATA_FLAG_CORRUPTED (1u<<0) /**< data is corrupted in some way */
-#define SPA_DATA_FLAG_DYNAMIC (1u<<1) /**< data pointer can be changed */
+#define SPA_DATA_FLAG_READABLE (1u<<0) /**< data is readable */
+#define SPA_DATA_FLAG_WRITABLE (1u<<1) /**< data is writable */
+#define SPA_DATA_FLAG_DYNAMIC (1u<<2) /**< data pointer can be changed */
+#define SPA_DATA_FLAG_READWRITE (SPA_DATA_FLAG_READABLE|SPA_DATA_FLAG_WRITABLE)
uint32_t flags; /**< data flags */
int64_t fd; /**< optional fd for data */
uint32_t mapoffset; /**< offset to map fd at */
diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c
index 166dac45..8811592d 100644
--- a/spa/plugins/v4l2/v4l2-utils.c
+++ b/spa/plugins/v4l2/v4l2-utils.c
@@ -1202,6 +1202,9 @@ static int mmap_read(struct impl *this)
d[0].chunk->offset = 0;
d[0].chunk->size = buf.bytesused;
d[0].chunk->stride = port->fmt.fmt.pix.bytesperline;
+ d[0].chunk->flags = 0;
+ if (buf.flags & V4L2_BUF_FLAG_ERROR)
+ d[0].flags |= SPA_CHUNK_FLAG_CORRUPTED;
SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUTSTANDING);
@@ -1399,6 +1402,7 @@ mmap_init(struct impl *this,
d[0].chunk->offset = 0;
d[0].chunk->size = 0;
d[0].chunk->stride = port->fmt.fmt.pix.bytesperline;
+ d[0].chunk->flags = 0;
if (port->export_buf) {
struct v4l2_exportbuffer expbuf;
@@ -1412,11 +1416,13 @@ mmap_init(struct impl *this,
continue;
}
d[0].type = SPA_DATA_DmaBuf;
+ d[0].flags = SPA_DATA_FLAG_READABLE;
d[0].fd = expbuf.fd;
d[0].data = NULL;
SPA_FLAG_SET(b->flags, BUFFER_FLAG_ALLOCATED);
} else {
d[0].type = SPA_DATA_MemPtr;
+ d[0].flags = SPA_DATA_FLAG_READABLE;
d[0].fd = -1;
d[0].data = mmap(NULL,
b->v4l2_buffer.length,