1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-25 04:38:01 +00:00

options: simplify --android-surface-size handling

This commit is contained in:
sfan5 2020-09-20 12:04:25 +02:00
parent 7831e52238
commit 3054bcc62c
5 changed files with 8 additions and 27 deletions

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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);
}

View File

@ -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;