[vlc-commits] interop_cvpx: hold previous texture on iOS too
Alexandre Janniaux
git at videolan.org
Fri Jan 29 11:06:29 UTC 2021
vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Thu Jan 28 17:57:44 2021 +0100| [0b68f2cf79a66c6db9b6192e451963f9900160a2] | committer: Alexandre Janniaux
interop_cvpx: hold previous texture on iOS too
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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0b68f2cf79a66c6db9b6192e451963f9900160a2
---
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,
More information about the vlc-commits
mailing list