diff --git a/daemon/src/dbus/dbusmanager.cpp b/daemon/src/dbus/dbusmanager.cpp index 99f15340f2935ef80c332ad6271c6ac7d75894c1..9c903bd3bdc45f0b1ec343d2c5381c5b01644a59 100644 --- a/daemon/src/dbus/dbusmanager.cpp +++ b/daemon/src/dbus/dbusmanager.cpp @@ -31,6 +31,7 @@ #include <dbusmanager.h> #include "global.h" #include "manager.h" +#include "instance.h" #include "callmanager.h" #include "configurationmanager.h" @@ -46,6 +47,7 @@ DBusManager::DBusManager() #endif { try { + DBus::_init_threading(); DBus::default_dispatcher = &_dispatcher; DBus::Connection sessionConnection = DBus::Connection::SessionBus(); @@ -68,13 +70,12 @@ DBusManager::DBusManager() DBusManager::~DBusManager() { - delete _callManager; - delete _configurationManager; - delete _instanceManager; - #ifdef USE_NETWORKMANAGER delete _networkManager; #endif + delete _instanceManager; + delete _configurationManager; + delete _callManager; } void DBusManager::exec() diff --git a/daemon/src/dbus/dbusmanager.h b/daemon/src/dbus/dbusmanager.h index c72fd32464b9f38afcbf1fa96b8e2c4f7d1dd254..2e3ee3911f5b93a09a133c11dffa7a9eb9c0e1bb 100644 --- a/daemon/src/dbus/dbusmanager.h +++ b/daemon/src/dbus/dbusmanager.h @@ -31,11 +31,13 @@ #ifndef __DBUSMANAGERIMPL_H__ #define __DBUSMANAGERIMPL_H__ -#include "instance.h" - +#pragma GCC diagnostic ignored "-Wignored-qualifiers" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#include <dbus-c++/dbus.h> class ConfigurationManager; class CallManager; class NetworkManager; +class Instance; class DBusManager { @@ -56,7 +58,6 @@ class DBusManager void exec(); void exit(); - static const char* SERVER_NAME; private: bool _connected; diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 9a54afe3d6015eadc448af98f11d02c6648c5ea8..a18d0e62dc7ebe5025949813594b3b4fc66dd5d4 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -3058,22 +3058,11 @@ void ManagerImpl::setEchoCancelDelay(int delay) audioPreference.setEchoCancelDelay(delay); } -int ManagerImpl::app_is_running (std::string process) -{ - std::ostringstream cmd; - - cmd << "ps -C " << process; - return system (cmd.str().c_str()); -} - /** * Initialization: Main Thread */ bool ManagerImpl::initAudioDriver (void) { - - int error; - _debugInit ("Manager: AudioLayer Creation"); audioLayerMutexLock(); @@ -3082,7 +3071,7 @@ bool ManagerImpl::initAudioDriver (void) _audiodriver = new AlsaLayer (this); _audiodriver->setMainBuffer (&_mainBuffer); } else if (preferences.getAudioApi() == PULSEAUDIO) { - if (app_is_running ("pulseaudio") == 0) { + if (system("ps -C pulseaudio") == 0) { _audiodriver = new PulseLayer (this); _audiodriver->setMainBuffer (&_mainBuffer); } else { @@ -3099,7 +3088,7 @@ bool ManagerImpl::initAudioDriver (void) audioLayerMutexUnlock(); return false; } else { - error = _audiodriver->getErrorMessage(); + int error = _audiodriver->getErrorMessage(); if (error == -1) { _debug ("Manager: Init audio driver: %d", error); @@ -3111,7 +3100,6 @@ bool ManagerImpl::initAudioDriver (void) audioLayerMutexUnlock(); return true; - } /** @@ -3175,12 +3163,10 @@ void ManagerImpl::selectAudioDriver (void) /* Notify the error if there is one */ - if (_audiodriver -> getErrorMessage() != -1) { + if (_audiodriver -> getErrorMessage() != -1) notifyErrClient (_audiodriver -> getErrorMessage()); - } audioLayerMutexUnlock(); - } void ManagerImpl::switchAudioManager (void) @@ -3270,14 +3256,13 @@ void ManagerImpl::audioSamplingRateChanged (int samplerate) // Only modify internal sampling rate if new sampling rate is higher currentSamplerate = _mainBuffer.getInternalSamplingRate(); - if(currentSamplerate >= samplerate) { + if (currentSamplerate >= samplerate) { _debug("Manager: No need to update audio layer sampling rate"); audioLayerMutexUnlock(); return; } - else { + else _debug ("Manager: Audio sampling rate changed"); - } type = _audiodriver->getLayerType(); framesize = audioPreference.getFramesize(); @@ -3295,6 +3280,7 @@ void ManagerImpl::audioSamplingRateChanged (int samplerate) wasActive = _audiodriver->isStarted(); delete _audiodriver; + _audiodriver = 0; switch (type) { @@ -3341,9 +3327,8 @@ void ManagerImpl::audioSamplingRateChanged (int samplerate) _dtmfKey = new DTMF (sampleRate); // Restart audio layer if it was active - if (wasActive) { + if (wasActive) _audiodriver->startStream(); - } audioLayerMutexUnlock(); } @@ -3515,8 +3500,8 @@ int ManagerImpl::getConfigInt (const std::string& section, { try { return _config.getConfigTreeItemIntValue (section, name); - } catch (Conf::ConfigTreeItemException& e) { - throw e; + } catch (const Conf::ConfigTreeItemException& e) { + throw; } return 0; @@ -3528,8 +3513,8 @@ bool ManagerImpl::getConfigBool (const std::string& section, try { return (_config.getConfigTreeItemValue (section, name) == Conf::TRUE_STR) ? true : false; - } catch (Conf::ConfigTreeItemException& e) { - throw e; + } catch (const Conf::ConfigTreeItemException& e) { + throw; } return false; @@ -3541,8 +3526,8 @@ std::string ManagerImpl::getConfigString (const std::string& section, { try { return _config.getConfigTreeItemValue (section, name); - } catch (Conf::ConfigTreeItemException& e) { - throw e; + } catch (const Conf::ConfigTreeItemException& e) { + throw; } return ""; diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index 05f891f1a8f1f2f46fa5e5a3347d89b3e0a35f08..4ad0309443d70c3d8893205322cc475474e3daa3 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -1109,23 +1109,6 @@ class ManagerImpl void audioLayerMutexUnlock(void) { _audiolayerMutex.leaveMutex(); } private: - /* Transform digest to string. - * output must be at least PJSIP_MD5STRLEN+1 bytes. - * Helper function taken from sip_auth_client.c in - * pjproject-1.0.3. - * - * NOTE: THE OUTPUT STRING IS NOT NULL TERMINATED! - */ - void digest2str (const unsigned char digest[], char *output); - - /** - * Check if a process is running with the system command - * - * @return 0 on success - * 1 otherelse - */ - int app_is_running (std::string process); - /** * Create config directory in home user and return configuration file path */ @@ -1159,6 +1142,8 @@ class ManagerImpl */ bool playATone (Tone::TONEID toneId); + DBusManager _dbus; + /** The configuration tree. It contains accounts parameters, general user settings ,audio settings, ... */ Conf::ConfigTree _config; @@ -1201,11 +1186,6 @@ class ManagerImpl */ ost::Mutex _audiolayerMutex; - /** - * Multithread variable (non protected) - */ - DBusManager _dbus; - /** * Waiting Call Vectors */