diff --git a/src/Makefile.am b/src/Makefile.am index 5be031174cdf639b7967fbb297021f6256af06e5..2d5e1af3133debef313b4a3046209c7bce46da23 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,6 +62,8 @@ sflphoned_LDADD = \ @PULSEAUDIO_LIBS@ \ @SAMPLERATE_LIBS@ +#sflphoned_LDFLAGS=-pg + noinst_LTLIBRARIES = libsflphone.la noinst_HEADERS = \ diff --git a/src/audio/alsalayer.cpp b/src/audio/alsalayer.cpp index acd933c9d071b4d82e1a02c7206f07ab069a279d..c72378229e9a7b69f83a5560312ffa7724326414 100644 --- a/src/audio/alsalayer.cpp +++ b/src/audio/alsalayer.cpp @@ -54,7 +54,7 @@ AlsaLayer::~AlsaLayer (void) deviceClosed = true; ringtone_thread_is_running = false; - pthread_join(ringtone_thread, NULL); + //pthread_join(ringtone_thread, NULL); } void @@ -104,7 +104,7 @@ AlsaLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize, _debugAlsa(" : nb channel in=%2d, out=%2d\n", _inChannel, _outChannel); _debugAlsa(" : sample rate=%5d, format=%s\n", _sampleRate, SFLDataFormatString); - ost::MutexLock lock( _mutex ); + //ost::MutexLock lock( _mutex ); /*void **hint; @@ -163,6 +163,7 @@ void* ringtoneThreadEntry( void *ptr ) ( ( AlsaLayer *) ptr) -> playTones(); //sleep(0.1); } + /* pthread_mutex_lock(&mut); while( ((AlsaLayer*)ptr)->_manager->getTelephoneTone() == NULL ) @@ -171,6 +172,7 @@ void* ringtoneThreadEntry( void *ptr ) } ( AlsaLayer *) ptr -> playTones(); pthread_mutex_unlock(&mut);*/ + return 0; } @@ -206,7 +208,7 @@ AlsaLayer::fillHWBuffer( void) bool AlsaLayer::isStreamActive (void) { - ost::MutexLock lock( _mutex ); + //ost::MutexLock lock( _mutex ); return (isPlaybackActive() && isCaptureActive()); } @@ -279,7 +281,7 @@ AlsaLayer::getMic(void *buffer, int toCopy) bool AlsaLayer::isStreamStopped (void) { - ost::MutexLock lock( _mutex ); + //ost::MutexLock lock( _mutex ); return !(isStreamActive()); } @@ -291,20 +293,18 @@ void AlsaLayer::restorePulseAppsVolume( void ){} ///////////////// ALSA PRIVATE FUNCTIONS //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// - - void AlsaLayer::playTones( void ) { int frames; int maxBytes; - pthread_mutex_lock(&mut); - while(!_manager-> getTelephoneTone() && !_manager->getTelephoneFile()) - { + //pthread_mutex_lock(&mut); + //while(!_manager-> getTelephoneTone() && !_manager->getTelephoneFile()) + //{ _debug("Make the ringtone thread wait\n"); pthread_cond_wait(&cond, &mut); - } + //} //frames = _periodSize ; frames = 940 ; @@ -324,13 +324,13 @@ AlsaLayer::playTones( void ) } // free the temporary data buffer free( out ); out = 0; - pthread_mutex_unlock(&mut); + //pthread_mutex_unlock(&mut); } bool AlsaLayer::isPlaybackActive(void) { - ost::MutexLock guard( _mutex ); + //ost::MutexLock guard( _mutex ); if( _PlaybackHandle ) return (snd_pcm_state(_PlaybackHandle) == SND_PCM_STATE_RUNNING ? true : false); else @@ -339,7 +339,7 @@ AlsaLayer::isPlaybackActive(void) { bool AlsaLayer::isCaptureActive(void) { - ost::MutexLock guard( _mutex ); + //ost::MutexLock guard( _mutex ); if( _CaptureHandle ) return (snd_pcm_state( _CaptureHandle) == SND_PCM_STATE_RUNNING ? true : false); else @@ -452,11 +452,11 @@ bool AlsaLayer::alsa_set_params( snd_pcm_t *pcm_handle, int type, int rate ){ // So the loop could start when the ringtone thread entry function is reached ringtone_thread_is_running = true; - if( pthread_create(&ringtone_thread, NULL, ringtoneThreadEntry, this) != 0 ) + /*if( pthread_create(&ringtone_thread, NULL, ringtoneThreadEntry, this) != 0 ) { _debug("Unable to start the ringtone posix thread\n"); return false; - } + }*/ } snd_pcm_sw_params_free( swparams ); diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index c2f3ec87673b1d73b58029c8215bd0cfc3a24b43..85ec5fea464f198be3e410b68d8cd130dc562bb9 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -52,7 +52,7 @@ AudioRtp::~AudioRtp (void) { int AudioRtp::createNewSession (SIPCall *ca) { - ost::MutexLock m(_threadMutex); + //ost::MutexLock m(_threadMutex); // something should stop the thread before... if ( _RTXThread != 0 ) { @@ -66,7 +66,7 @@ AudioRtp::createNewSession (SIPCall *ca) { _RTXThread = new AudioRtpRTX (ca, _symmetric); try { if (_RTXThread->start() != 0) { - _debug("! ARTP Failure: unable to start RTX Thread\n"); + _debug("! ARTP Failure: unable to start RTX Thread\n"); return -1; } } catch(...) { @@ -79,7 +79,7 @@ AudioRtp::createNewSession (SIPCall *ca) { void AudioRtp::closeRtpSession () { - ost::MutexLock m(_threadMutex); + //ost::MutexLock m(_threadMutex); // This will make RTP threads finish. // _debug("Stopping AudioRTP\n"); try { diff --git a/src/audio/pulselayer.cpp b/src/audio/pulselayer.cpp index 98a6cd6aa54fcf9e3a25a0ae50eb1e263a9f53c5..b1e6f6f725ea9c061cbbbcf8c04d811ff181643f 100644 --- a/src/audio/pulselayer.cpp +++ b/src/audio/pulselayer.cpp @@ -89,7 +89,7 @@ PulseLayer::connectPulseAudioServer( void ) } pa_threaded_mainloop_unlock( m ); - serverinfo(); + //serverinfo(); //muteAudioApps(99); _debug("Context creation done\n"); } diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index c6177f35fc920738250824a767cd0f07635b32f2..626aca506c6114558d6a1db42fae6259e55a019b 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -64,20 +64,20 @@ ManagerImpl::ManagerImpl (void) : _hasTriedToRegister(false) , _config() , _currentCallId2() - , _currentCallMutex() + //, _currentCallMutex() , _codecBuilder(NULL) , _audiodriver(NULL) , _dtmfKey(NULL) , _codecDescriptorMap() - , _toneMutex() + //, _toneMutex() , _telephoneTone(NULL) , _audiofile() , _spkr_volume(0) , _mic_volume(0) - , _mutex() + //, _mutex() , _dbus(NULL) , _waitingCall() - , _waitingCallMutex() + //, _waitingCallMutex() , _nbIncomingWaitingCall(0) , _path("") , _exist(0) @@ -86,7 +86,7 @@ ManagerImpl::ManagerImpl (void) , _firewallAddr("") , _hasZeroconf(false) , _callAccountMap() - , _callAccountMapMutex() + //, _callAccountMapMutex() , _accountMap() , _userAgent(NULL) , _userAgentInitlized(false) @@ -203,13 +203,13 @@ void ManagerImpl::terminate() bool ManagerImpl::isCurrentCall(const CallID& callId) { - ost::MutexLock m(_currentCallMutex); + //ost::MutexLock m(_currentCallMutex); return (_currentCallId2 == callId ? true : false); } bool ManagerImpl::hasCurrentCall() { - ost::MutexLock m(_currentCallMutex); + //ost::MutexLock m(_currentCallMutex); _debug("Current call ID = %s\n", _currentCallId2.c_str()); if ( _currentCallId2 != "") { return true; @@ -219,13 +219,13 @@ ManagerImpl::hasCurrentCall() { const CallID& ManagerImpl::getCurrentCallId() { - ost::MutexLock m(_currentCallMutex); + //ost::MutexLock m(_currentCallMutex); return _currentCallId2; } void ManagerImpl::switchCall(const CallID& id ) { - ost::MutexLock m(_currentCallMutex); + //ost::MutexLock m(_currentCallMutex); _currentCallId2 = id; } @@ -295,7 +295,9 @@ ManagerImpl::answerCall(const CallID& id) ManagerImpl::hangupCall(const CallID& id) { stopTone(true); + if (_dbus) _dbus->getCallManager()->callStateChanged(id, "HUNGUP"); + AccountID accountid = getAccountFromCall( id ); if (accountid == AccountNULL) { /** @todo We should tell the GUI that the call doesn't exist, so @@ -305,6 +307,7 @@ ManagerImpl::hangupCall(const CallID& id) } bool returnValue = getAccountLink(accountid)->hangup(id); + _debug("After voip link hungup!\n"); removeCallAccount(id); switchCall(""); @@ -561,20 +564,20 @@ ManagerImpl::playDtmf(char code, bool isTalking) // Multi-thread bool ManagerImpl::incomingCallWaiting() { - ost::MutexLock m(_waitingCallMutex); + //ost::MutexLock m(_waitingCallMutex); return (_nbIncomingWaitingCall > 0) ? true : false; } void ManagerImpl::addWaitingCall(const CallID& id) { - ost::MutexLock m(_waitingCallMutex); + //ost::MutexLock m(_waitingCallMutex); _waitingCall.insert(id); _nbIncomingWaitingCall++; } void ManagerImpl::removeWaitingCall(const CallID& id) { - ost::MutexLock m(_waitingCallMutex); + //ost::MutexLock m(_waitingCallMutex); // should return more than 1 if it erase a call if (_waitingCall.erase(id)) { _nbIncomingWaitingCall--; @@ -583,7 +586,7 @@ ManagerImpl::removeWaitingCall(const CallID& id) { bool ManagerImpl::isWaitingCall(const CallID& id) { - ost::MutexLock m(_waitingCallMutex); + //ost::MutexLock m(_waitingCallMutex); CallIDSet::iterator iter = _waitingCall.find(id); if (iter != _waitingCall.end()) { return false; @@ -735,9 +738,9 @@ ManagerImpl::playATone(Tone::TONEID toneId) { if (!hasToPlayTone) return false; if (_telephoneTone != 0) { - _toneMutex.enterMutex(); + //_toneMutex.enterMutex(); _telephoneTone->setCurrentTone(toneId); - _toneMutex.leaveMutex(); + //_toneMutex.leaveMutex(); AudioLoop* audioloop = getTelephoneTone(); unsigned int nbSampling = audioloop->getSize(); @@ -774,16 +777,16 @@ ManagerImpl::stopTone(bool stopAudio=true) { } - _toneMutex.enterMutex(); + //_toneMutex.enterMutex(); if (_telephoneTone != 0) { _telephoneTone->setCurrentTone(Tone::TONE_NULL); } - _toneMutex.leaveMutex(); + //_toneMutex.leaveMutex(); // for ringing tone.. - _toneMutex.enterMutex(); + //_toneMutex.enterMutex(); _audiofile.stop(); - _toneMutex.leaveMutex(); + //_toneMutex.leaveMutex(); } /** @@ -847,13 +850,13 @@ ManagerImpl::ringtone() int sampleRate = audiolayer->getSampleRate(); AudioCodec* codecForTone = _codecDescriptorMap.getFirstCodecAvailable(); - _toneMutex.enterMutex(); + //_toneMutex.enterMutex(); bool loadFile = _audiofile.loadFile(ringchoice, codecForTone , sampleRate); - _toneMutex.leaveMutex(); + //_toneMutex.leaveMutex(); if (loadFile) { - _toneMutex.enterMutex(); + //_toneMutex.enterMutex(); _audiofile.start(); - _toneMutex.leaveMutex(); + //_toneMutex.leaveMutex(); if(CHECK_INTERFACE( layer, ALSA )){ /*int size = _audiofile.getSize(); SFLDataFormat output[ size ]; @@ -880,7 +883,7 @@ ManagerImpl::ringtone() ManagerImpl::getTelephoneTone() { if(_telephoneTone != 0) { - ost::MutexLock m(_toneMutex); + //ost::MutexLock m(_toneMutex); return _telephoneTone->getCurrentTone(); } else { @@ -891,7 +894,7 @@ ManagerImpl::getTelephoneTone() AudioLoop* ManagerImpl::getTelephoneFile() { - ost::MutexLock m(_toneMutex); + //ost::MutexLock m(_toneMutex); if(_audiofile.isStarted()) { return &_audiofile; } else { @@ -1837,7 +1840,7 @@ ManagerImpl::detachZeroconfEvents(Pattern::Observer& observer) ManagerImpl::getCallStatus(const std::string& sequenceId UNUSED) { if (!_dbus) { return false; } - ost::MutexLock m(_callAccountMapMutex); + //ost::MutexLock m(_callAccountMapMutex); CallAccountMap::iterator iter = _callAccountMap.begin(); TokenList tk; std::string code; @@ -2139,7 +2142,7 @@ ManagerImpl::associateCallToAccount(const CallID& callID, const AccountID& accou { if (getAccountFromCall(callID) == AccountNULL) { // nothing with the same ID if ( accountExists(accountID) ) { // account id exist in AccountMap - ost::MutexLock m(_callAccountMapMutex); + //ost::MutexLock m(_callAccountMapMutex); _callAccountMap[callID] = accountID; _debug("Associate Call %s with Account %s\n", callID.data(), accountID.data()); return true; @@ -2154,7 +2157,7 @@ ManagerImpl::associateCallToAccount(const CallID& callID, const AccountID& accou AccountID ManagerImpl::getAccountFromCall(const CallID& callID) { - ost::MutexLock m(_callAccountMapMutex); + //ost::MutexLock m(_callAccountMapMutex); CallAccountMap::iterator iter = _callAccountMap.find(callID); if ( iter == _callAccountMap.end()) { return AccountNULL; @@ -2166,7 +2169,7 @@ ManagerImpl::getAccountFromCall(const CallID& callID) bool ManagerImpl::removeCallAccount(const CallID& callID) { - ost::MutexLock m(_callAccountMapMutex); + //ost::MutexLock m(_callAccountMapMutex); if ( _callAccountMap.erase(callID) ) { return true; } diff --git a/src/managerimpl.h b/src/managerimpl.h index a76987d758b48188f60e853759be06a51d5b75de..b13fc911a88d79580e739ac8ea8b5439d5ad7424 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -868,7 +868,7 @@ class ManagerImpl { CallID _currentCallId2; /** Protected current call access */ - ost::Mutex _currentCallMutex; + //ost::Mutex _currentCallMutex; /** Vector of CodecDescriptor */ CodecDescriptor* _codecBuilder; @@ -886,7 +886,7 @@ class ManagerImpl { ///////////////////// // Protected by Mutex ///////////////////// - ost::Mutex _toneMutex; + //ost::Mutex _toneMutex; TelephoneTone* _telephoneTone; AudioFile _audiofile; @@ -899,7 +899,7 @@ class ManagerImpl { // Multithread variable (protected by _mutex) // /** Mutex to protect access to code section */ - ost::Mutex _mutex; + //ost::Mutex _mutex; // Multithread variable (non protected) DBusManagerImpl * _dbus; @@ -908,7 +908,7 @@ class ManagerImpl { CallIDSet _waitingCall; /** Protect waiting call list, access by many voip/audio threads */ - ost::Mutex _waitingCallMutex; + //ost::Mutex _waitingCallMutex; /** Number of waiting call, synchronize with waitingcall callidvector */ unsigned int _nbIncomingWaitingCall; @@ -956,7 +956,7 @@ class ManagerImpl { CallAccountMap _callAccountMap; /** Mutex to lock the call account map (main thread + voiplink thread) */ - ost::Mutex _callAccountMapMutex; + //ost::Mutex _callAccountMapMutex; /** Associate a new CallID to a AccountID * Protected by mutex diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index d70e1221216de4257fe15373b637d39446152286..c71fd1da9eb1392f4074c80f29d88a3c6ea40327 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -81,7 +81,7 @@ void SIPVoIPLink::terminateSIPCall() { - ost::MutexLock m(_callMapMutex); + //ost::MutexLock m(_callMapMutex); CallMap::iterator iter = _callMap.begin(); SIPCall *call; while( iter != _callMap.end() ) { @@ -219,18 +219,21 @@ SIPVoIPLink::answer(const CallID& id) bool SIPVoIPLink::hangup(const CallID& id) { - SIPCall* call = getSIPCall(id); - if (call==0) { _debug("! SIP Error: Call doesn't exist\n"); return false; } + SIPCall* call = getSIPCall(id); + if (call==0) { _debug("! SIP Error: Call doesn't exist\n"); return false; } - Manager::instance().getUserAgent()->hangup(call); + if(!Manager::instance().getUserAgent()->hangup(call)) + return false; - // Release RTP thread - if (Manager::instance().isCurrentCall(id)) { - _debug("* SIP Info: Stopping AudioRTP for hangup\n"); - _audiortp->closeRtpSession(); - } - removeCall(id); - return true; + // Release RTP thread + if (Manager::instance().isCurrentCall(id)) { + _debug("* SIP Info: Stopping AudioRTP for hangup\n"); + _audiortp->closeRtpSession(); + } + + removeCall(id); + + return true; } bool diff --git a/src/useragent.cpp b/src/useragent.cpp index fb527784e0a41d0754228debb329860589370d0c..6e0e104cec4ada90606d980fbf15212e2870e450 100644 --- a/src/useragent.cpp +++ b/src/useragent.cpp @@ -1195,16 +1195,16 @@ bool UserAgent::hangup(SIPCall* call) { // User hangup current call. Notify peer status = pjsip_inv_end_session(call->getInvSession(), 404, NULL, &tdata); if(status != PJ_SUCCESS) - return false; + return false; _debug("UserAgent: Before send msg!\n"); if(tdata == NULL) - return true; + return true; status = pjsip_inv_send_msg(call->getInvSession(), tdata); if(status != PJ_SUCCESS) - return false; + return false; call->getInvSession()->mod_data[getInstance()->getModId()] = NULL; return true;