Commit 2f460392 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vout: create the window just once at startup

This enables recycling the window when multiple window types are
involved. and avoids visual glitches.
parent 8e570775
...@@ -159,6 +159,24 @@ static vout_thread_t *VoutCreate(vlc_object_t *object, ...@@ -159,6 +159,24 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
/* */ /* */
vout_InitInterlacingSupport(vout, vout->p->displayed.is_interlaced); vout_InitInterlacingSupport(vout, vout->p->displayed.is_interlaced);
/* Window */
if (vout->p->splitter_name == NULL) {
vout_window_cfg_t wcfg = {
.is_standalone = !var_InheritBool(vout, "embedded-video"),
.type = VOUT_WINDOW_TYPE_INVALID,
// TODO: take pixel A/R, crop and zoom into account
#ifdef __APPLE__
.x = var_InheritInteger(vout, "video-x"),
.y = var_InheritInteger(vout, "video-y"),
#endif
.width = cfg->fmt->i_visible_width,
.height = cfg->fmt->i_visible_height,
};
vout->p->window = vout_window_New(VLC_OBJECT(vout), "$window", &wcfg);
} else
vout->p->window = NULL;
/* */ /* */
vlc_object_set_destructor(vout, VoutDestructor); vlc_object_set_destructor(vout, VoutDestructor);
...@@ -607,45 +625,26 @@ static void VoutGetDisplayCfg(vout_thread_t *vout, vout_display_cfg_t *cfg, cons ...@@ -607,45 +625,26 @@ static void VoutGetDisplayCfg(vout_thread_t *vout, vout_display_cfg_t *cfg, cons
vout_window_t * vout_NewDisplayWindow(vout_thread_t *vout, vout_window_t * vout_NewDisplayWindow(vout_thread_t *vout,
const vout_window_cfg_t *cfg) const vout_window_cfg_t *cfg)
{ {
vout_window_cfg_t cfg_override = *cfg; vout_window_t *window = vout->p->window;
assert(vout->p->splitter_name == NULL); assert(vout->p->splitter_name == NULL);
if (!var_InheritBool( vout, "embedded-video"))
cfg_override.is_standalone = true;
vout_window_t *window = vout->p->window.object;
if (window != NULL) {
if (!cfg_override.is_standalone == !vout->p->window.cfg.is_standalone &&
cfg_override.type == vout->p->window.cfg.type) {
/* Reuse the stored window */
msg_Dbg(vout, "Reusing previous vout window");
if (cfg_override.width != vout->p->window.cfg.width ||
cfg_override.height != vout->p->window.cfg.height)
vout_window_SetSize(window,
cfg_override.width, cfg_override.height);
vout->p->window.cfg = cfg_override;
return window;
}
vout_window_Delete(window); if (window == NULL)
} return NULL;
if (cfg->type != VOUT_WINDOW_TYPE_INVALID && cfg->type != window->type)
return NULL;
window = vout_window_New(VLC_OBJECT(vout), "$window", &cfg_override); vout_window_SetSize(window, cfg->width, cfg->height);
if (window != NULL)
vout->p->window.cfg = cfg_override;
vout->p->window.object = window;
return window; return window;
} }
void vout_DeleteDisplayWindow(vout_thread_t *vout, vout_window_t *window) void vout_DeleteDisplayWindow(vout_thread_t *vout, vout_window_t *window)
{ {
if (window == NULL && vout->p->window.object != NULL) { if (window == NULL && vout->p->window != NULL) {
vout_window_Delete(vout->p->window.object); vout_window_Delete(vout->p->window);
vout->p->window.object = NULL; vout->p->window = NULL;
} }
assert(vout->p->window.object == window); assert(vout->p->window == window);
} }
/* */ /* */
...@@ -1382,7 +1381,6 @@ static void ThreadStop(vout_thread_t *vout, vout_display_state_t *state) ...@@ -1382,7 +1381,6 @@ static void ThreadStop(vout_thread_t *vout, vout_display_state_t *state)
static void ThreadInit(vout_thread_t *vout) static void ThreadInit(vout_thread_t *vout)
{ {
vout->p->window.object = NULL;
vout->p->dead = false; vout->p->dead = false;
vout->p->is_late_dropped = var_InheritBool(vout, "drop-late-frames"); vout->p->is_late_dropped = var_InheritBool(vout, "drop-late-frames");
vout->p->pause.is_on = false; vout->p->pause.is_on = false;
...@@ -1393,8 +1391,8 @@ static void ThreadInit(vout_thread_t *vout) ...@@ -1393,8 +1391,8 @@ static void ThreadInit(vout_thread_t *vout)
static void ThreadClean(vout_thread_t *vout) static void ThreadClean(vout_thread_t *vout)
{ {
if (vout->p->window.object != NULL) if (vout->p->window != NULL)
vout_window_Delete(vout->p->window.object); vout_window_Delete(vout->p->window);
vout_chrono_Clean(&vout->p->render); vout_chrono_Clean(&vout->p->render);
vout->p->dead = true; vout->p->dead = true;
vout_control_Dead(&vout->p->control); vout_control_Dead(&vout->p->control);
......
...@@ -69,10 +69,7 @@ struct vout_thread_sys_t ...@@ -69,10 +69,7 @@ struct vout_thread_sys_t
filter_t *spu_blend; filter_t *spu_blend;
/* Video output window */ /* Video output window */
struct { vout_window_t *window;
vout_window_cfg_t cfg;
vout_window_t *object;
} window;
/* Thread & synchronization */ /* Thread & synchronization */
vlc_thread_t thread; vlc_thread_t thread;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment