1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-23 15:22:09 +00:00

wayland: switch to the new mp_msg api

This commit is contained in:
Alexander Preisinger 2013-07-31 19:19:44 +02:00
parent 03bef3adfd
commit 6443a9b16c
3 changed files with 23 additions and 8 deletions

View File

@ -27,6 +27,7 @@
#include "gl_common.h"
struct egl_context {
struct mp_log *log;
EGLSurface egl_surface;
struct wl_egl_window *egl_window;
@ -96,6 +97,8 @@ static void egl_resize_func(struct vo_wayland_state *wl,
else
y = 0;
MP_VERBOSE(ctx, "resizing %dx%d -> %dx%d\n", wl->window.width,
wl->window.height, width, height);
wl_egl_window_resize(ctx->egl_window, width, height, x, y);
wl->window.width = width;
@ -134,6 +137,8 @@ static bool egl_create_context(struct vo_wayland_state *wl,
if (eglInitialize(egl_ctx->egl.dpy, &major, &minor) != EGL_TRUE)
return false;
MP_VERBOSE(egl_ctx, "EGL version %d.%d\n", major, minor);
EGLint context_attribs[] = {
EGL_CONTEXT_MAJOR_VERSION_KHR,
MPGL_VER_GET_MAJOR(ctx->requested_gl_version),
@ -210,6 +215,8 @@ static bool config_window_wayland(struct MPGLContext *ctx,
bool enable_alpha = !!(flags & VOFLAG_ALPHA);
bool ret = false;
egl_ctx->log = mp_log_new(egl_ctx, wl->log, "EGL");
wl->window.resize_func = egl_resize_func;
wl->window.resize_func_data = (void*) egl_ctx;

View File

@ -220,13 +220,13 @@ static void keyboard_handle_keymap(void *data,
close(fd);
if (!wl->input.xkb.keymap) {
mp_msg(MSGT_VO, MSGL_ERR, "[wayland] failed to compile keymap.\n");
MP_ERR(wl, "failed to compile keymap\n");
return;
}
wl->input.xkb.state = xkb_state_new(wl->input.xkb.keymap);
if (!wl->input.xkb.state) {
mp_msg(MSGT_VO, MSGL_ERR, "[wayland] failed to create XKB state.\n");
MP_ERR(wl, "failed to create XKB state\n");
xkb_map_unref(wl->input.xkb.keymap);
wl->input.xkb.keymap = NULL;
return;
@ -541,13 +541,15 @@ static void resize_window(struct vo_wayland_state *wl,
int32_t width,
int32_t height)
{
MP_VERBOSE(wl, "resizing %dx%d -> %dx%d\n", wl->window.width,
wl->window.height, width, height);
if (wl->window.resize_func && wl->window.resize_func_data) {
wl->window.resize_func(wl, edges, width, height,
wl->window.resize_func_data);
wl->window.events |= VO_EVENT_RESIZE;
}
else
mp_msg(MSGT_VO, MSGL_WARN, "[wayland] No resizing possible!\n");
MP_WARN(wl, "no resizing possible\n");
}
@ -588,8 +590,10 @@ static bool create_window (struct vo_wayland_state *wl)
wl->window.shell_surface = wl_shell_get_shell_surface(wl->display.shell,
wl->window.surface);
if (!wl->window.shell_surface)
if (!wl->window.shell_surface) {
MP_ERR(wl, "creating shell surface failed\n");
return false;
}
wl_shell_surface_add_listener(wl->window.shell_surface,
&shell_surface_listener, wl);
@ -628,7 +632,7 @@ static bool create_input (struct vo_wayland_state *wl)
wl->input.xkb.context = xkb_context_new(0);
if (!wl->input.xkb.context) {
mp_msg(MSGT_VO, MSGL_ERR, "[wayland] failed to initialize input.\n");
MP_ERR(wl, "failed to initialize input\n");
return false;
}
@ -657,13 +661,14 @@ int vo_wayland_init (struct vo *vo)
vo->wayland = talloc_zero(NULL, struct vo_wayland_state);
struct vo_wayland_state *wl = vo->wayland;
wl->vo = vo;
wl->log = mp_log_new(wl, vo->log, "wayland");
if (!create_input(wl)
|| !create_display(wl)
|| !create_window(wl)
|| !create_cursor(wl))
{
mp_msg(MSGT_VO, MSGL_ERR, "[wayland] failed to initialize display.\n");
MP_ERR(wl, "failed to initialize backend\n");
return false;
}
@ -713,6 +718,7 @@ static void vo_wayland_fullscreen (struct vo *vo)
struct wl_output *fs_output = wl->display.fs_output;
if (vo->opts->fullscreen) {
MP_VERBOSE(wl, "going fullscreen\n");
wl->window.p_width = wl->window.width;
wl->window.p_height = wl->window.height;
wl_shell_surface_set_fullscreen(wl->window.shell_surface,
@ -721,6 +727,7 @@ static void vo_wayland_fullscreen (struct vo *vo)
}
else {
MP_VERBOSE(wl, "leaving fullscreen\n");
wl_shell_surface_set_toplevel(wl->window.shell_surface);
resize_window(wl, 0, wl->window.p_width, wl->window.p_height);
}
@ -748,7 +755,7 @@ static int vo_wayland_check_events (struct vo *vo)
* are events to read from the file descriptor through poll */
if (poll(&fd, 1, 0) > 0) {
if (fd.revents & POLLERR || fd.revents & POLLHUP)
mp_msg(MSGT_VO, MSGL_ERR, "[wayland] error occurred on fd\n");
MP_ERR(wl, "error occurred on the display fd\n");
if (fd.revents & POLLIN)
wl_display_dispatch(dp);
if (fd.revents & POLLOUT)
@ -793,7 +800,7 @@ static void vo_wayland_update_screeninfo (struct vo *vo)
}
if (!mode_received) {
mp_msg(MSGT_VO, MSGL_ERR, "[wayland] no output mode detected\n");
MP_ERR(wl, "no output mode detected\n");
return;
}

View File

@ -43,6 +43,7 @@ struct vo_wayland_output {
struct vo_wayland_state {
struct vo *vo;
struct mp_log* log;
struct {
int fd;