summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Denis-Courmont <remid@nvidia.com>2014-10-29 14:47:01 +0200
committerAaron Plattner <aplattner@nvidia.com>2014-11-04 15:51:17 -0800
commit9899f7b79f4c33b05d27b0409ab17268dc476b06 (patch)
treec148846c6ea4fbe152ea1e98ab8a9f9551bea4f4
parentc285f0a78cb87340dc9d6a373f69c92ad95f3fe2 (diff)
vdpau_wrapper: make initialization of library handles thread-safe
Reviewed-by: Aaron Plattner <aplattner@nvidia.com> Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
-rw-r--r--src/vdpau_wrapper.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/vdpau_wrapper.c b/src/vdpau_wrapper.c
index 8f263c5..7cbdda5 100644
--- a/src/vdpau_wrapper.c
+++ b/src/vdpau_wrapper.c
@@ -398,17 +398,21 @@ VdpStatus vdp_device_create_x11(
)
{
static pthread_once_t once = PTHREAD_ONCE_INIT;
- VdpStatus status;
+ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+ VdpStatus status = VDP_STATUS_OK;
pthread_once(&once, init_fixes);
+ pthread_mutex_lock(&lock);
if (!_vdp_imp_device_create_x11_proc) {
status = _vdp_open_driver(display, screen);
- if (status != VDP_STATUS_OK) {
+ if (status != VDP_STATUS_OK)
_vdp_close_driver();
- return status;
- }
}
+ pthread_mutex_unlock(&lock);
+
+ if (status != VDP_STATUS_OK)
+ return status;
status = _vdp_imp_device_create_x11_proc(
display,