[vlc-devel] [PATCH v3 06/10] video_output: conditionnally render on display
Alexandre Janniaux
ajanni at videolabs.io
Tue Feb 16 15:25:46 UTC 2021
Don't prepare/display if rendering is disabled. Rendering can only be
disabled when taking the display_lock so the prepare/display cannot be
done partially because of this patch.
---
src/video_output/video_output.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 489d5205e6..fdcf6e6981 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -146,6 +146,7 @@ typedef struct vout_thread_sys_t
vout_display_cfg_t display_cfg;
vout_display_t *display;
vlc_mutex_t display_lock;
+ vlc_mutex_t render_lock;
/* Video filter2 chain */
struct {
@@ -660,9 +661,9 @@ void vout_ChangeDisplayRenderingEnabled(vout_thread_t *vout, bool enabled)
{
vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
assert(!sys->dummy);
- vlc_mutex_lock(&sys->display_lock);
+ vlc_mutex_lock(&sys->render_lock);
sys->rendering_enabled = enabled;
- vlc_mutex_unlock(&sys->display_lock);
+ vlc_mutex_unlock(&sys->render_lock);
}
void vout_ControlChangeFilters(vout_thread_t *vout, const char *filters)
@@ -1117,6 +1118,8 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now)
// hold it as the filter chain will release it or return it and we release it
picture_Hold(sys->displayed.current);
+ vlc_mutex_lock(&sys->render_lock);
+
vout_chrono_Start(&sys->render);
vlc_mutex_lock(&sys->filter.lock);
@@ -1124,7 +1127,10 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now)
vlc_mutex_unlock(&sys->filter.lock);
if (!filtered)
+ {
+ vlc_mutex_unlock(&sys->render_lock);
return VLC_EGENERIC;
+ }
if (filtered->date != sys->displayed.current->date)
msg_Warn(&vout->obj, "Unsupported timestamp modifications done by chain_interactive");
@@ -1273,6 +1279,7 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now)
todisplay = vout_ConvertForDisplay(vd, todisplay);
if (todisplay == NULL) {
vlc_mutex_unlock(&sys->display_lock);
+ vlc_mutex_unlock(&sys->render_lock);
if (subpic != NULL)
subpicture_Delete(subpic);
@@ -1298,10 +1305,13 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now)
const unsigned frame_rate = todisplay->format.i_frame_rate;
const unsigned frame_rate_base = todisplay->format.i_frame_rate_base;
- if (vd->ops->prepare != NULL)
- vd->ops->prepare(vd, todisplay, do_dr_spu ? subpic : NULL, system_pts);
+ if (sys->rendering_enabled)
+ {
+ if (vd->ops->prepare != NULL)
+ vd->ops->prepare(vd, todisplay, do_dr_spu ? subpic : NULL, system_pts);
- vout_chrono_Stop(&sys->render);
+ vout_chrono_Stop(&sys->render);
+ }
#if 0
{
static int i = 0;
@@ -1345,8 +1355,13 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now)
frame_rate, frame_rate_base);
/* Display the direct buffer returned by vout_RenderPicture */
- vout_display_Display(vd, todisplay);
+ if (sys->rendering_enabled)
+ vout_display_Display(vd, todisplay);
+ else
+ picture_Release(todisplay);
+
vlc_mutex_unlock(&sys->display_lock);
+ vlc_mutex_unlock(&sys->render_lock);
if (subpic)
subpicture_Delete(subpic);
@@ -2021,6 +2036,7 @@ vout_thread_t *vout_Create(vlc_object_t *object)
/* Display */
sys->display = NULL;
vlc_mutex_init(&sys->display_lock);
+ vlc_mutex_init(&sys->render_lock);
/* Window */
sys->window_width = sys->window_height = 0;
--
2.30.1
More information about the vlc-devel
mailing list