build: add configure test for POSIX shm for the sake of vo_kitty

Android's POSIX coverage is pretty sketchy but not like we have a choice.
This commit is contained in:
sfan5 2022-12-26 15:08:07 +01:00
parent cb15bc4324
commit d8ae14653a
3 changed files with 15 additions and 4 deletions

View File

@ -962,6 +962,11 @@ if features['sixel']
sources += files('video/out/vo_sixel.c')
endif
features += {'posix_shm': false}
if features['posix']
features += {'posix_shm': cc.has_function('shm_open', prefix: '#include <sys/mman.h>')}
endif
spirv_cross = dependency('spirv-cross-c-shared', required: get_option('spirv-cross'))
features += {'spirv-cross': spirv_cross.found()}
if features['spirv-cross']

View File

@ -22,7 +22,7 @@
#include <stdlib.h>
#include <signal.h>
#include <config.h>
#include "config.h"
#if HAVE_POSIX
#include <fcntl.h>
@ -34,7 +34,6 @@
#include <libswscale/swscale.h>
#include <libavutil/base64.h>
#include "config.h"
#include "options/m_config.h"
#include "osdep/terminal.h"
#include "sub/osd.h"
@ -109,7 +108,7 @@ static bool resized;
static void close_shm(struct priv *p)
{
#if HAVE_POSIX
#if HAVE_POSIX_SHM
if (p->buffer != NULL) {
munmap(p->buffer, p->buffer_size);
p->buffer = NULL;
@ -210,7 +209,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
static int create_shm(struct vo *vo)
{
#if HAVE_POSIX
#if HAVE_POSIX_SHM
struct priv *p = vo->priv;
p->shm_fd = shm_open(p->shm_path, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
if (p->shm_fd == -1) {
@ -344,7 +343,9 @@ static int preinit(struct vo *vo)
struct sigaction sa;
sa.sa_handler = handle_winch;
sigaction(SIGWINCH, &sa, &saved_sigaction);
#endif
#if HAVE_POSIX_SHM
if (p->opts.use_shm) {
p->shm_path = talloc_asprintf(vo, "/mpv-kitty-%p", vo);
int p_size = strlen(p->shm_path) - 1;

View File

@ -814,6 +814,11 @@ video_output_features = [
'desc': 'drmIsKMS() function',
'deps': 'drm',
'func': check_pkg_config('libdrm', '>= 2.4.105'),
}, {
'name': 'posix-shm',
'desc': "POSIX shared memory API",
'deps': 'posix',
'func': check_statement('sys/mman.h', 'shm_open("",0,0)')
}
]