diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:03:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:03:18 +0000 |
commit | 2dd5bc6a074165ddfbd57c4bd52c2d2dac8f47a1 (patch) | |
tree | 465b29cb405d3af0b0ad50c78e1dccc636594fec /src/pulsecore/mem.h | |
parent | Initial commit. (diff) | |
download | pulseaudio-upstream.tar.xz pulseaudio-upstream.zip |
Adding upstream version 14.2.upstream/14.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pulsecore/mem.h')
-rw-r--r-- | src/pulsecore/mem.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/pulsecore/mem.h b/src/pulsecore/mem.h new file mode 100644 index 0000000..cba1410 --- /dev/null +++ b/src/pulsecore/mem.h @@ -0,0 +1,60 @@ +#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/creds.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); +} + +static inline bool pa_memfd_is_locally_supported() { +#if defined(HAVE_CREDS) && defined(HAVE_MEMFD) + return true; +#else + return false; +#endif +} + +#endif |