[vlc-devel] [PATCH 15/17] video_output: do the VoutFixFormat in vout_ChangeSource()
Steve Lhomme
robux4 at ycbcr.xyz
Fri Nov 20 15:45:05 CET 2020
And keep the fixed format in sys->original unconditionally. If vout_Request()
fails, it doesn't matter if we updated sys->original. The vout is not usable.
---
src/video_output/video_output.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index a92c185275f..dc4d5160e24 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -2181,15 +2181,18 @@ int vout_ChangeSource( vout_thread_t *vout, const video_format_t *original )
{
vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
+ video_format_t fixed_original;
+ VoutFixFormat(&fixed_original, original);
+
/* TODO: If dimensions are equal or slightly smaller, update the aspect
* ratio and crop settings, instead of recreating a display.
*/
- if (video_format_IsSimilar(original, &sys->original)) {
- /* It is assumed that the SPU input matches input already. */
- return 0;
- }
+ bool similar = video_format_IsSimilar(&fixed_original, &sys->original);
+ video_format_Clean(&sys->original);
+ sys->original = fixed_original;
- return -1;
+ /* It is assumed that the SPU input matches input already. */
+ return similar ? 0 : -1;
}
static int EnableWindowLocked(vout_thread_sys_t *vout, const video_format_t *original)
@@ -2275,23 +2278,17 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input
/* don't stop the display and keep sys->original */
return -1;
- video_format_t original;
- VoutFixFormat(&original, cfg->fmt);
-
- if (vout_ChangeSource(cfg->vout, &original) == 0)
- {
- video_format_Clean(&original);
+ if (vout_ChangeSource(cfg->vout, cfg->fmt) == 0)
return 0;
- }
vlc_mutex_lock(&sys->window_lock);
vout_InitSource(vout);
- if (EnableWindowLocked(vout, &original) != 0)
+ if (EnableWindowLocked(vout, &sys->original) != 0)
{
/* the window was not enabled, nor the display started */
msg_Err(cfg->vout, "failed to enable window");
- video_format_Clean(&original);
+ video_format_Clean(&sys->original);
vlc_mutex_unlock(&sys->window_lock);
return -1;
}
@@ -2302,8 +2299,6 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input
vout_ReinitInterlacingSupport(cfg->vout, &sys->private);
- sys->original = original;
-
sys->delay = 0;
sys->rate = 1.f;
sys->clock = cfg->clock;
--
2.26.2
More information about the vlc-devel
mailing list