From 081271949700849fa4b30e0ca4865ec93f09c5ae Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 7 Apr 2016 19:55:51 +0200 Subject: vo_opengl: videotoolbox: use kCVPixelBufferLock_ReadOnly for screenshots Why not. --- video/out/opengl/hwdec_osx.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'video/out/opengl') diff --git a/video/out/opengl/hwdec_osx.c b/video/out/opengl/hwdec_osx.c index 3046768604..addc16f404 100644 --- a/video/out/opengl/hwdec_osx.c +++ b/video/out/opengl/hwdec_osx.c @@ -101,16 +101,15 @@ static struct mp_image *download_image(struct mp_hwdec_ctx *ctx, if (hw_image->imgfmt != IMGFMT_VIDEOTOOLBOX) return NULL; + struct mp_image *image = NULL; CVPixelBufferRef pbuf = (CVPixelBufferRef)hw_image->planes[3]; - CVPixelBufferLockBaseAddress(pbuf, 0); + CVPixelBufferLockBaseAddress(pbuf, kCVPixelBufferLock_ReadOnly); size_t width = CVPixelBufferGetWidth(pbuf); size_t height = CVPixelBufferGetHeight(pbuf); uint32_t cvpixfmt = CVPixelBufferGetPixelFormatType(pbuf); struct vt_format *f = vt_get_gl_format(cvpixfmt); - if (!f) { - CVPixelBufferUnlockBaseAddress(pbuf, 0); - return NULL; - } + if (!f) + goto unlock; struct mp_image img = {0}; mp_image_setfmt(&img, f->imgfmt); @@ -125,8 +124,10 @@ static struct mp_image *download_image(struct mp_hwdec_ctx *ctx, mp_image_copy_attributes(&img, hw_image); - struct mp_image *image = mp_image_pool_new_copy(swpool, &img); - CVPixelBufferUnlockBaseAddress(pbuf, 0); + image = mp_image_pool_new_copy(swpool, &img); + +unlock: + CVPixelBufferUnlockBaseAddress(pbuf, kCVPixelBufferLock_ReadOnly); return image; } -- cgit v1.2.3