mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
mem: add private mapping flag
This commit is contained in:
parent
b9e517ee67
commit
3142d3b979
3 changed files with 9 additions and 3 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2736c227a19b1db48dd849af6f7f3e929bb53c00
|
Subproject commit 35bf6bfa5c3969b65e63dbfe48578c5c040849d4
|
||||||
|
|
@ -266,13 +266,18 @@ static struct mapping * memblock_map(struct memblock *b,
|
||||||
struct mempool *p = SPA_CONTAINER_OF(b->this.pool, struct mempool, this);
|
struct mempool *p = SPA_CONTAINER_OF(b->this.pool, struct mempool, this);
|
||||||
struct mapping *m;
|
struct mapping *m;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
int prot = 0;
|
int prot = 0, fl = 0;
|
||||||
|
|
||||||
if (flags & PW_MEMMAP_FLAG_READ)
|
if (flags & PW_MEMMAP_FLAG_READ)
|
||||||
prot |= PROT_READ;
|
prot |= PROT_READ;
|
||||||
if (flags & PW_MEMMAP_FLAG_WRITE)
|
if (flags & PW_MEMMAP_FLAG_WRITE)
|
||||||
prot |= PROT_WRITE;
|
prot |= PROT_WRITE;
|
||||||
|
|
||||||
|
if (flags & PW_MEMMAP_FLAG_PRIVATE)
|
||||||
|
fl |= MAP_PRIVATE;
|
||||||
|
else
|
||||||
|
fl |= MAP_SHARED;
|
||||||
|
|
||||||
if (flags & PW_MEMMAP_FLAG_TWICE) {
|
if (flags & PW_MEMMAP_FLAG_TWICE) {
|
||||||
pw_log_error(NAME" %p: implement me PW_MEMMAP_FLAG_TWICE", p);
|
pw_log_error(NAME" %p: implement me PW_MEMMAP_FLAG_TWICE", p);
|
||||||
errno = ENOTSUP;
|
errno = ENOTSUP;
|
||||||
|
|
@ -280,7 +285,7 @@ static struct mapping * memblock_map(struct memblock *b,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ptr = mmap(NULL, size, prot, MAP_SHARED, b->this.fd, offset);
|
ptr = mmap(NULL, size, prot, fl, b->this.fd, offset);
|
||||||
if (ptr == MAP_FAILED) {
|
if (ptr == MAP_FAILED) {
|
||||||
pw_log_error(NAME" %p: Failed to mmap memory fd:%d offset:%u size:%u: %m",
|
pw_log_error(NAME" %p: Failed to mmap memory fd:%d offset:%u size:%u: %m",
|
||||||
p, b->this.fd, offset, size);
|
p, b->this.fd, offset, size);
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ enum pw_memmap_flags {
|
||||||
PW_MEMMAP_FLAG_WRITE = (1 << 1), /**< map in write mode */
|
PW_MEMMAP_FLAG_WRITE = (1 << 1), /**< map in write mode */
|
||||||
PW_MEMMAP_FLAG_TWICE = (1 << 2), /**< map the same area twice afer eachother,
|
PW_MEMMAP_FLAG_TWICE = (1 << 2), /**< map the same area twice afer eachother,
|
||||||
* creating a circular ringbuffer */
|
* creating a circular ringbuffer */
|
||||||
|
PW_MEMMAP_FLAG_PRIVATE = (1 << 3), /**< writes will be private */
|
||||||
PW_MEMMAP_FLAG_READWRITE = PW_MEMMAP_FLAG_READ | PW_MEMMAP_FLAG_WRITE,
|
PW_MEMMAP_FLAG_READWRITE = PW_MEMMAP_FLAG_READ | PW_MEMMAP_FLAG_WRITE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue