Skip to content
Snippets Groups Projects
Commit 7531c4df authored by Adrien Béraud's avatar Adrien Béraud
Browse files

revert bug in pulseaudio

parent bb88a719
Branches
Tags
No related merge requests found
...@@ -48,7 +48,7 @@ class AudioStream; ...@@ -48,7 +48,7 @@ class AudioStream;
/** /**
* Convenience structure to hold PulseAudio device propreties such as supported channel number etc. * Convenience structure to hold PulseAudio device propreties such as supported channel number etc.
*/ */
typedef struct { typedef struct PaDeviceInfos {
uint32_t index; uint32_t index;
std::string name; std::string name;
pa_sample_spec sample_spec; pa_sample_spec sample_spec;
......
...@@ -78,14 +78,13 @@ ...@@ -78,14 +78,13 @@
#endif #endif
#include "conference.h" #include "conference.h"
#include "scoped_lock.h"
#include <cerrno> #include <cerrno>
#include <algorithm> #include <algorithm>
#include <ctime> #include <ctime>
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include <tr1/functional> #include <functional>
#include <iterator> #include <iterator>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
...@@ -102,21 +101,12 @@ ManagerImpl::ManagerImpl() : ...@@ -102,21 +101,12 @@ ManagerImpl::ManagerImpl() :
waitingCalls_(), waitingCallsMutex_(), path_(), waitingCalls_(), waitingCallsMutex_(), path_(),
IPToIPMap_(), mainBuffer_(), conferenceMap_(), history_(), finished_(false) IPToIPMap_(), mainBuffer_(), conferenceMap_(), history_(), finished_(false)
{ {
pthread_mutex_init(&currentCallMutex_, NULL);
pthread_mutex_init(&toneMutex_, NULL);
pthread_mutex_init(&audioLayerMutex_, NULL);
pthread_mutex_init(&waitingCallsMutex_, NULL);
// initialize random generator for call id // initialize random generator for call id
srand(time(NULL)); srand(time(NULL));
} }
ManagerImpl::~ManagerImpl() ManagerImpl::~ManagerImpl()
{ {
// destroy in reverse order of initialization
pthread_mutex_destroy(&waitingCallsMutex_);
pthread_mutex_destroy(&audioLayerMutex_);
pthread_mutex_destroy(&toneMutex_);
pthread_mutex_destroy(&currentCallMutex_);
} }
namespace { namespace {
...@@ -207,10 +197,10 @@ void ManagerImpl::init(const std::string &config_file) ...@@ -207,10 +197,10 @@ void ManagerImpl::init(const std::string &config_file)
initAudioDriver(); initAudioDriver();
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
if (audiodriver_) { if (audiodriver_) {
{ {
sfl::ScopedLock toneLock(toneMutex_); std::lock_guard<std::mutex> toneLock(toneMutex_);
telephoneTone_.reset(new TelephoneTone(preferences.getZoneToneChoice(), audiodriver_->getSampleRate())); telephoneTone_.reset(new TelephoneTone(preferences.getZoneToneChoice(), audiodriver_->getSampleRate()));
} }
dtmfKey_.reset(new DTMF(getMainBuffer().getInternalSamplingRate())); dtmfKey_.reset(new DTMF(getMainBuffer().getInternalSamplingRate()));
...@@ -260,7 +250,7 @@ void ManagerImpl::finish() ...@@ -260,7 +250,7 @@ void ManagerImpl::finish()
#endif #endif
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
delete audiodriver_; delete audiodriver_;
audiodriver_ = NULL; audiodriver_ = NULL;
...@@ -292,7 +282,7 @@ void ManagerImpl::unsetCurrentCall() ...@@ -292,7 +282,7 @@ void ManagerImpl::unsetCurrentCall()
void ManagerImpl::switchCall(const std::string& id) void ManagerImpl::switchCall(const std::string& id)
{ {
sfl::ScopedLock m(currentCallMutex_); std::lock_guard<std::mutex> m(currentCallMutex_);
DEBUG("----- Switch current call id to %s -----", id.c_str()); DEBUG("----- Switch current call id to %s -----", id.c_str());
currentCallId_ = id; currentCallId_ = id;
} }
...@@ -447,7 +437,7 @@ bool ManagerImpl::answerCall(const std::string& call_id) ...@@ -447,7 +437,7 @@ bool ManagerImpl::answerCall(const std::string& call_id)
void ManagerImpl::checkAudio() void ManagerImpl::checkAudio()
{ {
if (getCallList().empty()) { if (getCallList().empty()) {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
if (audiodriver_) if (audiodriver_)
audiodriver_->stopStream(); audiodriver_->stopStream();
} }
...@@ -699,7 +689,7 @@ bool ManagerImpl::refuseCall(const std::string& id) ...@@ -699,7 +689,7 @@ bool ManagerImpl::refuseCall(const std::string& id)
stopTone(); stopTone();
if (getCallList().size() <= 1) { if (getCallList().size() <= 1) {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
audiodriver_->stopStream(); audiodriver_->stopStream();
} }
...@@ -961,7 +951,7 @@ ManagerImpl::addMainParticipant(const std::string& conference_id) ...@@ -961,7 +951,7 @@ ManagerImpl::addMainParticipant(const std::string& conference_id)
} }
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
ConferenceMap::const_iterator iter = conferenceMap_.find(conference_id); ConferenceMap::const_iterator iter = conferenceMap_.find(conference_id);
...@@ -1106,7 +1096,7 @@ ManagerImpl::joinParticipant(const std::string& callId1, const std::string& call ...@@ -1106,7 +1096,7 @@ ManagerImpl::joinParticipant(const std::string& callId1, const std::string& call
// set recording sampling rate // set recording sampling rate
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
if (audiodriver_) if (audiodriver_)
conf->setRecordingSmplRate(audiodriver_->getSampleRate()); conf->setRecordingSmplRate(audiodriver_->getSampleRate());
} }
...@@ -1157,7 +1147,7 @@ void ManagerImpl::createConfFromParticipantList(const std::vector< std::string > ...@@ -1157,7 +1147,7 @@ void ManagerImpl::createConfFromParticipantList(const std::vector< std::string >
client_.getCallManager()->conferenceCreated(conf->getConfID()); client_.getCallManager()->conferenceCreated(conf->getConfID());
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
if (audiodriver_) if (audiodriver_)
conf->setRecordingSmplRate(audiodriver_->getSampleRate()); conf->setRecordingSmplRate(audiodriver_->getSampleRate());
...@@ -1351,7 +1341,7 @@ void ManagerImpl::addStream(const std::string& call_id) ...@@ -1351,7 +1341,7 @@ void ManagerImpl::addStream(const std::string& call_id)
// bind to main // bind to main
getMainBuffer().bindCallID(call_id, MainBuffer::DEFAULT_ID); getMainBuffer().bindCallID(call_id, MainBuffer::DEFAULT_ID);
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
audiodriver_->flushUrgent(); audiodriver_->flushUrgent();
audiodriver_->flushMain(); audiodriver_->flushMain();
} }
...@@ -1432,7 +1422,7 @@ void ManagerImpl::playDtmf(char code) ...@@ -1432,7 +1422,7 @@ void ManagerImpl::playDtmf(char code)
return; return;
} }
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
// numbers of int = length in milliseconds / 1000 (number of seconds) // numbers of int = length in milliseconds / 1000 (number of seconds)
// = number of seconds * SAMPLING_RATE by SECONDS // = number of seconds * SAMPLING_RATE by SECONDS
...@@ -1473,19 +1463,19 @@ void ManagerImpl::playDtmf(char code) ...@@ -1473,19 +1463,19 @@ void ManagerImpl::playDtmf(char code)
// Multi-thread // Multi-thread
bool ManagerImpl::incomingCallsWaiting() bool ManagerImpl::incomingCallsWaiting()
{ {
sfl::ScopedLock m(waitingCallsMutex_); std::lock_guard<std::mutex> m(waitingCallsMutex_);
return not waitingCalls_.empty(); return not waitingCalls_.empty();
} }
void ManagerImpl::addWaitingCall(const std::string& id) void ManagerImpl::addWaitingCall(const std::string& id)
{ {
sfl::ScopedLock m(waitingCallsMutex_); std::lock_guard<std::mutex> m(waitingCallsMutex_);
waitingCalls_.insert(id); waitingCalls_.insert(id);
} }
void ManagerImpl::removeWaitingCall(const std::string& id) void ManagerImpl::removeWaitingCall(const std::string& id)
{ {
sfl::ScopedLock m(waitingCallsMutex_); std::lock_guard<std::mutex> m(waitingCallsMutex_);
waitingCalls_.erase(id); waitingCalls_.erase(id);
} }
...@@ -1651,7 +1641,7 @@ void ManagerImpl::peerAnsweredCall(const std::string& id) ...@@ -1651,7 +1641,7 @@ void ManagerImpl::peerAnsweredCall(const std::string& id)
addStream(id); addStream(id);
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
audiodriver_->flushMain(); audiodriver_->flushMain();
audiodriver_->flushUrgent(); audiodriver_->flushUrgent();
} }
...@@ -1765,7 +1755,7 @@ void ManagerImpl::playATone(Tone::TONEID toneId) ...@@ -1765,7 +1755,7 @@ void ManagerImpl::playATone(Tone::TONEID toneId)
return; return;
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
if (audiodriver_ == NULL) { if (audiodriver_ == NULL) {
ERROR("Audio layer not initialized"); ERROR("Audio layer not initialized");
...@@ -1777,7 +1767,7 @@ void ManagerImpl::playATone(Tone::TONEID toneId) ...@@ -1777,7 +1767,7 @@ void ManagerImpl::playATone(Tone::TONEID toneId)
} }
{ {
sfl::ScopedLock lock(toneMutex_); std::lock_guard<std::mutex> lock(toneMutex_);
if (telephoneTone_.get() != 0) if (telephoneTone_.get() != 0)
telephoneTone_->setCurrentTone(toneId); telephoneTone_->setCurrentTone(toneId);
} }
...@@ -1791,7 +1781,7 @@ void ManagerImpl::stopTone() ...@@ -1791,7 +1781,7 @@ void ManagerImpl::stopTone()
if (not voipPreferences.getPlayTones()) if (not voipPreferences.getPlayTones())
return; return;
sfl::ScopedLock lock(toneMutex_); std::lock_guard<std::mutex> lock(toneMutex_);
if (telephoneTone_.get() != NULL) if (telephoneTone_.get() != NULL)
telephoneTone_->setCurrentTone(Tone::TONE_NULL); telephoneTone_->setCurrentTone(Tone::TONE_NULL);
...@@ -1874,7 +1864,7 @@ void ManagerImpl::playRingtone(const std::string& accountID) ...@@ -1874,7 +1864,7 @@ void ManagerImpl::playRingtone(const std::string& accountID)
int audioLayerSmplr = 8000; int audioLayerSmplr = 8000;
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
if (!audiodriver_) { if (!audiodriver_) {
ERROR("no audio layer in ringtone"); ERROR("no audio layer in ringtone");
...@@ -1885,7 +1875,7 @@ void ManagerImpl::playRingtone(const std::string& accountID) ...@@ -1885,7 +1875,7 @@ void ManagerImpl::playRingtone(const std::string& accountID)
} }
{ {
sfl::ScopedLock m(toneMutex_); std::lock_guard<std::mutex> m(toneMutex_);
if (audiofile_.get()) { if (audiofile_.get()) {
client_.getCallManager()->recordPlaybackStopped(audiofile_->getFilePath()); client_.getCallManager()->recordPlaybackStopped(audiofile_->getFilePath());
...@@ -1895,14 +1885,14 @@ void ManagerImpl::playRingtone(const std::string& accountID) ...@@ -1895,14 +1885,14 @@ void ManagerImpl::playRingtone(const std::string& accountID)
updateAudioFile(ringchoice, audioLayerSmplr); updateAudioFile(ringchoice, audioLayerSmplr);
} // leave mutex } // leave mutex
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
// start audio if not started AND flush all buffers (main and urgent) // start audio if not started AND flush all buffers (main and urgent)
audiodriver_->startStream(); audiodriver_->startStream();
} }
AudioLoop* ManagerImpl::getTelephoneTone() AudioLoop* ManagerImpl::getTelephoneTone()
{ {
sfl::ScopedLock m(toneMutex_); std::lock_guard<std::mutex> m(toneMutex_);
if (telephoneTone_.get()) if (telephoneTone_.get())
return telephoneTone_->getCurrentTone(); return telephoneTone_->getCurrentTone();
else else
...@@ -1912,7 +1902,7 @@ AudioLoop* ManagerImpl::getTelephoneTone() ...@@ -1912,7 +1902,7 @@ AudioLoop* ManagerImpl::getTelephoneTone()
AudioLoop* AudioLoop*
ManagerImpl::getTelephoneFile() ManagerImpl::getTelephoneFile()
{ {
sfl::ScopedLock m(toneMutex_); std::lock_guard<std::mutex> m(toneMutex_);
return audiofile_.get(); return audiofile_.get();
} }
...@@ -1979,7 +1969,7 @@ ManagerImpl::getCurrentVideoCodecName(const std::string& ID) ...@@ -1979,7 +1969,7 @@ ManagerImpl::getCurrentVideoCodecName(const std::string& ID)
*/ */
void ManagerImpl::setAudioPlugin(const std::string& audioPlugin) void ManagerImpl::setAudioPlugin(const std::string& audioPlugin)
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
audioPreference.setAlsaPlugin(audioPlugin); audioPreference.setAlsaPlugin(audioPlugin);
...@@ -1998,7 +1988,7 @@ void ManagerImpl::setAudioPlugin(const std::string& audioPlugin) ...@@ -1998,7 +1988,7 @@ void ManagerImpl::setAudioPlugin(const std::string& audioPlugin)
*/ */
void ManagerImpl::setAudioDevice(int index, AudioLayer::PCMType type) void ManagerImpl::setAudioDevice(int index, AudioLayer::PCMType type)
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
if (!audiodriver_) { if (!audiodriver_) {
ERROR("Audio driver not initialized"); ERROR("Audio driver not initialized");
...@@ -2021,7 +2011,7 @@ void ManagerImpl::setAudioDevice(int index, AudioLayer::PCMType type) ...@@ -2021,7 +2011,7 @@ void ManagerImpl::setAudioDevice(int index, AudioLayer::PCMType type)
*/ */
std::vector<std::string> ManagerImpl::getAudioOutputDeviceList() std::vector<std::string> ManagerImpl::getAudioOutputDeviceList()
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
return audiodriver_->getPlaybackDeviceList(); return audiodriver_->getPlaybackDeviceList();
} }
...@@ -2031,7 +2021,7 @@ std::vector<std::string> ManagerImpl::getAudioOutputDeviceList() ...@@ -2031,7 +2021,7 @@ std::vector<std::string> ManagerImpl::getAudioOutputDeviceList()
*/ */
std::vector<std::string> ManagerImpl::getAudioInputDeviceList() std::vector<std::string> ManagerImpl::getAudioInputDeviceList()
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
return audiodriver_->getCaptureDeviceList(); return audiodriver_->getCaptureDeviceList();
} }
...@@ -2040,7 +2030,7 @@ std::vector<std::string> ManagerImpl::getAudioInputDeviceList() ...@@ -2040,7 +2030,7 @@ std::vector<std::string> ManagerImpl::getAudioInputDeviceList()
*/ */
std::vector<std::string> ManagerImpl::getCurrentAudioDevicesIndex() std::vector<std::string> ManagerImpl::getCurrentAudioDevicesIndex()
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
std::vector<std::string> v; std::vector<std::string> v;
...@@ -2132,7 +2122,7 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath) ...@@ -2132,7 +2122,7 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath)
int sampleRate; int sampleRate;
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
if (!audiodriver_) { if (!audiodriver_) {
ERROR("No audio layer in start recorded file playback"); ERROR("No audio layer in start recorded file playback");
...@@ -2143,7 +2133,7 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath) ...@@ -2143,7 +2133,7 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath)
} }
{ {
sfl::ScopedLock m(toneMutex_); std::lock_guard<std::mutex> m(toneMutex_);
if (audiofile_.get()) { if (audiofile_.get()) {
client_.getCallManager()->recordPlaybackStopped(audiofile_->getFilePath()); client_.getCallManager()->recordPlaybackStopped(audiofile_->getFilePath());
...@@ -2155,15 +2145,17 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath) ...@@ -2155,15 +2145,17 @@ bool ManagerImpl::startRecordedFilePlayback(const std::string& filepath)
return false; return false;
} // release toneMutex } // release toneMutex
sfl::ScopedLock lock(audioLayerMutex_); {
std::lock_guard<std::mutex> lock(audioLayerMutex_);
audiodriver_->startStream(); audiodriver_->startStream();
}
return true; return true;
} }
void ManagerImpl::recordingPlaybackSeek(const double value) void ManagerImpl::recordingPlaybackSeek(const double value)
{ {
sfl::ScopedLock m(toneMutex_); std::lock_guard<std::mutex> m(toneMutex_);
if (audiofile_.get()) if (audiofile_.get())
audiofile_.get()->seek(value); audiofile_.get()->seek(value);
} }
...@@ -2174,12 +2166,12 @@ void ManagerImpl::stopRecordedFilePlayback(const std::string& filepath) ...@@ -2174,12 +2166,12 @@ void ManagerImpl::stopRecordedFilePlayback(const std::string& filepath)
DEBUG("Stop recorded file playback %s", filepath.c_str()); DEBUG("Stop recorded file playback %s", filepath.c_str());
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
audiodriver_->stopStream(); audiodriver_->stopStream();
} }
{ {
sfl::ScopedLock m(toneMutex_); std::lock_guard<std::mutex> m(toneMutex_);
audiofile_.reset(); audiofile_.reset();
} }
client_.getCallManager()->recordPlaybackStopped(filepath); client_.getCallManager()->recordPlaybackStopped(filepath);
...@@ -2200,7 +2192,7 @@ int ManagerImpl::getHistoryLimit() const ...@@ -2200,7 +2192,7 @@ int ManagerImpl::getHistoryLimit() const
void ManagerImpl::setAudioManager(const std::string &api) void ManagerImpl::setAudioManager(const std::string &api)
{ {
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
if (!audiodriver_) if (!audiodriver_)
return; return;
...@@ -2226,7 +2218,7 @@ int ManagerImpl::getAudioDeviceIndex(const std::string &name) ...@@ -2226,7 +2218,7 @@ int ManagerImpl::getAudioDeviceIndex(const std::string &name)
{ {
int soundCardIndex = 0; int soundCardIndex = 0;
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
if (audiodriver_ == NULL) { if (audiodriver_ == NULL) {
ERROR("Audio layer not initialized"); ERROR("Audio layer not initialized");
...@@ -2267,13 +2259,13 @@ void ManagerImpl::setEchoCancelState(const std::string &state) ...@@ -2267,13 +2259,13 @@ void ManagerImpl::setEchoCancelState(const std::string &state)
*/ */
void ManagerImpl::initAudioDriver() void ManagerImpl::initAudioDriver()
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
audiodriver_ = audioPreference.createAudioLayer(); audiodriver_ = audioPreference.createAudioLayer();
} }
void ManagerImpl::switchAudioManager() void ManagerImpl::switchAudioManager()
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
bool wasStarted = audiodriver_->isStarted(); bool wasStarted = audiodriver_->isStarted();
delete audiodriver_; delete audiodriver_;
...@@ -2285,7 +2277,7 @@ void ManagerImpl::switchAudioManager() ...@@ -2285,7 +2277,7 @@ void ManagerImpl::switchAudioManager()
void ManagerImpl::audioSamplingRateChanged(int samplerate) void ManagerImpl::audioSamplingRateChanged(int samplerate)
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
if (!audiodriver_) { if (!audiodriver_) {
DEBUG("No Audio driver initialized"); DEBUG("No Audio driver initialized");
...@@ -2311,7 +2303,7 @@ void ManagerImpl::audioSamplingRateChanged(int samplerate) ...@@ -2311,7 +2303,7 @@ void ManagerImpl::audioSamplingRateChanged(int samplerate)
unsigned int sampleRate = audiodriver_->getSampleRate(); unsigned int sampleRate = audiodriver_->getSampleRate();
{ {
sfl::ScopedLock toneLock(toneMutex_); std::lock_guard<std::mutex> toneLock(toneMutex_);
telephoneTone_.reset(new TelephoneTone(preferences.getZoneToneChoice(), sampleRate)); telephoneTone_.reset(new TelephoneTone(preferences.getZoneToneChoice(), sampleRate));
} }
dtmfKey_.reset(new DTMF(sampleRate)); dtmfKey_.reset(new DTMF(sampleRate));
...@@ -2700,18 +2692,18 @@ int ManagerImpl::loadAccountMap(Conf::YamlParser &parser) ...@@ -2700,18 +2692,18 @@ int ManagerImpl::loadAccountMap(Conf::YamlParser &parser)
} }
#endif #endif
using std::tr1::placeholders::_1; using std::placeholders::_1;
#if HAVE_IAX #if HAVE_IAX
std::for_each(seq->begin(), seq->end(), std::for_each(seq->begin(), seq->end(),
std::tr1::bind(loadAccount, _1, std::bind(loadAccount, _1,
std::tr1::ref(SIPVoIPLink::instance()->getAccounts()), std::ref(SIPVoIPLink::instance()->getAccounts()),
std::tr1::ref(IAXVoIPLink::getAccounts()), std::ref(IAXVoIPLink::getAccounts()),
std::tr1::ref(errorCount))); std::ref(errorCount)));
#else #else
std::for_each(seq->begin(), seq->end(), std::for_each(seq->begin(), seq->end(),
std::tr1::bind(loadAccount, _1, std::bind(loadAccount, _1,
std::tr1::ref(SIPVoIPLink::instance()->getAccounts()), std::ref(SIPVoIPLink::instance()->getAccounts()),
std::tr1::ref(errorCount))); std::ref(errorCount)));
#endif #endif
return errorCount; return errorCount;
...@@ -2917,7 +2909,7 @@ void ManagerImpl::clearHistory() ...@@ -2917,7 +2909,7 @@ void ManagerImpl::clearHistory()
void ManagerImpl::startAudioDriverStream() void ManagerImpl::startAudioDriverStream()
{ {
sfl::ScopedLock lock(audioLayerMutex_); std::lock_guard<std::mutex> lock(audioLayerMutex_);
audiodriver_->startStream(); audiodriver_->startStream();
} }
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include <set> #include <set>
#include <map> #include <map>
#include <memory> #include <memory>
#include <pthread.h> #include <mutex>
#include "client/client.h" #include "client/client.h"
...@@ -843,7 +843,7 @@ class ManagerImpl { ...@@ -843,7 +843,7 @@ class ManagerImpl {
std::string currentCallId_; std::string currentCallId_;
/** Protected current call access */ /** Protected current call access */
pthread_mutex_t currentCallMutex_; std::mutex currentCallMutex_;
/** Audio layer */ /** Audio layer */
AudioLayer* audiodriver_; AudioLayer* audiodriver_;
...@@ -854,7 +854,7 @@ class ManagerImpl { ...@@ -854,7 +854,7 @@ class ManagerImpl {
///////////////////// /////////////////////
// Protected by Mutex // Protected by Mutex
///////////////////// /////////////////////
pthread_mutex_t toneMutex_; std::mutex toneMutex_;
std::unique_ptr<TelephoneTone> telephoneTone_; std::unique_ptr<TelephoneTone> telephoneTone_;
std::unique_ptr<AudioFile> audiofile_; std::unique_ptr<AudioFile> audiofile_;
...@@ -866,7 +866,7 @@ class ManagerImpl { ...@@ -866,7 +866,7 @@ class ManagerImpl {
/** /**
* Mutex used to protect audio layer * Mutex used to protect audio layer
*/ */
pthread_mutex_t audioLayerMutex_; std::mutex audioLayerMutex_;
/** /**
* Waiting Call Vectors * Waiting Call Vectors
...@@ -876,7 +876,7 @@ class ManagerImpl { ...@@ -876,7 +876,7 @@ class ManagerImpl {
/** /**
* Protect waiting call list, access by many voip/audio threads * Protect waiting call list, access by many voip/audio threads
*/ */
pthread_mutex_t waitingCallsMutex_; std::mutex waitingCallsMutex_;
/** /**
* Add incoming callid to the waiting list * Add incoming callid to the waiting list
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment