From 3054bcc62c04f8d360aba3c6f24982e78b25bcb0 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 20 Sep 2020 12:04:25 +0200 Subject: options: simplify --android-surface-size handling --- options/m_option.h | 1 - options/options.c | 8 +++----- options/options.h | 3 ++- player/command.c | 2 +- video/out/android_common.c | 21 ++------------------- 5 files changed, 8 insertions(+), 27 deletions(-) diff --git a/options/m_option.h b/options/m_option.h index bfaaef8d07..afd86eaf96 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -417,7 +417,6 @@ char *format_file_size(int64_t size); #define UPDATE_SCREENSAVER (1 << 16) // --stop-screensaver #define UPDATE_VOL (1 << 17) // softvol related options #define UPDATE_LAVFI_COMPLEX (1 << 18) // --lavfi-complex -#define UPDATE_VO_RESIZE (1 << 19) // --android-surface-size #define UPDATE_HWDEC (1 << 20) // --hwdec #define UPDATE_DVB_PROG (1 << 21) // some --dvbin-... #define UPDATE_SUB_HARD (1 << 22) // subtitle opts. that need full reinit diff --git a/options/options.c b/options/options.c index 1f6f943fdc..88b78565ed 100644 --- a/options/options.c +++ b/options/options.c @@ -92,7 +92,6 @@ extern const struct m_sub_options d3d11va_conf; extern const struct m_sub_options angle_conf; extern const struct m_sub_options cocoa_conf; extern const struct m_sub_options macos_conf; -extern const struct m_sub_options android_conf; extern const struct m_sub_options wayland_conf; extern const struct m_sub_options vaapi_conf; @@ -166,6 +165,9 @@ static const m_option_t mp_vo_opt_list[] = { #endif #if HAVE_DRM {"", OPT_SUBSTRUCT(drm_opts, drm_conf)}, +#endif +#if HAVE_EGL_ANDROID + {"android-surface-size", OPT_SIZE_BOX(android_surface_size)}, #endif {"swapchain-depth", OPT_INT(swapchain_depth), M_RANGE(1, 8)}, {0} @@ -784,10 +786,6 @@ static const m_option_t mp_opts[] = { {"", OPT_SUBSTRUCT(macos_opts, macos_conf)}, #endif -#if HAVE_EGL_ANDROID - {"", OPT_SUBSTRUCT(android_opts, android_conf)}, -#endif - #if HAVE_WAYLAND {"", OPT_SUBSTRUCT(wayland_opts, wayland_conf)}, #endif diff --git a/options/options.h b/options/options.h index 62eef010d7..9b93588bec 100644 --- a/options/options.h +++ b/options/options.h @@ -62,6 +62,8 @@ typedef struct mp_vo_opts { // vo_drm struct drm_opts *drm_opts; + struct m_geometry android_surface_size; + int swapchain_depth; // max number of images to render ahead } mp_vo_opts; @@ -340,7 +342,6 @@ typedef struct MPOpts { struct d3d11va_opts *d3d11va_opts; struct cocoa_opts *cocoa_opts; struct macos_opts *macos_opts; - struct android_opts *android_opts; struct wayland_opts *wayland_opts; struct dvd_opts *dvd_opts; struct vaapi_opts *vaapi_opts; diff --git a/player/command.c b/player/command.c index 5197dafffc..982efa2e3a 100644 --- a/player/command.c +++ b/player/command.c @@ -6475,7 +6475,7 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags, if (flags & UPDATE_LAVFI_COMPLEX) update_lavfi_complex(mpctx); - if (flags & UPDATE_VO_RESIZE) { + if (opt_ptr == &opts->vo->android_surface_size) { if (mpctx->video_out) vo_control(mpctx->video_out, VOCTRL_EXTERNAL_RESIZE, NULL); } diff --git a/video/out/android_common.c b/video/out/android_common.c index 52132f2d66..e32f9c1706 100644 --- a/video/out/android_common.c +++ b/video/out/android_common.c @@ -24,21 +24,6 @@ #include "options/m_config.h" #include "vo.h" -struct android_opts { - struct m_geometry surface_size; -}; - -#define OPT_BASE_STRUCT struct android_opts -const struct m_sub_options android_conf = { - .opts = (const struct m_option[]) { - {"android-surface-size", OPT_SIZE_BOX(surface_size), - .flags = UPDATE_VO_RESIZE}, - {0} - }, - .size = sizeof(struct android_opts), -}; - - struct vo_android_state { struct mp_log *log; ANativeWindow *native_window; @@ -95,16 +80,14 @@ ANativeWindow *vo_android_native_window(struct vo *vo) bool vo_android_surface_size(struct vo *vo, int *out_w, int *out_h) { struct vo_android_state *ctx = vo->android; - void *tmp = talloc_new(NULL); - struct android_opts *opts = mp_get_config_group(tmp, vo->global, &android_conf); - int w = opts->surface_size.w, h = opts->surface_size.h; + int w = vo->opts->android_surface_size.w, + h = vo->opts->android_surface_size.h; if (!w) w = ANativeWindow_getWidth(ctx->native_window); if (!h) h = ANativeWindow_getHeight(ctx->native_window); - talloc_free(tmp); if (w <= 0 || h <= 0) { MP_ERR(ctx, "Failed to get height and width.\n"); return false; -- cgit v1.2.3