summaryrefslogtreecommitdiffstats
path: root/recipes-multimedia/onevpl/onevpl/0001-sample_common-Fix-regression-of-missing-mutex-init.patch
blob: eaf494054dedc776d89a465507d0b1a62075c2d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From f6f9d62817d58909fe9eafa555b1638f165dc746 Mon Sep 17 00:00:00 2001
From: "Yew, Chang Ching" <chang.ching.yew@intel.com>
Date: Wed, 2 Mar 2022 07:56:57 +0800
Subject: [PATCH] sample_common: Fix regression of missing mutex init

Upstream-Status: Submitted
innersource PR #377

Signed-off-by: Yew, Chang Ching <chang.ching.yew@intel.com>
---
 tools/legacy/sample_common/src/vm/thread_linux.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tools/legacy/sample_common/src/vm/thread_linux.cpp b/tools/legacy/sample_common/src/vm/thread_linux.cpp
index 819d811f..c17ce5bf 100644
--- a/tools/legacy/sample_common/src/vm/thread_linux.cpp
+++ b/tools/legacy/sample_common/src/vm/thread_linux.cpp
@@ -22,6 +22,13 @@ MSDKSemaphore::MSDKSemaphore(mfxStatus& sts, mfxU32 count) : msdkSemaphoreHandle
         // If pthread_cond_init reports an error m_semaphore was not allocated
         throw std::bad_alloc();
     }
+    res = pthread_mutex_init(&m_mutex, NULL);
+    if (res) {
+        if (!pthread_cond_destroy(&m_semaphore)) {
+            // do nothing
+        }
+        throw std::bad_alloc();
+    }
 }
 
 MSDKSemaphore::~MSDKSemaphore(void) {
@@ -97,6 +104,13 @@ MSDKEvent::MSDKEvent(mfxStatus& sts, bool manual, bool state) : msdkEventHandle(
         //non-zero means something is wrong, throw bad_alloc
         throw std::bad_alloc();
     }
+    res = pthread_mutex_init(&m_mutex, NULL);
+    if (res) {
+        if (!pthread_cond_destroy(&m_event)) {
+            // do nothing
+        }
+        throw std::bad_alloc();
+    }
 }
 
 MSDKEvent::~MSDKEvent(void) {
-- 
2.17.1