From eface0d72362f6bf6060a0ec3faffca4194300ac Mon Sep 17 00:00:00 2001 From: Yun Liu <yun@yun.(none)> Date: Thu, 2 Oct 2008 09:34:16 -0400 Subject: [PATCH] Remove warnings continued --- src/account.cpp | 4 +- src/account.h | 17 ++---- src/audio/alsalayer.cpp | 109 ++++++++++++++++++---------------- src/audio/alsalayer.h | 6 ++ src/audio/audiodevice.cpp | 2 +- src/audio/audiofile.h | 17 ++---- src/audio/audiolayer.h | 37 ++++-------- src/audio/audioloop.h | 23 +++---- src/audio/audiortp.cpp | 12 ++-- src/audio/audiortp.h | 13 ++++ src/audio/audiostream.cpp | 8 +-- src/audio/audiostream.h | 7 +++ src/audio/codecDescriptor.cpp | 16 +++-- src/audio/dtmf.cpp | 4 +- src/audio/dtmfgenerator.cpp | 32 +--------- src/audio/dtmfgenerator.h | 9 ++- src/audio/pulselayer.cpp | 21 ++++--- src/audio/pulselayer.h | 6 ++ src/audio/ringbuffer.cpp | 13 ---- src/audio/ringbuffer.h | 10 ++-- src/audio/samplecache.h | 17 ++---- src/audio/tone.cpp | 3 +- src/audio/tonegenerator.cpp | 4 +- src/audio/tonegenerator.h | 6 ++ src/audio/tonelist.h | 35 ++++------- src/call.cpp | 25 +++++--- src/dbus/contactmanager.cpp | 2 +- src/eventthread.cpp | 14 ----- src/eventthread.h | 7 ++- src/managerimpl.cpp | 75 ++++++++++++++--------- src/managerimpl.h | 8 +++ src/samplerateconverter.cpp | 32 ++++++---- src/samplerateconverter.h | 6 ++ src/sipaccount.cpp | 5 +- src/sipaccount.h | 6 ++ src/sipcall.cpp | 13 ++-- src/sipcall.h | 7 +++ src/sipvoiplink.cpp | 22 ++++--- src/sipvoiplink.h | 6 ++ src/useragent.cpp | 2 +- src/useragent.h | 7 +++ 41 files changed, 352 insertions(+), 316 deletions(-) diff --git a/src/account.cpp b/src/account.cpp index 0fc25638d0..5eedf99bd4 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -23,10 +23,8 @@ #include <string> -Account::Account(const AccountID& accountID) : _accountID(accountID) +Account::Account(const AccountID& accountID) : _accountID(accountID), _link(NULL), _enabled(false) { - _link = NULL; - _enabled = false; } Account::~Account() diff --git a/src/account.h b/src/account.h index b89baf42c6..fc722ebd07 100644 --- a/src/account.h +++ b/src/account.h @@ -76,17 +76,6 @@ class Account{ */ virtual ~Account(); - // copy constructor - Account(const Account& rh):_accountID(rh._accountID), _link(rh._link), _enabled(rh._enabled){ - _debug("Account copy constructor hasn't been implemented yet. Quit! "); - exit(0); - } - - // assignment operator - Account& operator=(const Account& rh){ - _debug("Account assignment operator hasn't been implemented yet. Quit! "); - exit(0); - } /** * Load the settings for this account. @@ -147,6 +136,12 @@ class Account{ private: + // copy constructor + Account(const Account& rh); + + // assignment operator + Account& operator=(const Account& rh); + protected: /** * Account ID are assign in constructor and shall not changed diff --git a/src/audio/alsalayer.cpp b/src/audio/alsalayer.cpp index e0278d7b13..8df372658b 100644 --- a/src/audio/alsalayer.cpp +++ b/src/audio/alsalayer.cpp @@ -24,11 +24,17 @@ // Constructor AlsaLayer::AlsaLayer( ManagerImpl* manager ) : AudioLayer( manager , ALSA ) - , _PlaybackHandle(NULL) - , _CaptureHandle(NULL) + , _PlaybackHandle(NULL) + , _CaptureHandle(NULL) + , _periodSize() + , _AsyncHandler(NULL) + , _audioPlugin() + , _inChannel() + , _outChannel() + , _defaultVolume(100) + , IDSoundCards() { _debug(" Constructor of AlsaLayer called\n"); - _defaultVolume = 100; } // Destructor @@ -99,7 +105,7 @@ AlsaLayer::startStream(void) snd_pcm_start( _CaptureHandle ) ; snd_pcm_prepare( _PlaybackHandle ); - if( err = snd_pcm_start( _PlaybackHandle) < 0 ) _debugAlsa(" Cannot start (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_start( _PlaybackHandle)) < 0 ) _debugAlsa(" Cannot start (%s)\n", snd_strerror(err)); } } @@ -132,7 +138,7 @@ AlsaLayer::fillHWBuffer( void) short s1, s2; int periodSize = 128 ; int frames = periodSize >> 2 ; - _debug("frames = %d\n"); + _debug("frames = %d\n", frames); data = (unsigned char*)malloc(periodSize); for(l1 = 0; l1 < 100; l1++) { @@ -286,7 +292,7 @@ AlsaLayer::open_device(std::string pcm_p, std::string pcm_c, int flag) int dir = 0; snd_pcm_uframes_t period_size_in = getFrameSize() * getSampleRate() / 1000 * 2 ; snd_pcm_uframes_t buffer_size_in = period_size_in * 4 ; - snd_pcm_uframes_t threshold = 1024 ; + //snd_pcm_uframes_t threshold = 1024 ; snd_pcm_uframes_t period_size_out = getFrameSize() * getSampleRate() / 1000 * 2;//1024 ; snd_pcm_uframes_t buffer_size_out = period_size_out * 4 ; @@ -296,41 +302,41 @@ AlsaLayer::open_device(std::string pcm_p, std::string pcm_c, int flag) if(flag == SFL_PCM_BOTH || flag == SFL_PCM_CAPTURE) { _debugAlsa("Opening capture device %s\n", pcm_c.c_str()); - if(err = snd_pcm_open(&_CaptureHandle, pcm_c.c_str(), SND_PCM_STREAM_CAPTURE, 0) < 0){ + if( (err = snd_pcm_open(&_CaptureHandle, pcm_c.c_str(), SND_PCM_STREAM_CAPTURE, 0)) < 0){ _debugAlsa("Error while opening capture device %s\n", pcm_c.c_str()); setErrorMessage( ALSA_CAPTURE_DEVICE ); return false; } - if( err = snd_pcm_hw_params_malloc( &hwParams ) < 0 ) { + if( (err = snd_pcm_hw_params_malloc( &hwParams )) < 0 ) { _debugAlsa(" Cannot allocate hardware parameter structure (%s)\n", snd_strerror(err)); return false; } - if( err = snd_pcm_hw_params_any(_CaptureHandle, hwParams) < 0) _debugAlsa(" Cannot initialize hardware parameter structure (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_access( _CaptureHandle, hwParams, SND_PCM_ACCESS_MMAP_INTERLEAVED) < 0) _debugAlsa(" Cannot set access type (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_format( _CaptureHandle, hwParams, SND_PCM_FORMAT_S16_LE) < 0) _debugAlsa(" Cannot set sample format (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_rate_near( _CaptureHandle, hwParams, &rate_in, &dir) < 0) _debugAlsa(" Cannot set sample rate (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_channels( _CaptureHandle, hwParams, 1) < 0) _debugAlsa(" Cannot set channel count (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_period_time_near( _CaptureHandle, hwParams, &period_time , &dir) < 0) _debugAlsa(" Cannot set period time (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_buffer_time_near( _CaptureHandle, hwParams, &buffer_time , &dir) < 0) _debugAlsa(" Cannot set buffer time (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_get_period_size( hwParams, &period_size_in , &dir) < 0) _debugAlsa(" Cannot get period size (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_get_buffer_size( hwParams, &buffer_size_in ) < 0) _debugAlsa(" Cannot get buffer size (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params( _CaptureHandle, hwParams ) < 0) _debugAlsa(" Cannot set hw parameters (%s)\n", snd_strerror(err)); - _debug("buffer size = %d\n" , period_size_in); - _debug("period size = %d\n" , buffer_size_in); + if( (err = snd_pcm_hw_params_any(_CaptureHandle, hwParams)) < 0) _debugAlsa(" Cannot initialize hardware parameter structure (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_access( _CaptureHandle, hwParams, SND_PCM_ACCESS_MMAP_INTERLEAVED)) < 0) _debugAlsa(" Cannot set access type (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_format( _CaptureHandle, hwParams, SND_PCM_FORMAT_S16_LE)) < 0) _debugAlsa(" Cannot set sample format (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_rate_near( _CaptureHandle, hwParams, &rate_in, &dir) < 0)) _debugAlsa(" Cannot set sample rate (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_channels( _CaptureHandle, hwParams, 1)) < 0) _debugAlsa(" Cannot set channel count (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_period_time_near( _CaptureHandle, hwParams, &period_time , &dir)) < 0) _debugAlsa(" Cannot set period time (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_buffer_time_near( _CaptureHandle, hwParams, &buffer_time , &dir)) < 0) _debugAlsa(" Cannot set buffer time (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_get_period_size( hwParams, &period_size_in , &dir) < 0)) _debugAlsa(" Cannot get period size (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_get_buffer_size( hwParams, &buffer_size_in ) < 0)) _debugAlsa(" Cannot get buffer size (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params( _CaptureHandle, hwParams ) < 0)) _debugAlsa(" Cannot set hw parameters (%s)\n", snd_strerror(err)); + _debug("buffer size = %d\n" , (int) period_size_in); + _debug("period size = %d\n" , (int) buffer_size_in); snd_pcm_hw_params_free( hwParams ); snd_pcm_uframes_t val ; snd_pcm_sw_params_malloc( &swparams ); snd_pcm_sw_params_current( _CaptureHandle, swparams ); - if( err = snd_pcm_sw_params_set_start_threshold( _CaptureHandle, swparams, period_size_out) < 0 ) _debugAlsa(" Cannot set start threshold (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_sw_params_set_start_threshold( _CaptureHandle, swparams, period_size_out)) < 0 ) _debugAlsa(" Cannot set start threshold (%s)\n", snd_strerror(err)); snd_pcm_sw_params_get_start_threshold( swparams , &val); - _debug("Start threshold = %d\n" ,val); - if( err = snd_pcm_sw_params_set_avail_min( _CaptureHandle, swparams, period_size_out) < 0) _debugAlsa(" Cannot set min avail (%s)\n" , snd_strerror(err)); + _debug("Start threshold = %d\n" ,(int)val); + if( (err = snd_pcm_sw_params_set_avail_min( _CaptureHandle, swparams, period_size_out)) < 0) _debugAlsa(" Cannot set min avail (%s)\n" , snd_strerror(err)); snd_pcm_sw_params_get_avail_min( swparams , &val); - _debug("Min available = %d\n" ,val); - if( err = snd_pcm_sw_params( _CaptureHandle, swparams ) < 0 ) _debugAlsa(" Cannot set sw parameters (%s)\n", snd_strerror(err)); + _debug("Min available = %d\n" ,(int)val); + if( (err = snd_pcm_sw_params( _CaptureHandle, swparams )) < 0 ) _debugAlsa(" Cannot set sw parameters (%s)\n", snd_strerror(err)); snd_pcm_sw_params_free( swparams ); deviceClosed = false; } @@ -339,26 +345,26 @@ AlsaLayer::open_device(std::string pcm_p, std::string pcm_c, int flag) { _debugAlsa(" Opening playback device %s\n", pcm_p.c_str()); - if(err = snd_pcm_open(&_PlaybackHandle, pcm_p.c_str(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK ) < 0){ + if((err = snd_pcm_open(&_PlaybackHandle, pcm_p.c_str(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK )) < 0){ _debugAlsa("Error while opening playback device %s\n", pcm_p.c_str()); setErrorMessage( ALSA_PLAYBACK_DEVICE ); return false; } - if( err = snd_pcm_hw_params_malloc( &hwParams ) < 0 ) { + if( (err = snd_pcm_hw_params_malloc( &hwParams )) < 0 ) { _debugAlsa(" Cannot allocate hardware parameter structure (%s)\n", snd_strerror(err)); return false; } - if( err = snd_pcm_hw_params_any( _PlaybackHandle,hwParams) < 0) _debugAlsa(" Cannot initialize hardware parameter structure (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_access( _PlaybackHandle, hwParams, SND_PCM_ACCESS_MMAP_INTERLEAVED) < 0) _debugAlsa(" Cannot set access type (%s)\n", snd_strerror(err)); + if(( err = snd_pcm_hw_params_any( _PlaybackHandle,hwParams)) < 0) _debugAlsa(" Cannot initialize hardware parameter structure (%s)\n", snd_strerror(err)); + if(( err = snd_pcm_hw_params_set_access( _PlaybackHandle, hwParams, SND_PCM_ACCESS_MMAP_INTERLEAVED)) < 0) _debugAlsa(" Cannot set access type (%s)\n", snd_strerror(err)); //if( err = snd_pcm_hw_params_set_access( _PlaybackHandle, hwParams, SND_PCM_ACCESS_RW_INTERLEAVED) < 0) _debugAlsa(" Cannot set access type (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_format( _PlaybackHandle, hwParams, SND_PCM_FORMAT_S16_LE) < 0) _debugAlsa(" Cannot set sample format (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_rate( _PlaybackHandle, hwParams, rate_out, dir) < 0) _debugAlsa(" Cannot set sample rate (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_channels( _PlaybackHandle, hwParams, 1) < 0) _debugAlsa(" Cannot set channel count (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_buffer_time_near( _PlaybackHandle, hwParams, &buffer_time , &dir) < 0) _debugAlsa(" Cannot set buffer time (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_set_period_time_near( _PlaybackHandle, hwParams, &period_time , &dir) < 0) _debugAlsa(" Cannot set period time (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_get_period_size( hwParams, &_periodSize , &dir) < 0) _debugAlsa(" Cannot get period size (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params_get_buffer_size( hwParams, &buffer_size_out ) < 0) _debugAlsa(" Cannot get buffer size (%s)\n", snd_strerror(err)); - if( err = snd_pcm_hw_params( _PlaybackHandle, hwParams ) < 0) _debugAlsa(" Cannot set hw parameters (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_format( _PlaybackHandle, hwParams, SND_PCM_FORMAT_S16_LE)) < 0) _debugAlsa(" Cannot set sample format (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_rate( _PlaybackHandle, hwParams, rate_out, dir)) < 0) _debugAlsa(" Cannot set sample rate (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_channels( _PlaybackHandle, hwParams, 1)) < 0) _debugAlsa(" Cannot set channel count (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_buffer_time_near( _PlaybackHandle, hwParams, &buffer_time , &dir)) < 0) _debugAlsa(" Cannot set buffer time (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_set_period_time_near( _PlaybackHandle, hwParams, &period_time , &dir)) < 0) _debugAlsa(" Cannot set period time (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_get_period_size( hwParams, &_periodSize , &dir)) < 0) _debugAlsa(" Cannot get period size (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params_get_buffer_size( hwParams, &buffer_size_out )) < 0) _debugAlsa(" Cannot get buffer size (%s)\n", snd_strerror(err)); + if( (err = snd_pcm_hw_params( _PlaybackHandle, hwParams )) < 0) _debugAlsa(" Cannot set hw parameters (%s)\n", snd_strerror(err)); snd_pcm_hw_params_free( hwParams ); @@ -367,23 +373,23 @@ AlsaLayer::open_device(std::string pcm_p, std::string pcm_c, int flag) snd_pcm_sw_params_malloc( &swparams ); snd_pcm_sw_params_current( _PlaybackHandle, swparams ); - if( err = snd_pcm_sw_params_set_start_threshold( _PlaybackHandle, swparams, period_size_out) < 0 ) _debugAlsa(" Cannot set start threshold (%s)\n", snd_strerror(err)); + if((err = snd_pcm_sw_params_set_start_threshold( _PlaybackHandle, swparams, period_size_out)) < 0 ) _debugAlsa(" Cannot set start threshold (%s)\n", snd_strerror(err)); snd_pcm_sw_params_get_start_threshold( swparams , &val); - _debug("Start threshold = %d\n" ,val); + _debug("Start threshold = %d\n" ,(int)val); //if( err = snd_pcm_sw_params_set_stop_threshold( _PlaybackHandle, swparams, buffer_size_out ) < 0 ) _debugAlsa(" Cannot set stop threshold (%s)\n", snd_strerror(err)); //snd_pcm_sw_params_get_stop_threshold( swparams , &val); //_debug("Stop threshold = %d\n" ,val); - if( err = snd_pcm_sw_params_set_avail_min( _PlaybackHandle, swparams, period_size_out) < 0) _debugAlsa(" Cannot set min avail (%s)\n" , snd_strerror(err)); - if( err = snd_pcm_sw_params_set_xfer_align( _PlaybackHandle, swparams, 1) < 0) _debugAlsa(" Cannot set xfer align (%s)\n" , snd_strerror(err)); + if((err = snd_pcm_sw_params_set_avail_min( _PlaybackHandle, swparams, period_size_out)) < 0) _debugAlsa(" Cannot set min avail (%s)\n" , snd_strerror(err)); + if((err = snd_pcm_sw_params_set_xfer_align( _PlaybackHandle, swparams, 1)) < 0) _debugAlsa(" Cannot set xfer align (%s)\n" , snd_strerror(err)); snd_pcm_sw_params_get_avail_min( swparams , &val); - _debug("Min available = %d\n" ,val); + _debug("Min available = %d\n" ,(int)val); //if( err = snd_pcm_sw_params_set_silence_threshold( _PlaybackHandle, swparams, period_size_out) < 0) _debugAlsa(" Cannot set silence threshold (%s)\n" , snd_strerror(err)); //snd_pcm_sw_params_get_silence_threshold( swparams , &val); // _debug("Silence threshold = %d\n" ,val); - if( err = snd_pcm_sw_params( _PlaybackHandle, swparams ) < 0 ) _debugAlsa(" Cannot set sw parameters (%s)\n", snd_strerror(err)); + if(( err = snd_pcm_sw_params( _PlaybackHandle, swparams )) < 0 ) _debugAlsa(" Cannot set sw parameters (%s)\n", snd_strerror(err)); snd_pcm_sw_params_free( swparams ); - if ( err = snd_async_add_pcm_handler( &_AsyncHandler, _PlaybackHandle , AlsaCallBack, this ) < 0) _debugAlsa(" Unable to install the async callback handler (%s)\n", snd_strerror(err)); + if (( err = snd_async_add_pcm_handler( &_AsyncHandler, _PlaybackHandle , AlsaCallBack, this ) < 0)) _debugAlsa(" Unable to install the async callback handler (%s)\n", snd_strerror(err)); deviceClosed = false; } //fillHWBuffer(); @@ -421,8 +427,8 @@ AlsaLayer::write(void* buffer, int length) break; } - if( err >=0 && err < frames ) - _debugAlsa("Short write : %d out of %d\n", err , frames); + if( ( err >=0 ) && ( err < (int)frames ) ) + _debugAlsa("Short write : %d out of %d\n", err , (int)frames); return ( err > 0 )? err : 0 ; } @@ -439,7 +445,7 @@ AlsaLayer::read( void* buffer, int toCopy) snd_pcm_start( _CaptureHandle ); } snd_pcm_uframes_t frames = snd_pcm_bytes_to_frames( _CaptureHandle, toCopy ); - if( err = snd_pcm_mmap_readi( _CaptureHandle, buffer, frames) < 0 ) { + if(( err = snd_pcm_mmap_readi( _CaptureHandle, buffer, frames)) < 0 ) { switch(err){ case EPERM: _debugAlsa(" Capture EPERM (%s)\n", snd_strerror(err)); @@ -470,7 +476,9 @@ AlsaLayer::read( void* buffer, int toCopy) int AlsaLayer::putInCache( char code, void *buffer, int toCopy ) -{} +{ + return 1; +} void AlsaLayer::handle_xrun_capture( void ) @@ -497,7 +505,7 @@ AlsaLayer::handle_xrun_playback( void ) snd_pcm_status_t* status; snd_pcm_status_alloca( &status ); - if( state = snd_pcm_status( _PlaybackHandle, status ) < 0 ) _debugAlsa(" Error: Cannot get playback handle status (%s)\n" , snd_strerror( state ) ); + if( (state = snd_pcm_status( _PlaybackHandle, status )) < 0 ) _debugAlsa(" Error: Cannot get playback handle status (%s)\n" , snd_strerror( state ) ); else { state = snd_pcm_status_get_state( status ); @@ -541,7 +549,6 @@ AlsaLayer::getSoundCardsInfo( int stream ) snd_pcm_info_alloca( &pcminfo ); int numCard = -1 ; - int err; std::string description; if(snd_card_next( &numCard ) < 0 || numCard < 0) @@ -624,7 +631,7 @@ AlsaLayer::soundCardIndexExist( int card , int stream ) int AlsaLayer::soundCardGetIndex( std::string description ) { - int i; + unsigned int i; for( i = 0 ; i < IDSoundCards.size() ; i++ ) { HwIDPair p = IDSoundCards[i]; diff --git a/src/audio/alsalayer.h b/src/audio/alsalayer.h index fb5def1fa6..78a51988e9 100644 --- a/src/audio/alsalayer.h +++ b/src/audio/alsalayer.h @@ -203,6 +203,12 @@ class AlsaLayer : public AudioLayer { void setPlaybackVolume( double volume ); private: + + // Copy Constructor + AlsaLayer(const AlsaLayer& rh); + + // Assignment Operator + AlsaLayer& operator=( const AlsaLayer& rh); /** * Drop the pending frames and close the capture device diff --git a/src/audio/audiodevice.cpp b/src/audio/audiodevice.cpp index a4672da846..f82ce075a2 100644 --- a/src/audio/audiodevice.cpp +++ b/src/audio/audiodevice.cpp @@ -23,7 +23,7 @@ const double AudioDevice::DEFAULT_RATE = 8000.0; AudioDevice::AudioDevice(int id, const std::string& name) : - _id(id), _name(name) + _id(id), _name(name), _rate(DEFAULT_RATE) { _rate = DEFAULT_RATE; } diff --git a/src/audio/audiofile.h b/src/audio/audiofile.h index 8911f41d5d..a016289ed6 100644 --- a/src/audio/audiofile.h +++ b/src/audio/audiofile.h @@ -45,17 +45,6 @@ public: */ ~AudioFile(); - // Copy Constructor - AudioFile(const AudioFile& rh):_filename(rh._filename), _codec(rh._codec), _start(rh._start) { - _debug("AudioFilie copy constructor hasn't been implemented yet. Quit!"); - exit(0); - } - - // Assignment Operator - AudioFile& operator=( const AudioFile& rh){ - _debug("AudioFilie assignment operator hasn't been implemented yet. Quit!"); - exit(0); - } /** * Load a sound file in memory @@ -84,6 +73,12 @@ public: bool isStarted() { return _start; } private: + // Copy Constructor + AudioFile(const AudioFile& rh); + + // Assignment Operator + AudioFile& operator=( const AudioFile& rh); + /** The absolute path to the sound file */ std::string _filename; diff --git a/src/audio/audiolayer.h b/src/audio/audiolayer.h index eb8025e3da..b0b765e446 100644 --- a/src/audio/audiolayer.h +++ b/src/audio/audiolayer.h @@ -46,6 +46,15 @@ */ class AudioLayer { + + private: + + //copy constructor + AudioLayer(const AudioLayer& rh); + + // assignment operator + AudioLayer& operator=(const AudioLayer& rh); + public: /** * Constructor @@ -69,37 +78,11 @@ class AudioLayer { } - //copy constructor - AudioLayer(const AudioLayer& rh) - : _layerType( rh._layerType ) - , _manager(rh._manager) - , _urgentBuffer( rh._urgentBuffer ) - , _talk ( rh._talk ) - , deviceClosed ( rh.deviceClosed ) - , _indexIn ( rh._indexIn ) - , _indexOut ( rh._indexOut ) - , _sampleRate ( rh._sampleRate ) - , _frameSize ( rh._frameSize ) - , _inChannel( rh._inChannel ) - , _outChannel ( rh._outChannel ) - , _errorMessage ( rh._errorMessage ) - , _mutex (rh._mutex) - { - _debug("AudioLayer copy constructor hasn't been implemented yet. Quit!"); - exit(0); - } - - // assignment operator - AudioLayer& operator=(const AudioLayer& rh) - { - _debug("AudioLayer assignment operator hasn't been implemented yet. Quit!"); - exit(0); - } /** * Destructor */ - ~AudioLayer(void){} + virtual ~AudioLayer(void){} virtual void closeLayer( void ) = 0; diff --git a/src/audio/audioloop.h b/src/audio/audioloop.h index 98114e9002..e5f7984100 100644 --- a/src/audio/audioloop.h +++ b/src/audio/audioloop.h @@ -42,18 +42,6 @@ public: */ virtual ~AudioLoop(); - // Copy Constructor - AudioLoop(const AudioLoop& rh):_buffer(rh._buffer),_size(rh._size), _pos(rh._pos), _sampleRate(rh._sampleRate) { - _debug("AudioLoop copy constructor hasn't been implemented yet. Quit!"); - exit(0); - } - - // Assignment Operator - AudioLoop& operator=( const AudioLoop& rh){ - _debug("AudioLoop assignment operator hasn't been implemented yet. Quit!"); - exit(0); - } - /** * Get the next fragment of the tone * the function change the intern position, and will loop @@ -76,7 +64,6 @@ public: unsigned int getSize() { return _size; } - protected: /** The data buffer */ SFLDataFormat* _buffer; @@ -88,7 +75,15 @@ protected: int _pos; /** Sample rate */ - int _sampleRate; + int _sampleRate; + +private: + + // Copy Constructor + AudioLoop(const AudioLoop& rh); + + // Assignment Operator + AudioLoop& operator=( const AudioLoop& rh); }; #endif // __AUDIOLOOP_H__ diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index 2c7da7d7e2..c69828e918 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -42,9 +42,8 @@ //////////////////////////////////////////////////////////////////////////////// // AudioRtp //////////////////////////////////////////////////////////////////////////////// -AudioRtp::AudioRtp () +AudioRtp::AudioRtp() :_RTXThread(0), _symmetric(), _threadMutex() { - _RTXThread = 0; } AudioRtp::~AudioRtp (void) { @@ -94,12 +93,11 @@ AudioRtp::closeRtpSession () { //////////////////////////////////////////////////////////////////////////////// // AudioRtpRTX Class // //////////////////////////////////////////////////////////////////////////////// -AudioRtpRTX::AudioRtpRTX (SIPCall *sipcall, bool sym) +AudioRtpRTX::AudioRtpRTX (SIPCall *sipcall, bool sym) : time(new ost::Time()), _ca(sipcall), _sessionSend(NULL), _sessionRecv(NULL), _session(NULL), _start(), + _sym(sym), micData(NULL), micDataConverted(NULL), micDataEncoded(NULL), spkrDataDecoded(NULL), spkrDataConverted(NULL), + converter(NULL), _layerSampleRate(),_codecSampleRate(), _layerFrameSize(), _audiocodec(NULL) { setCancel(cancelDeferred); - time = new ost::Time(); - _ca = sipcall; - _sym = sym; // AudioRtpRTX should be close if we change sample rate // TODO: Change bind address according to user settings. // TODO: this should be the local ip not the external (router) IP @@ -324,7 +322,7 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime) //buffer _receiveDataDecoded ----> short int or int16, coded on 2 bytes int nbInt16 = expandedSize / sizeof(int16); //nbInt16 represents the number of samples we just decoded - if (nbInt16 > max) { + if ((unsigned int)nbInt16 > max) { _debug("We have decoded an RTP packet larger than expected: %d VS %d. Cropping.\n", nbInt16, max); nbInt16=max; } diff --git a/src/audio/audiortp.h b/src/audio/audiortp.h index a0cb003bf3..030840f94e 100644 --- a/src/audio/audiortp.h +++ b/src/audio/audiortp.h @@ -65,6 +65,13 @@ class AudioRtpRTX : public ost::Thread, public ost::TimerPort { virtual void run (); private: + + // copy constructor + AudioRtpRTX(const AudioRtpRTX& rh); + + // assignment operator + AudioRtpRTX& operator=(const AudioRtpRTX& rh); + /** A SIP call */ SIPCall* _ca; @@ -169,6 +176,12 @@ class AudioRtp { void closeRtpSession( void ); private: + // copy constructor + AudioRtp(const AudioRtp& rh); + + // assignment operator + AudioRtp& operator=(const AudioRtp& rh); + /** The RTP thread */ AudioRtpRTX* _RTXThread; diff --git a/src/audio/audiostream.cpp b/src/audio/audiostream.cpp index 55478be095..9c8638e4a8 100644 --- a/src/audio/audiostream.cpp +++ b/src/audio/audiostream.cpp @@ -22,17 +22,15 @@ static pa_channel_map channel_map ; AudioStream::AudioStream( pa_context* context, int type, std::string desc, double vol ) + : _audiostream (createStream( context )), _streamType(type), _streamDescription(desc), flag(PA_STREAM_AUTO_TIMING_UPDATE), sample_spec(), _volume() { - _streamType = type; - _streamDescription = desc; sample_spec.format = PA_SAMPLE_S16LE; sample_spec.rate = 44100; sample_spec.channels = 1; channel_map.channels = 1; - flag = PA_STREAM_AUTO_TIMING_UPDATE ; pa_cvolume_set( &_volume , 1 , PA_VOLUME_MUTED ) ; // * vol / 100 ; - _audiostream = createStream( context ); + //_audiostream = createStream( context ); } AudioStream::~AudioStream() @@ -76,7 +74,7 @@ AudioStream::stream_state_callback( pa_stream* s, void* user_data ) AudioStream::createStream( pa_context* c ) { pa_stream* s; - pa_cvolume cv; + //pa_cvolume cv; assert(pa_sample_spec_valid(&sample_spec)); assert(pa_channel_map_valid(&channel_map)); diff --git a/src/audio/audiostream.h b/src/audio/audiostream.h index 7645f2bd51..121b87ad9c 100644 --- a/src/audio/audiostream.h +++ b/src/audio/audiostream.h @@ -95,6 +95,13 @@ class AudioStream { pa_cvolume getVolume( void ) { return _volume; } private: + + // Copy Constructor + AudioStream(const AudioStream& rh); + + // Assignment Operator + AudioStream& operator=( const AudioStream& rh); + /** * Create the audio stream into the given context * @param c The pulseaudio context diff --git a/src/audio/codecDescriptor.cpp b/src/audio/codecDescriptor.cpp index ba6ca1e681..04b35d547a 100644 --- a/src/audio/codecDescriptor.cpp +++ b/src/audio/codecDescriptor.cpp @@ -24,7 +24,7 @@ #include "codecDescriptor.h" -CodecDescriptor::CodecDescriptor() +CodecDescriptor::CodecDescriptor() : _CodecsMap(), _codecOrder(), _Cache(), _nbCodecs(), _CodecInMemory() { } @@ -36,7 +36,7 @@ CodecDescriptor::~CodecDescriptor() CodecDescriptor::deleteHandlePointer( void ) { int i; - for( i = 0 ; i < _CodecInMemory.size() ; i++) + for( i = 0 ; (unsigned int)i < _CodecInMemory.size() ; i++) { unloadCodec( _CodecInMemory[i] ); } @@ -97,7 +97,7 @@ CodecDescriptor::getCodec(AudioCodecType payload) CodecDescriptor::isActive(AudioCodecType payload) { int i; - for(i=0 ; i < _codecOrder.size() ; i++) + for(i=0 ; (unsigned int)i < _codecOrder.size() ; i++) { if(_codecOrder[i] == payload) return true; @@ -164,7 +164,7 @@ CodecDescriptor::saveActiveCodecs(const std::vector<std::string>& list) int i=0; int payload; size_t size = list.size(); - while( i < size ) + while( (unsigned int)i < size ) { payload = std::atoi(list[i].data()); if( isCodecLoaded( payload ) ) { @@ -188,7 +188,7 @@ CodecDescriptor::scanCodecDirectory( void ) dirToScan.push_back(homeDir); dirToScan.push_back(libDir); - for( i = 0 ; i < dirToScan.size() ; i++ ) + for( i = 0 ; (unsigned int)i < dirToScan.size() ; i++ ) { std::string dirStr = dirToScan[i]; _debug("Scanning %s to find audio codecs....\n", dirStr.c_str()); @@ -196,7 +196,7 @@ CodecDescriptor::scanCodecDirectory( void ) AudioCodec* audioCodec; if( dir ){ dirent *dirStruct; - while( dirStruct = readdir( dir )) { + while( (dirStruct = readdir( dir )) ) { tmp = dirStruct -> d_name ; if( tmp == CURRENT_DIR || tmp == PARENT_DIR){} else{ @@ -241,7 +241,6 @@ CodecDescriptor::unloadCodec( CodecHandlePointer p ) { // _debug("Unload codec %s\n", p.first->getCodecName().c_str()); using std::cerr; - int i; destroy_t* destroyCodec = (destroy_t*)dlsym( p.second , "destroy"); if(dlerror()) cerr << dlerror() << '\n'; @@ -311,7 +310,7 @@ CodecDescriptor::seemsValid( std::string lib) CodecDescriptor::alreadyInCache( std::string lib ) { int i; - for( i = 0 ; i < _Cache.size() ; i++ ) + for( i = 0 ; (unsigned int)i < _Cache.size() ; i++ ) { if( _Cache[i] == lib ){ return true;} @@ -322,7 +321,6 @@ CodecDescriptor::alreadyInCache( std::string lib ) bool CodecDescriptor::isCodecLoaded( int payload ) { - int i; CodecsMap::iterator iter = _CodecsMap.begin(); while( iter != _CodecsMap.end()) { diff --git a/src/audio/dtmf.cpp b/src/audio/dtmf.cpp index faabf1d69a..c6ba907aae 100644 --- a/src/audio/dtmf.cpp +++ b/src/audio/dtmf.cpp @@ -24,10 +24,8 @@ #include "dtmf.h" DTMF::DTMF (unsigned int sampleRate) -: dtmfgenerator(sampleRate) +: currentTone(0), newTone(0), dtmfgenerator(sampleRate) { - currentTone = 0; - newTone = 0; } DTMF::~DTMF (void) diff --git a/src/audio/dtmfgenerator.cpp b/src/audio/dtmfgenerator.cpp index 24b00942ac..f35f1e50ac 100644 --- a/src/audio/dtmfgenerator.cpp +++ b/src/audio/dtmfgenerator.cpp @@ -51,9 +51,8 @@ const DTMFGenerator::DTMFTone DTMFGenerator::tones[NUM_TONES] = { }; -DTMFException::DTMFException(const char* _reason) throw() +DTMFException::DTMFException(const char* _reason) throw() : reason(_reason) { - reason = _reason; } @@ -61,20 +60,6 @@ DTMFException::~DTMFException() throw() { } - -DTMFException::DTMFException(const DTMFException& rh) throw() -{ - _debug("DTMFException copy constructor hasn't been implemented yet. Quit!"); - exit(0); -} - -DTMFException& DTMFException::operator=(const DTMFException& rh) throw() -{ - _debug("DTMFException assignment operator hasn't been implemented yet. Quit!"); - exit(0); -} - - const char* DTMFException::what() const throw() { return reason; @@ -85,9 +70,8 @@ const char* DTMFException::what() const throw() /* * Initialize the generator */ -DTMFGenerator::DTMFGenerator(unsigned int sampleRate) : tone("", sampleRate) +DTMFGenerator::DTMFGenerator(unsigned int sampleRate) : state(), _sampleRate(sampleRate), tone("", sampleRate) { - _sampleRate = sampleRate; state.offset = 0; state.sample = 0; @@ -103,18 +87,6 @@ DTMFGenerator::~DTMFGenerator() { } } -DTMFGenerator::DTMFGenerator(const DTMFGenerator& rh) : tone("", rh._sampleRate) -{ - _debug("DTMFGenerator copy constructor hasn't been implemented yet. Quit!"); - exit(0); -} - -DTMFGenerator& DTMFGenerator::operator=(const DTMFGenerator& rh) -{ - _debug("DTMFGenerator assignment operator hasn't been implemented yet. Quit!"); - exit(0); -} - /* * Get n samples of the signal of code code */ diff --git a/src/audio/dtmfgenerator.h b/src/audio/dtmfgenerator.h index 0f6250c2ae..a4bed74983 100644 --- a/src/audio/dtmfgenerator.h +++ b/src/audio/dtmfgenerator.h @@ -39,6 +39,7 @@ class DTMFException : public std::exception { private: + /** Message */ const char* reason; public: @@ -52,13 +53,13 @@ class DTMFException : public std::exception * Destructor */ virtual ~DTMFException() throw(); - +/* // Copy Constructor DTMFException(const DTMFException& rh) throw(); // Assignment Operator - DTMFException& operator=( const DTMFException& rh) throw(); - + DTMFException& operator=( const DTMFException& rh) throw(); +*/ /** * @return const char* The error */ @@ -113,6 +114,7 @@ class DTMFGenerator */ ~DTMFGenerator(); + // Copy Constructor DTMFGenerator(const DTMFGenerator& rh); @@ -136,6 +138,7 @@ class DTMFGenerator void getNextSamples(SFLDataFormat* buffer, size_t n) throw (DTMFException); private: + /** * Generate samples for a specific dtmf code * @param code The code diff --git a/src/audio/pulselayer.cpp b/src/audio/pulselayer.cpp index 41af80b5e1..a9942eacea 100644 --- a/src/audio/pulselayer.cpp +++ b/src/audio/pulselayer.cpp @@ -22,10 +22,15 @@ int framesPerBuffer = 2048; PulseLayer::PulseLayer(ManagerImpl* manager) - : AudioLayer( manager , PULSEAUDIO ) + : AudioLayer( manager , PULSEAUDIO ) + , _mainSndRingBuffer( SIZEBUF ) , _urgentRingBuffer( SIZEBUF) - ,_mainSndRingBuffer( SIZEBUF ) - ,_micRingBuffer( SIZEBUF ) + , _micRingBuffer( SIZEBUF ) + , context(NULL) + , m(NULL) + , playback() + , record() + , cache() { _debug("Pulse audio constructor: Create context\n"); } @@ -53,7 +58,6 @@ PulseLayer::closeLayer( void ) PulseLayer::connectPulseAudioServer( void ) { pa_context_flags_t flag = PA_CONTEXT_NOAUTOSPAWN ; - int ret = 1; pa_threaded_mainloop_lock( m ); @@ -87,7 +91,6 @@ void PulseLayer::context_state_callback( pa_context* c, void* user_data ) _debug("Waiting....\n"); break; case PA_CONTEXT_READY: - pa_cvolume cv; pulse->createStreams( c ); _debug("Connection to PulseAudio server established\n"); break; @@ -148,6 +151,7 @@ PulseLayer::openDevice(int indexIn, int indexOut, int sampleRate, int frameSize connectPulseAudioServer(); _debug("Connection Done!! \n"); + return true; } void @@ -254,7 +258,7 @@ PulseLayer::underflow ( pa_stream* s, void* userdata ) void PulseLayer::overflow ( pa_stream* s, void* userdata ) { - PulseLayer* pulse = (PulseLayer*) userdata; + //PulseLayer* pulse = (PulseLayer*) userdata; pa_stream_drop( s ); pa_stream_trigger( s, NULL, NULL); } @@ -355,6 +359,7 @@ PulseLayer::putInCache( char code, void *buffer, int toCopy ) _debug("Put the DTMF in cache\n"); //pa_stream_write( cache->pulseStream() , buffer , toCopy , pa_xfree, 0 , PA_SEEK_RELATIVE); //pa_stream_finish_upload( cache->pulseStream() ); + return 1; } static void retrieve_server_info(pa_context *c, const pa_server_info *i, void *userdata) @@ -365,6 +370,7 @@ static void retrieve_server_info(pa_context *c, const pa_server_info *i, void *u _debug("\t\tDefault source name : %s\n" , i->default_source_name); } +/* static void retrieve_client_list(pa_context *c, const pa_client_info *i, int eol, void *userdata) { _debug("end of list = %i\n", eol); @@ -373,6 +379,7 @@ static void retrieve_client_list(pa_context *c, const pa_client_info *i, int eol _debug("\t\tOwner module : %i\n" , i->owner_module); _debug("\t\tDriver : %s\n" , i->driver); } +*/ static void reduce_sink_list(pa_context *c, const pa_sink_input_info *i, int eol, void *userdata) { @@ -392,7 +399,7 @@ static void reduce_sink_list(pa_context *c, const pa_sink_input_info *i, int eol static void restore_sink_list(pa_context *c, const pa_sink_input_info *i, int eol, void *userdata) { PulseLayer* pulse = (PulseLayer*) userdata; - AudioStream* s = pulse->getPlaybackStream(); + //AudioStream* s = pulse->getPlaybackStream(); if( !eol ){ _debug("Sink Info: index : %i\n" , i->index); _debug("\t\tSink name : -%s-\n" , i->name); diff --git a/src/audio/pulselayer.h b/src/audio/pulselayer.h index 122b267753..08db1de9d3 100644 --- a/src/audio/pulselayer.h +++ b/src/audio/pulselayer.h @@ -173,6 +173,12 @@ class PulseLayer : public AudioLayer { void setPlaybackVolume( double volume ); private: + // Copy Constructor + PulseLayer(const PulseLayer& rh); + + // Assignment Operator + PulseLayer& operator=( const PulseLayer& rh); + /** * Drop the pending frames and close the capture device */ diff --git a/src/audio/ringbuffer.cpp b/src/audio/ringbuffer.cpp index 2d474a1bc6..f56e8ec0e9 100644 --- a/src/audio/ringbuffer.cpp +++ b/src/audio/ringbuffer.cpp @@ -42,19 +42,6 @@ RingBuffer::~RingBuffer() { delete[] mBuffer; mBuffer = NULL; } -//copy constructor -RingBuffer::RingBuffer(const RingBuffer& rh): mStart(rh.mStart), mEnd(rh.mEnd), mBufferSize( rh.mBufferSize ), mBuffer ( rh.mBuffer ) -{ - _debug("RingBuffer copy constructor hasn't been implemented yet. Quit!"); - exit(0); -} - -// Assignment operator -RingBuffer& RingBuffer::operator=(const RingBuffer& rh) { - _debug("RingBuffer assignment operator hasn't been implemented yet. Quit!"); - exit(0); -} - void RingBuffer::flush (void) { mStart = 0; diff --git a/src/audio/ringbuffer.h b/src/audio/ringbuffer.h index 8c991bd133..27db3e31b3 100644 --- a/src/audio/ringbuffer.h +++ b/src/audio/ringbuffer.h @@ -38,11 +38,6 @@ class RingBuffer { */ ~RingBuffer(); - // Copy Constructor - RingBuffer(const RingBuffer& rh); - - // Assignment operator - RingBuffer& operator=(const RingBuffer& rh); /** * Reset the counters to 0 @@ -98,6 +93,11 @@ class RingBuffer { void debug(); private: + // Copy Constructor + RingBuffer(const RingBuffer& rh); + + // Assignment operator + RingBuffer& operator=(const RingBuffer& rh); /** Pointer on the first data */ int mStart; diff --git a/src/audio/samplecache.h b/src/audio/samplecache.h index c5335d8b52..4c07d558b4 100644 --- a/src/audio/samplecache.h +++ b/src/audio/samplecache.h @@ -29,23 +29,18 @@ class SampleCache { SampleCache( pa_stream* stream ); ~SampleCache(); - // Copy Constructor - SampleCache(const SampleCache& rh):_stream(rh._stream) { - _debug("SampleCache copy constructor hasn't been implemented yet. Quit!"); - exit(0); - } - - // Assignment Operator - SampleCache& operator=( const SampleCache& rh){ - _debug("SampleCache assignment operator hasn't been implemented yet. Quit!"); - exit(0); - } bool uploadSample( SFLDataFormat* buffer, size_t size ); bool removeSample( ); bool isSampleCached( ); private: + // Copy Constructor + SampleCache(const SampleCache& rh); + + // Assignment Operator + SampleCache& operator=( const SampleCache& rh); + pa_stream* _stream; }; diff --git a/src/audio/tone.cpp b/src/audio/tone.cpp index d015abed7f..646dae56a5 100644 --- a/src/audio/tone.cpp +++ b/src/audio/tone.cpp @@ -26,9 +26,8 @@ #include "tone.h" #include <math.h> -Tone::Tone(const std::string& definition, unsigned int sampleRate) : AudioLoop() +Tone::Tone(const std::string& definition, unsigned int sampleRate) : AudioLoop(), _sampleRate(sampleRate) { - _sampleRate = sampleRate; genBuffer(definition); // allocate memory with definition parameter } diff --git a/src/audio/tonegenerator.cpp b/src/audio/tonegenerator.cpp index 37cfd1eaaa..e5a29cd078 100644 --- a/src/audio/tonegenerator.cpp +++ b/src/audio/tonegenerator.cpp @@ -31,8 +31,8 @@ int AMPLITUDE = 32767; // ToneGenerator implementation /////////////////////////////////////////////////////////////////////////////// -ToneGenerator::ToneGenerator (unsigned int sampleRate) { - _sampleRate = sampleRate; +ToneGenerator::ToneGenerator (unsigned int sampleRate): sample(NULL), freq1(), freq2(), time(), totalbytes(), _sampleRate(sampleRate) +{ } ToneGenerator::~ToneGenerator (void) { diff --git a/src/audio/tonegenerator.h b/src/audio/tonegenerator.h index 062caebd51..8fae9ea29f 100644 --- a/src/audio/tonegenerator.h +++ b/src/audio/tonegenerator.h @@ -63,6 +63,12 @@ class ToneGenerator { int totalbytes; private: + // Copy Constructor + ToneGenerator(const ToneGenerator& rh); + + // Assignment Operator + ToneGenerator& operator=( const ToneGenerator& rh); + /* * Initialisation of the supported tones according to the countries. */ diff --git a/src/audio/tonelist.h b/src/audio/tonelist.h index 88c91824da..849af15477 100644 --- a/src/audio/tonelist.h +++ b/src/audio/tonelist.h @@ -40,17 +40,6 @@ public: */ ~ToneList(); - // Copy Constructor - ToneList(const ToneList& rh):_nbTone(rh._nbTone),_nbCountry(rh._nbCountry),_defaultCountryId(rh._defaultCountryId) { - _debug("ToneList copy constructor hasn't been implemented yet. Quit!"); - exit(0); - } - - // Assignment Operator - ToneList& operator=( const ToneList& rh){ - _debug("ToneList assignment operator hasn't been implemented yet. Quit!"); - exit(0); - } /** Countries */ enum COUNTRYID { @@ -85,6 +74,13 @@ public: int getNbTone() { return _nbTone; } private: + + // Copy Constructor + ToneList(const ToneList& rh); + + // Assignment Operator + ToneList& operator=( const ToneList& rh); + void initToneDefinition(); std::string _toneZone[TONE_NBCOUNTRY][TONE_NBTONE]; int _nbTone; @@ -101,17 +97,6 @@ public: TelephoneTone(const std::string& countryName, unsigned int sampleRate); ~TelephoneTone(); - // Copy Constructor - TelephoneTone(const TelephoneTone& rh):_currentTone(rh._currentTone), _toneList(rh._toneList) { - _debug("TelephoneTone copy constructor hasn't been implemented yet. Quit!"); - exit(0); - }; - - // Assignment Operator - TelephoneTone& operator=( const TelephoneTone& rh){ - _debug("TelephoneTone assignment operator hasn't been implemented yet. Quit!"); - exit(0); - } /** send TONE::ZT_TONE_NULL to stop the playing */ void setCurrentTone(Tone::TONEID toneId); @@ -126,6 +111,12 @@ public: bool shouldPlay(); private: + // Copy Constructor + TelephoneTone(const TelephoneTone& rh); + + // Assignment Operator + TelephoneTone& operator=( const TelephoneTone& rh); + Tone* _tone[TONE_NBTONE]; Tone::TONEID _currentTone; ToneList _toneList; diff --git a/src/call.cpp b/src/call.cpp index 7d27f026c8..a29c60adfa 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -19,16 +19,23 @@ */ #include "call.h" -Call::Call(const CallID& id, Call::CallType type) : _id(id), _type(type), - _localIPAddress(""), - _remoteIPAddress("") +Call::Call(const CallID& id, Call::CallType type) + : _callMutex() + , _codecMap() + , _audioCodec() + , _audioStarted(false) + , _localIPAddress("") + , _localAudioPort(0) + , _localExternalAudioPort(0) + , _remoteIPAddress("") + , _remoteAudioPort(0) + , _id(id) + , _type(type) + , _connectionState(Call::Disconnected) + , _callState(Call::Inactive) + , _peerName() + , _peerNumber() { - _connectionState = Call::Disconnected; - _callState = Call::Inactive; - //_audioCodec = 0; - _localAudioPort = 0; - _localExternalAudioPort = 0; - _remoteAudioPort = 0; } diff --git a/src/dbus/contactmanager.cpp b/src/dbus/contactmanager.cpp index 27e9c8cc8c..52dcfa1b93 100644 --- a/src/dbus/contactmanager.cpp +++ b/src/dbus/contactmanager.cpp @@ -25,7 +25,7 @@ const char* ContactManager::SERVER_PATH = "/org/sflphone/SFLphone/ContactManager std::map< ::DBus::String, ::DBus::String > ContactManager::getContacts( const ::DBus::String& accountID ) { - // TODO + // TODO } void diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 49d361d50f..1ec4363470 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -27,20 +27,6 @@ EventThread::EventThread (VoIPLink* link) : Thread (), _linkthread(link), stopI setCancel(cancelDeferred); } -// Copy Constructor -EventThread::EventThread(const EventThread& rh): _linkthread(rh._linkthread), stopIt(rh.stopIt) -{ - _debug("EventThread copy constructor hasn't been implemented yet. Quit! "); - exit(); -} - -// Assignment Operator overloading -EventThread& EventThread::operator=(const EventThread& rh) -{ - _debug("EventThread assignment operator hasn't been implemented yet. Quit! "); - exit(); -} - EventThread::~EventThread (void) { terminate(); diff --git a/src/eventthread.h b/src/eventthread.h index 96b70f7e1c..8772c72043 100644 --- a/src/eventthread.h +++ b/src/eventthread.h @@ -37,15 +37,16 @@ public: */ EventThread (VoIPLink*); ~EventThread (void); - EventThread(const EventThread& rh); // copy constructor - EventThread& operator=(const EventThread& rh); // assignment operator virtual void run (); virtual void stop(); virtual void startLoop(); bool isStopped(); private: - /** VoIPLink is the object being called by getEvents() method */ + EventThread(const EventThread& rh); // copy constructor + EventThread& operator=(const EventThread& rh); // assignment operator + + /** VoIPLink is the object being called by getEvents() method */ VoIPLink* _linkthread; bool stopIt; }; diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 76c5587747..082551eac0 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -61,35 +61,52 @@ #define fill_config_int(name, value) \ (_config.addConfigTreeItem(section, Conf::ConfigTreeItem(std::string(name), std::string(value), type_int))) -ManagerImpl::ManagerImpl (void) +ManagerImpl::ManagerImpl (void) + : _hasTriedToRegister(false) + , _config() + , _currentCallId2() + , _currentCallMutex() + , _codecBuilder(NULL) + , _audiodriver(NULL) + , _dtmfKey(NULL) + , _codecDescriptorMap() + , _toneMutex() + , _telephoneTone(NULL) + , _audiofile() + , _spkr_volume(0) + , _mic_volume(0) + , _mutex() + , _dbus(NULL) + , _waitingCall() + , _waitingCallMutex() + , _nbIncomingWaitingCall(0) + , _path("") + , _exist(0) + , _setupLoaded(false) + , _firewallPort() + , _firewallAddr("") + , _hasZeroconf(false) + , _callAccountMap() + , _callAccountMapMutex() + , _accountMap() + , _userAgent(NULL) + , _userAgentInitlized(false) + , _sipThreadStop() + { - // Init private variables - _hasZeroconf = false; + /* Init private variables + setup: _path, _exist, _setupLoaded , _dbus + sound: _audiodriver, _dtmfKey, + _spkr_volume,_mic_volume = 0; // Initialize after by init() -> initVolume() + Call: _nbIncomingWaitingCall, _hasTriedToRegister + SIP Link: _userAgent, _userAgentInitlized + */ + #ifdef USE_ZEROCONF _hasZeroconf = true; _DNSService = new DNSService(); #endif - // setup - _path = ""; - _exist = 0; - _setupLoaded = false; - _dbus = NULL; - - // sound - _audiodriver = NULL; - _dtmfKey = 0; - _spkr_volume = 0; // Initialize after by init() -> initVolume() - _mic_volume = 0; // Initialize after by init() -> initVolume() - - // Call - _nbIncomingWaitingCall=0; - _hasTriedToRegister = false; - - // SIP Link - _userAgent = NULL; - _userAgentInitlized = false; - // initialize random generator for call id srand (time(NULL)); @@ -809,6 +826,7 @@ ManagerImpl::stopTone(bool stopAudio=true) { ManagerImpl::playTone() { playATone(Tone::TONE_DIALTONE); + return true; } /** @@ -818,6 +836,7 @@ ManagerImpl::playTone() ManagerImpl::playToneWithMessage() { playATone(Tone::TONE_CONGESTION); + return true; } /** @@ -1111,7 +1130,7 @@ ManagerImpl::setActiveCodecList(const std::vector< ::DBus::String >& list) std::string ManagerImpl::serialize(std::vector<std::string> v) { - int i; + unsigned int i; std::string res; for(i=0;i<v.size();i++) { @@ -1127,7 +1146,7 @@ ManagerImpl::getActiveCodecList( void ) _debug("Get Active codecs list\n"); std::vector< std::string > v; CodecOrder active = _codecDescriptorMap.getActiveCodecs(); - int i=0; + unsigned int i=0; size_t size = active.size(); while(i<size) { @@ -1247,7 +1266,7 @@ ManagerImpl::setInputAudioPlugin(const std::string& audioPlugin) void ManagerImpl::setOutputAudioPlugin(const std::string& audioPlugin) { - int layer = _audiodriver -> getLayerType(); + //int layer = _audiodriver -> getLayerType(); _debug("Set output audio plugin\n"); _audiodriver -> setErrorMessage( -1 ); _audiodriver -> openDevice( _audiodriver -> getIndexIn(), @@ -1278,7 +1297,7 @@ ManagerImpl::getAudioOutputDeviceList(void) void ManagerImpl::setAudioOutputDevice(const int index) { - int layer = _audiodriver -> getLayerType(); + //int layer = _audiodriver -> getLayerType(); _debug("Set audio output device: %i\n", index); _audiodriver -> setErrorMessage( -1 ); _audiodriver->openDevice(_audiodriver->getIndexIn(), @@ -1309,7 +1328,7 @@ ManagerImpl::getAudioInputDeviceList(void) void ManagerImpl::setAudioInputDevice(const int index) { - int layer = _audiodriver -> getLayerType(); + //int layer = _audiodriver -> getLayerType(); _debug("Set audio input device %i\n", index); _audiodriver -> setErrorMessage( -1 ); _audiodriver->openDevice(index, diff --git a/src/managerimpl.h b/src/managerimpl.h index f3c1e71478..f43800cb5a 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -819,6 +819,7 @@ class ManagerImpl { //pjsip_regc *getSipRegcFromID(const AccountID& id); private: + /** * Create .PROGNAME directory in home user and create * configuration tree from the settings file if this file exists. @@ -1026,6 +1027,13 @@ public: AccountID getAccountIdFromNameAndServer(const std::string& userName, const std::string& server); private: + + // Copy Constructor + ManagerImpl(const ManagerImpl& rh); + + // Assignment Operator + ManagerImpl& operator=( const ManagerImpl& rh); + /** * The UserAgent provides sip operation facilities for all sip accounts */ diff --git a/src/samplerateconverter.cpp b/src/samplerateconverter.cpp index 126c5d957c..3c6d0ed90d 100644 --- a/src/samplerateconverter.cpp +++ b/src/samplerateconverter.cpp @@ -18,19 +18,31 @@ #include "samplerateconverter.h" -SamplerateConverter::SamplerateConverter( void ) { - // Default values - _frequence = Manager::instance().getConfigInt( AUDIO , ALSA_SAMPLE_RATE ); // 44100; - _framesize = Manager::instance().getConfigInt( AUDIO , ALSA_FRAME_SIZE ); - +SamplerateConverter::SamplerateConverter( void ) + : _frequence(Manager::instance().getConfigInt( AUDIO , ALSA_SAMPLE_RATE )) //44100 + , _framesize(Manager::instance().getConfigInt( AUDIO , ALSA_FRAME_SIZE )) + , _floatBufferDownMic(NULL) + , _floatBufferUpMic(NULL) + , _src_state_mic(NULL) + , _floatBufferDownSpkr(NULL) + , _floatBufferUpSpkr(NULL) + , _src_state_spkr(NULL) + , _src_err(0) +{ init(); } -SamplerateConverter::SamplerateConverter( int freq , int fs ) { - - _frequence = freq ; - _framesize = fs ; - +SamplerateConverter::SamplerateConverter( int freq , int fs ) + : _frequence(freq) + , _framesize(fs) + , _floatBufferDownMic(NULL) + , _floatBufferUpMic(NULL) + , _src_state_mic(NULL) + , _floatBufferDownSpkr(NULL) + , _floatBufferUpSpkr(NULL) + , _src_state_spkr(NULL) + , _src_err(0) +{ init(); } diff --git a/src/samplerateconverter.h b/src/samplerateconverter.h index 86ea175319..f6423197fa 100644 --- a/src/samplerateconverter.h +++ b/src/samplerateconverter.h @@ -58,6 +58,12 @@ class SamplerateConverter { int getFramesize( void ) { return _framesize; } private: + // Copy Constructor + SamplerateConverter(const SamplerateConverter& rh); + + // Assignment Operator + SamplerateConverter& operator=( const SamplerateConverter& rh); + void init( void ); /** Audio layer caracteristics */ diff --git a/src/sipaccount.cpp b/src/sipaccount.cpp index 9d3aff2f6b..399b7fc2cc 100644 --- a/src/sipaccount.cpp +++ b/src/sipaccount.cpp @@ -28,8 +28,11 @@ SIPAccount::SIPAccount(const AccountID& accountID) : Account(accountID) + , _userName("") + , _server("") + , _cred(NULL) + , _contact("") { - _cred = NULL; _link = new SIPVoIPLink(accountID); } diff --git a/src/sipaccount.h b/src/sipaccount.h index 48eb62c7a8..5c32f1e50a 100644 --- a/src/sipaccount.h +++ b/src/sipaccount.h @@ -40,6 +40,12 @@ public: */ SIPAccount(const AccountID& accountID); + /* Copy Constructor */ + SIPAccount(const SIPAccount& rh); + + /* Assignment Operator */ + SIPAccount& operator=( const SIPAccount& rh); + /** * Virtual destructor */ diff --git a/src/sipcall.cpp b/src/sipcall.cpp index 4512839603..c5e33a7cb3 100644 --- a/src/sipcall.cpp +++ b/src/sipcall.cpp @@ -30,12 +30,15 @@ #define _RECVONLY 2 SIPCall::SIPCall(const CallID& id, Call::CallType type) : Call(id, type) + , _cid(0) + , _did(0) + , _tid(0) + , _localSDP(NULL) + , _negociator(NULL) + , _ipAddr("") + , _xferSub(NULL) + , _invSession(NULL) { - _cid = 0; - _did = 0; - _tid = 0; - _xferSub = NULL; - _invSession = NULL; } SIPCall::~SIPCall() diff --git a/src/sipcall.h b/src/sipcall.h index 1e0dcb5f51..fe23553d5d 100644 --- a/src/sipcall.h +++ b/src/sipcall.h @@ -130,6 +130,13 @@ class SIPCall : public Call pjsip_inv_session *getInvSession() {return _invSession;} private: + + // Copy Constructor + SIPCall(const SIPCall& rh); + + // Assignment Operator + SIPCall& operator=( const SIPCall& rh); + /** * Get a valid remote SDP or return a 400 bad request response if invalid * @param diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index 26cc9f91b4..129ad5ee3a 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -44,13 +44,21 @@ #define INVITE_METHOD "INVITE" SIPVoIPLink::SIPVoIPLink(const AccountID& accountID) - : VoIPLink(accountID), _localExternAddress("") + : VoIPLink(accountID) + , _initDone(false) + , _nbTryListenAddr(2) // number of times to try to start SIP listener + , _useStun(false) + , _stunServer("") + , _localExternAddress("") + , _localExternPort(0) + , _proxy("") + , _authname("") + , _password("") + , _audiortp(new AudioRtp()) + , _regc() + , _server("") + , _bRegister(false) { - - _nbTryListenAddr = 2; // number of times to try to start SIP listener - _localExternPort = 0; - - _audiortp = new AudioRtp(); // to get random number for RANDOM_PORT srand (time(NULL)); } @@ -352,7 +360,7 @@ SIPVoIPLink::carryingDTMFdigits(const CallID& id, char code) SIPCall* call = getSIPCall(id); if (call==0) { _debug("Call doesn't exist\n"); return false; } - int duration = Manager::instance().getConfigInt(SIGNALISATION, PULSE_LENGTH); + //int duration = Manager::instance().getConfigInt(SIGNALISATION, PULSE_LENGTH); // TODO Add DTMF with pjsip - INFO method diff --git a/src/sipvoiplink.h b/src/sipvoiplink.h index 265c6366e7..35d82e6c1e 100644 --- a/src/sipvoiplink.h +++ b/src/sipvoiplink.h @@ -60,6 +60,12 @@ class SIPVoIPLink : public VoIPLink */ ~SIPVoIPLink(); + /* Copy Constructor */ + SIPVoIPLink(const SIPVoIPLink& rh); + + /* Assignment Operator */ + SIPVoIPLink& operator=( const SIPVoIPLink& rh); + /** * Try to initiate the pjsip engine/thread and set config * @return bool True if OK diff --git a/src/useragent.cpp b/src/useragent.cpp index 4f4370208a..0ba6aefd4c 100644 --- a/src/useragent.cpp +++ b/src/useragent.cpp @@ -670,7 +670,7 @@ pj_bool_t UserAgent::mod_on_rx_request(pjsip_rx_data *rdata) { // Get the account id of callee from username and server account_id = Manager::instance().getAccountIdFromNameAndServer(userName, server); if(account_id == AccountNULL) { - _debug("UserAgent: Username %s doesn't match any account!\n",userName); + _debug("UserAgent: Username %s doesn't match any account!\n",userName.c_str()); return PJ_FALSE; } _debug("UserAgent: The receiver is : %s@%s\n", userName.data(), server.data()); diff --git a/src/useragent.h b/src/useragent.h index 8251e15742..655ba60f51 100644 --- a/src/useragent.h +++ b/src/useragent.h @@ -137,6 +137,13 @@ public: static UserAgent* getInstance() {return _current;} static void set_voicemail_info( AccountID account, pjsip_msg_body *body ); +private: + + // Copy Constructor + UserAgent(const UserAgent& rh); + + // Assignment Operator + UserAgent& operator=( const UserAgent& rh); }; -- GitLab