diff options
author | Pawit Pornkitprasan <p.pawit@gmail.com> | 2012-05-13 20:51:07 +0700 |
---|---|---|
committer | Pawit Pornkitprasan <p.pawit@gmail.com> | 2012-05-13 20:57:23 +0700 |
commit | 1225284123d6e87f8dcde679d56206dfcf65451d (patch) | |
tree | a9914a25fd9e69524b35b7f4a8a23d2cec035f35 | |
parent | 95844c3271a0423c1ea86614a5a568279c7eb60d (diff) | |
download | device_samsung_aries-common-1225284123d6e87f8dcde679d56206dfcf65451d.zip device_samsung_aries-common-1225284123d6e87f8dcde679d56206dfcf65451d.tar.gz device_samsung_aries-common-1225284123d6e87f8dcde679d56206dfcf65451d.tar.bz2 |
liboverlay: Lock overlay_queueBuffer properly
The old lock was too loose causing the overlay to fail with the
rotation animation. (Camera, YouTube)
Fixes bugs: 4907, 4909
Change-Id: I6d03b4b6d0011121ff01e8cd3b87dce17032f5e7
-rw-r--r-- | liboverlay/overlay.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp index d0a4289..f3de2e7 100644 --- a/liboverlay/overlay.cpp +++ b/liboverlay/overlay.cpp @@ -1332,29 +1332,34 @@ int overlay_dequeueBuffer(struct overlay_data_device_t *dev, int overlay_queueBuffer(struct overlay_data_device_t *dev, overlay_buffer_t buffer) { struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; - int cnt = 0; + int rc; pthread_mutex_lock(&ctx->shared->lock); if ( ctx->shared->streamingReset ) { ctx->shared->streamingReset = 0; - pthread_mutex_unlock(&ctx->shared->lock); - return ALL_BUFFERS_FLUSHED; + rc = ALL_BUFFERS_FLUSHED; + goto end; } - pthread_mutex_unlock(&ctx->shared->lock); /* Catch the case where the data side had no need to set the crop window */ if (!ctx->shared->dataReady) { ctx->shared->dataReady = 1; - enable_streaming(ctx->shared, ctx->ctl_fd); + enable_streaming_locked(ctx->shared, ctx->ctl_fd); } - if (!ctx->shared->controlReady) return -1; - int rc = v4l2_overlay_q_buf( ctx->ctl_fd, (int)buffer, (int) ctx->zerocopy ); + if (!ctx->shared->controlReady) { + rc = -1; + goto end; + } + + rc = v4l2_overlay_q_buf( ctx->ctl_fd, (int)buffer, (int) ctx->zerocopy ); if (rc == 0 && ctx->qd_buf_count < ctx->num_buffers) { ctx->qd_buf_count ++; } +end: + pthread_mutex_unlock(&ctx->shared->lock); return rc; } |