From 61553b2b28ebe6b39046c93c0cf5a59a72f3e3b4 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Tue, 18 Dec 2012 15:59:13 -0500
Subject: [PATCH] * #18668: call: use pthread_mutex

---
 daemon/src/call.cpp | 20 ++++++++++++--------
 daemon/src/call.h   |  4 ++--
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/daemon/src/call.cpp b/daemon/src/call.cpp
index 704a75f855..bd0668da3f 100644
--- a/daemon/src/call.cpp
+++ b/daemon/src/call.cpp
@@ -32,6 +32,7 @@
 #include "manager.h"
 #include "audio/mainbuffer.h"
 #include "history/historyitem.h"
+#include "scoped_lock.h"
 
 Call::Call(const std::string& id, Call::CallType type)
     : callMutex_()
@@ -49,37 +50,40 @@ Call::Call(const std::string& id, Call::CallType type)
     , timestamp_start_(0)
     , timestamp_stop_(0)
 {
+    pthread_mutex_init(&callMutex_, NULL);
     time(&timestamp_start_);
 }
 
 Call::~Call()
-{}
+{
+    pthread_mutex_destroy(&callMutex_);
+}
 
 void
 Call::setConnectionState(ConnectionState state)
 {
-    ost::MutexLock m(callMutex_);
+    sfl::ScopedLock m(callMutex_);
     connectionState_ = state;
 }
 
 Call::ConnectionState
 Call::getConnectionState()
 {
-    ost::MutexLock m(callMutex_);
+    sfl::ScopedLock m(callMutex_);
     return connectionState_;
 }
 
 void
 Call::setState(CallState state)
 {
-    ost::MutexLock m(callMutex_);
+    sfl::ScopedLock m(callMutex_);
     callState_ = state;
 }
 
 Call::CallState
 Call::getState()
 {
-    ost::MutexLock m(callMutex_);
+    sfl::ScopedLock m(callMutex_);
     return callState_;
 }
 
@@ -124,21 +128,21 @@ Call::getStateStr()
 std::string
 Call::getLocalIp()
 {
-    ost::MutexLock m(callMutex_);
+    sfl::ScopedLock m(callMutex_);
     return localIPAddress_;
 }
 
 unsigned int
 Call::getLocalAudioPort()
 {
-    ost::MutexLock m(callMutex_);
+    sfl::ScopedLock m(callMutex_);
     return localAudioPort_;
 }
 
 unsigned int
 Call::getLocalVideoPort()
 {
-    ost::MutexLock m (callMutex_);
+    sfl::ScopedLock m(callMutex_);
     return localVideoPort_;
 }
 
diff --git a/daemon/src/call.h b/daemon/src/call.h
index 281f896724..c637c311cd 100644
--- a/daemon/src/call.h
+++ b/daemon/src/call.h
@@ -34,7 +34,7 @@
 
 #include <sstream>
 #include <map>
-#include "cc_thread.h"
+#include <pthread.h>
 #include "audio/recordable.h"
 
 /*
@@ -229,7 +229,7 @@ class Call : public Recordable {
     private:
         std::string getTypeStr() const;
         /** Protect every attribute that can be changed by two threads */
-        ost::Mutex callMutex_;
+        pthread_mutex_t callMutex_;
 
         // Informations about call socket / audio
 
-- 
GitLab