mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -05:00
pulsecore: Transform pa_mempool_new() into a factory method
Soon we're going to have three types of memory pools: POSIX shm_open() pools, memfd memfd_create() ones, and privately malloc()-ed pools. Thus introduce annotations for the memory types supported and change pa_mempool_new() into a factory method based on required memory. Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
This commit is contained in:
parent
211a520543
commit
b88acd0266
18 changed files with 97 additions and 37 deletions
51
src/pulsecore/mem.h
Normal file
51
src/pulsecore/mem.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#ifndef foopulsememhfoo
|
||||
#define foopulsememhfoo
|
||||
|
||||
/***
|
||||
This file is part of PulseAudio.
|
||||
|
||||
Copyright 2016 Ahmed S. Darwish <darwish.07@gmail.com>
|
||||
|
||||
PulseAudio is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
PulseAudio is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
typedef enum pa_mem_type {
|
||||
PA_MEM_TYPE_SHARED_POSIX, /* Data is shared and created using POSIX shm_open() */
|
||||
PA_MEM_TYPE_SHARED_MEMFD, /* Data is shared and created using Linux memfd_create() */
|
||||
PA_MEM_TYPE_PRIVATE, /* Data is private and created using classic memory allocation
|
||||
(posix_memalign(), malloc() or anonymous mmap()) */
|
||||
} pa_mem_type_t;
|
||||
|
||||
static inline const char *pa_mem_type_to_string(pa_mem_type_t type) {
|
||||
switch (type) {
|
||||
case PA_MEM_TYPE_SHARED_POSIX:
|
||||
return "shared posix-shm";
|
||||
case PA_MEM_TYPE_SHARED_MEMFD:
|
||||
return "shared memfd";
|
||||
case PA_MEM_TYPE_PRIVATE:
|
||||
return "private";
|
||||
}
|
||||
|
||||
pa_assert_not_reached();
|
||||
}
|
||||
|
||||
static inline bool pa_mem_type_is_shared(pa_mem_type_t t) {
|
||||
return (t == PA_MEM_TYPE_SHARED_POSIX) || (t == PA_MEM_TYPE_SHARED_MEMFD);
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue