aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/out/opengl
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2016-04-07 19:55:51 +0200
committerGravatar wm4 <wm4@nowhere>2016-04-07 19:55:51 +0200
commit081271949700849fa4b30e0ca4865ec93f09c5ae (patch)
treef25cd4515908c0f8feebe63e24932a2e439cb56b /video/out/opengl
parentf03348155152b982f6eede1ec021a00a94a21d5a (diff)
vo_opengl: videotoolbox: use kCVPixelBufferLock_ReadOnly for screenshots
Why not.
Diffstat (limited to 'video/out/opengl')
-rw-r--r--video/out/opengl/hwdec_osx.c15
1 files changed, 8 insertions, 7 deletions
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;
}