[vlc-commits] video_output: group the code to setup and load the display module in a function
Steve Lhomme
git at videolan.org
Tue Jan 19 12:29:57 UTC 2021
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Nov 20 09:25:12 2020 +0100| [2b54a76461d6ee5baeab2386dd405e7913e4f85f] | committer: Steve Lhomme
video_output: group the code to setup and load the display module in a function
vout_Start is also handling filter setup.
The function must be called under display lock. The crop and aspect ratio
values need to be read under window lock.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2b54a76461d6ee5baeab2386dd405e7913e4f85f
---
src/video_output/video_output.c | 66 ++++++++++++++++++++++++++---------------
1 file changed, 42 insertions(+), 24 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 6d6e4af71d..758caf01c6 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1731,6 +1731,39 @@ static void ThreadProcessMouseState(vout_thread_sys_t *p_vout,
sys->mouse_event(m, sys->mouse_opaque);
}
+static int vout_StartDisplayLocked(vout_thread_sys_t *vout,
+ const video_format_t *fmt, vlc_video_context *vctx,
+ const vout_display_cfg_t *cfg,
+ const vlc_rational_t *dar, const vlc_rational_t *crop,
+ int x, int y, int w, int h)
+{
+ vout_thread_sys_t *sys = vout;
+ sys->private.display_pool = NULL;
+ sys->private.private_pool = NULL;
+
+ vout_display_cfg_t dcfg = *cfg;
+
+ /* Setup the window size, protected by the display_lock */
+ dcfg.window_props.width = sys->window_width;
+ dcfg.window_props.height = sys->window_height;
+
+ // original is used both as decoder output and display input
+ video_format_Clean(&sys->original);
+ video_format_Copy(&sys->original, fmt);
+
+ sys->display = vout_OpenWrapper(&vout->obj, &sys->private, sys->splitter_name, &dcfg,
+ fmt, vctx);
+ if (sys->display == NULL)
+ return VLC_EGENERIC;
+
+ vout_SetDisplayCrop(sys->display, crop->num, crop->den, x, y, w, h);
+
+ if (dar->num != 0 && dar->den != 0)
+ vout_SetDisplayAspect(sys->display, dar->num, dar->den);
+
+ return VLC_SUCCESS;
+}
+
static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vout_configuration_t *cfg)
{
vout_thread_sys_t *sys = vout;
@@ -1741,8 +1774,6 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
vlc_mouse_Init(&sys->mouse);
sys->decoder_fifo = picture_fifo_New();
- sys->private.display_pool = NULL;
- sys->private.private_pool = NULL;
sys->filter.configuration = NULL;
video_format_Copy(&sys->filter.src_fmt, &sys->original);
@@ -1764,9 +1795,6 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
sys->filter.chain_interactive = filter_chain_NewVideo(&vout->obj, true, &owner);
vout_display_cfg_t dcfg;
- int x = 0, y = 0, w = 0, h = 0;
- unsigned crop_num = 0, crop_den = 0;
- unsigned num, den;
vlc_mutex_lock(&sys->window_lock);
#ifndef NDEBUG
@@ -1781,12 +1809,14 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
dcfg = sys->display_cfg;
+ int x = 0, y = 0, w = 0, h = 0;
+ vlc_rational_t crop = {0};
switch (sys->source.crop.mode) {
case VOUT_CROP_NONE:
break;
case VOUT_CROP_RATIO:
- crop_num = sys->source.crop.ratio.num;
- crop_den = sys->source.crop.ratio.den;
+ crop = (vlc_rational_t) { sys->source.crop.ratio.num,
+ sys->source.crop.ratio.den };
break;
case VOUT_CROP_WINDOW:
x = sys->source.crop.window.x;
@@ -1802,27 +1832,15 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
break;
}
- num = sys->source.dar.num;
- den = sys->source.dar.den;
+ vlc_rational_t dar = (vlc_rational_t) { sys->source.dar.num, sys->source.dar.den };
vlc_mutex_lock(&sys->display_lock);
vlc_mutex_unlock(&sys->window_lock);
- /* Setup the window size, protected by the display_lock */
- dcfg.window_props.width = sys->window_width;
- dcfg.window_props.height = sys->window_height;
-
- sys->display = vout_OpenWrapper(&vout->obj, &sys->private, sys->splitter_name, &dcfg,
- &sys->original, vctx);
- if (sys->display == NULL) {
- vlc_mutex_unlock(&sys->display_lock);
- goto error;
- }
-
- vout_SetDisplayCrop(sys->display, crop_num, crop_den, x, y, w, h);
-
- if (num != 0 && den != 0)
- vout_SetDisplayAspect(sys->display, num, den);
+ int err = vout_StartDisplayLocked(vout, &sys->original, vctx, &dcfg,
+ &dar, &crop, x, y, h, w);
vlc_mutex_unlock(&sys->display_lock);
+ if (err != VLC_SUCCESS)
+ goto error;
assert(sys->private.display_pool != NULL && sys->private.private_pool != NULL);
More information about the vlc-commits
mailing list