[vlc-devel] [PATCH 6/6] interop_cvpx: hold previous texture on iOS too
Alexandre Janniaux
ajanni at videolabs.io
Thu Jan 28 16:57:44 UTC 2021
Otherwise, the buffer might get written while being in use in the
interop. This also initialize the initial stored picture to NULL
which was initialized through calloc on MacOSX.
---
modules/video_output/opengl/interop_cvpx.m | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/modules/video_output/opengl/interop_cvpx.m b/modules/video_output/opengl/interop_cvpx.m
index ec8681d174..abe95721d0 100644
--- a/modules/video_output/opengl/interop_cvpx.m
+++ b/modules/video_output/opengl/interop_cvpx.m
@@ -42,9 +42,9 @@ struct priv
CVOpenGLESTextureCacheRef cache;
CVOpenGLESTextureRef last_cvtexs[PICTURE_PLANE_MAX];
#else
- picture_t *last_pic;
CGLContextObj gl_ctx;
#endif
+ picture_t *last_pic;
};
#if TARGET_OS_IPHONE
@@ -68,6 +68,10 @@ tc_cvpx_update(const struct vlc_gl_interop *interop, GLuint *textures,
}
}
+ if (priv->last_pic != NULL)
+ picture_Release(priv->last_pic);
+ priv->last_pic = picture_Hold(pic);
+
CVOpenGLESTextureCacheFlush(priv->cache, 0);
for (unsigned i = 0; i < interop->tex_count; ++i)
@@ -132,12 +136,9 @@ tc_cvpx_update(const struct vlc_gl_interop *interop, GLuint *textures,
}
}
- if (priv->last_pic != pic)
- {
- if (priv->last_pic != NULL)
- picture_Release(priv->last_pic);
- priv->last_pic = picture_Hold(pic);
- }
+ if (priv->last_pic != NULL)
+ picture_Release(priv->last_pic);
+ priv->last_pic = picture_Hold(pic);
return VLC_SUCCESS;
}
@@ -155,10 +156,9 @@ Close(struct vlc_gl_interop *interop)
CFRelease(priv->last_cvtexs[i]);
}
CFRelease(priv->cache);
-#else
+#endif
if (priv->last_pic != NULL)
picture_Release(priv->last_pic);
-#endif
free(priv);
}
@@ -283,6 +283,8 @@ Open(vlc_object_t *obj)
for (unsigned i = 0; i < interop->tex_count; ++i)
priv->last_cvtexs[i] = NULL;
#endif
+
+ priv->last_pic = NULL;
interop->priv = priv;
static const struct vlc_gl_interop_ops ops = {
.update_textures = tc_cvpx_update,
--
2.30.0
More information about the vlc-devel
mailing list