diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index c660a68700ce1bd5934b17ae4a72807ac4710aa4..96d6aa5e999f8819c98d5beb9608bae81dc0eb29 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -123,7 +123,7 @@ void ManagerImpl::init(std::string config_file) ost::MutexLock lock(audioLayerMutex_); if (audiodriver_) { telephoneTone_ = new TelephoneTone(preferences.getZoneToneChoice(), audiodriver_->getSampleRate()); - dtmfKey_ = new DTMF(8000); + dtmfKey_.reset(new DTMF(8000)); } } @@ -142,7 +142,6 @@ void ManagerImpl::terminate() unloadAccountMap(); delete SIPVoIPLink::instance(); - delete dtmfKey_; delete telephoneTone_; telephoneTone_ = NULL; @@ -1308,7 +1307,7 @@ void ManagerImpl::playDtmf(char code) // = number of seconds * SAMPLING_RATE by SECONDS // fast return, no sound, so no dtmf - if (audiodriver_ == NULL || dtmfKey_ == NULL) { + if (audiodriver_ == NULL || dtmfKey_.get() == 0) { DEBUG("Manager: playDtmf: Error no audio layer..."); return; } @@ -2314,8 +2313,7 @@ void ManagerImpl::audioSamplingRateChanged(int samplerate) delete telephoneTone_; telephoneTone_ = new TelephoneTone(preferences.getZoneToneChoice(), sampleRate); - delete dtmfKey_; - dtmfKey_ = new DTMF(sampleRate); + dtmfKey_.reset(new DTMF(sampleRate)); if (wasActive) audiodriver_->startStream(); diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index a9ebb8f45a13a002c7162b8faa7c6b22694b680e..b1ff382644a927e9629bff665018bae6984432b4 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -40,6 +40,7 @@ #include <set> #include <map> #include <cc++/thread.h> +#include <memory> #include "dbus/dbusmanager.h" #include "config/config.h" @@ -940,8 +941,7 @@ class ManagerImpl { AudioLayer* audiodriver_; // Main thread - - DTMF* dtmfKey_; + std::auto_ptr<DTMF> dtmfKey_; ///////////////////// // Protected by Mutex