diff --git a/daemon/src/audio/alsa/alsalayer.cpp b/daemon/src/audio/alsa/alsalayer.cpp index 3a7550e0adeebc4f88695f77284df981adef2f0a..7f310dd39cc134d167a25270fc32754506ab8743 100644 --- a/daemon/src/audio/alsa/alsalayer.cpp +++ b/daemon/src/audio/alsa/alsalayer.cpp @@ -92,11 +92,11 @@ AlsaLayer::AlsaLayer (ManagerImpl* manager) { _debug ("Audio: Build ALSA layer"); - _urgentRingBuffer.createReadPointer(); + urgentRingBuffer_.createReadPointer(); - audioPlugin_ = AudioLayer::_manager->audioPreference.getPlugin(); + audioPlugin_ = manager_->audioPreference.getPlugin(); - AudioLayer::_noisesuppressstate = true; + noiseSuppressState_ = true; } // Destructor @@ -146,26 +146,26 @@ AlsaLayer::openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, else if ( (stream == SFL_PCM_PLAYBACK or stream == SFL_PCM_BOTH) and is_playback_open_) closePlaybackStream (); - _indexIn = indexIn; - _indexOut = indexOut; - _indexRing = indexRing; + indexIn_ = indexIn; + indexOut_ = indexOut; + indexRing_ = indexRing; - _audioSampleRate = sampleRate; - _frameSize = frameSize; + audioSampleRate_ = sampleRate; + frameSize_ = frameSize; audioPlugin_ = plugin; - _debugAlsa (" Setting AlsaLayer: device in=%2d, out=%2d, ring=%2d", _indexIn, _indexOut, _indexRing); + _debugAlsa (" Setting AlsaLayer: device in=%2d, out=%2d, ring=%2d", indexIn_, indexOut_, indexRing_); _debugAlsa (" : alsa plugin=%s", audioPlugin_.c_str()); - _debugAlsa (" : nb channel in=%2d, out=%2d", _inChannel, _outChannel); - _debugAlsa (" : sample rate=%5d, format=%s", _audioSampleRate, SFLDataFormatString); + _debugAlsa (" : nb channel in=%2d, out=%2d", inChannel_, outChannel_); + _debugAlsa (" : sample rate=%5d, format=%s", audioSampleRate_, SFLDataFormatString); audioThread_ = NULL; // use 1 sec buffer for resampling - converter_ = new SamplerateConverter (_audioSampleRate); - _dcblocker = new DcBlocker; - _audiofilter = new AudioProcessing (_dcblocker); + converter_ = new SamplerateConverter (audioSampleRate_); + dcblocker_ = new DcBlocker; + audiofilter_ = new AudioProcessing (dcblocker_); } void @@ -173,8 +173,8 @@ AlsaLayer::startStream (void) { _debug ("Audio: Start stream"); - if (_audiofilter) - _audiofilter->resetAlgorithm(); + if (audiofilter_) + audiofilter_->resetAlgorithm(); if (is_playback_running_ and is_capture_running_) return; @@ -184,18 +184,18 @@ AlsaLayer::startStream (void) std::string pcmc; if (audioPlugin_ == PCM_DMIX_DSNOOP) { - pcmp = buildDeviceTopo (PCM_DMIX, _indexOut, 0); - pcmr = buildDeviceTopo (PCM_DMIX, _indexRing, 0); - pcmc = buildDeviceTopo (PCM_DSNOOP, _indexIn, 0); + pcmp = buildDeviceTopo (PCM_DMIX, indexOut_, 0); + pcmr = buildDeviceTopo (PCM_DMIX, indexRing_, 0); + pcmc = buildDeviceTopo (PCM_DSNOOP, indexIn_, 0); } else { - pcmp = buildDeviceTopo (audioPlugin_, _indexOut, 0); - pcmr = buildDeviceTopo (audioPlugin_, _indexRing, 0); - pcmc = buildDeviceTopo (audioPlugin_, _indexIn, 0); + pcmp = buildDeviceTopo (audioPlugin_, indexOut_, 0); + pcmr = buildDeviceTopo (audioPlugin_, indexRing_, 0); + pcmc = buildDeviceTopo (audioPlugin_, indexIn_, 0); } - _debug ("pcmp: %s, index %d", pcmp.c_str(), _indexOut); - _debug ("pcmr: %s, index %d", pcmr.c_str(), _indexRing); - _debug ("pcmc: %s, index %d", pcmc.c_str(), _indexIn); + _debug ("pcmp: %s, index %d", pcmp.c_str(), indexOut_); + _debug ("pcmr: %s, index %d", pcmr.c_str(), indexRing_); + _debug ("pcmc: %s, index %d", pcmc.c_str(), indexIn_); if (not is_capture_open_) open_device (pcmp, pcmc, pcmr, SFL_PCM_CAPTURE); @@ -222,7 +222,7 @@ AlsaLayer::startStream (void) } } - _isStarted = true; + isStarted_ = true; } void @@ -230,7 +230,7 @@ AlsaLayer::stopStream (void) { _debug ("Audio: Stop stream"); - _isStarted = false; + isStarted_ = false; try { /* Stop the audio thread first */ @@ -256,12 +256,6 @@ AlsaLayer::stopStream (void) flushMain (); } -void AlsaLayer::setNoiseSuppressState (bool state) -{ - // if a stream already opened - AudioLayer::_noisesuppressstate = state; -} - ////////////////////////////////////////////////////////////////////////////////////////////// ///////////////// ALSA PRIVATE FUNCTIONS //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// @@ -430,17 +424,17 @@ bool AlsaLayer::alsa_set_params (snd_pcm_t *pcm_handle, int type) /* Set sample rate. If we can't set to the desired exact value, we set to the nearest acceptable */ int dir = 0; - unsigned int exact_ivalue = _audioSampleRate; + unsigned int exact_ivalue = audioSampleRate_; if ((err = snd_pcm_hw_params_set_rate_near (pcm_handle, hwparams, &exact_ivalue, &dir) < 0)) { _debugAlsa ("Audio: Error: Cannot set sample rate (%s)", snd_strerror (err)); return false; } else - _debug ("Audio: Set audio rate to %d", _audioSampleRate); + _debug ("Audio: Set audio rate to %d", audioSampleRate_); if (dir != 0) { - _debugAlsa ("Audio: Error: (%i) The chosen rate %d Hz is not supported by your hardware.Using %d Hz instead. ", type , _audioSampleRate, exact_ivalue); - _audioSampleRate = exact_ivalue; + _debugAlsa ("Audio: Error: (%i) The chosen rate %d Hz is not supported by your hardware.Using %d Hz instead. ", type , audioSampleRate_, exact_ivalue); + audioSampleRate_ = exact_ivalue; } /* Set the number of channels */ @@ -808,19 +802,19 @@ namespace void AlsaLayer::audioCallback (void) { - unsigned int _mainBufferSampleRate = getMainBuffer()->getInternalSamplingRate(); - bool resample = _audioSampleRate != _mainBufferSampleRate; + unsigned int mainBufferSampleRate = getMainBuffer()->getInternalSamplingRate(); + bool resample = audioSampleRate_ != mainBufferSampleRate; notifyincomingCall(); - unsigned short spkrVolume = _manager->getSpkrVolume(); + unsigned short spkrVolume = manager_->getSpkrVolume(); - AudioLoop *tone = _manager->getTelephoneTone(); - AudioLoop *file_tone = _manager->getTelephoneFile(); + AudioLoop *tone = manager_->getTelephoneTone(); + AudioLoop *file_tone = manager_->getTelephoneFile(); // AvailForGet tell the number of chars inside the buffer // framePerBuffer are the number of data for one channel (left) - int urgentAvailBytes = _urgentRingBuffer.AvailForGet(); + int urgentAvailBytes = urgentRingBuffer_.AvailForGet(); if (!playbackHandle_ or !captureHandle_) return; @@ -836,7 +830,7 @@ void AlsaLayer::audioCallback (void) if (toGet > playbackAvailBytes) toGet = playbackAvailBytes; SFLDataFormat *out = (SFLDataFormat*) malloc (toGet); - _urgentRingBuffer.Get (out, toGet); + urgentRingBuffer_.Get (out, toGet); adjustVolume(out, toGet / sizeof(SFLDataFormat), spkrVolume); write (out, toGet, playbackHandle_); @@ -867,7 +861,7 @@ void AlsaLayer::audioCallback (void) // Compute maximal value to get from the ring buffer double resampleFactor = 1.0; if (resample) { - resampleFactor = (double) _audioSampleRate / _mainBufferSampleRate; + resampleFactor = (double) audioSampleRate_ / mainBufferSampleRate; maxNbBytesToGet = (double) toGet / resampleFactor; } @@ -882,7 +876,7 @@ void AlsaLayer::audioCallback (void) int inSamples = toGet / sizeof(SFLDataFormat); int outSamples = inSamples * resampleFactor; SFLDataFormat *rsmpl_out = (SFLDataFormat*) malloc (outSamples * sizeof(SFLDataFormat)); - converter_->resample (out, rsmpl_out, _mainBufferSampleRate, _audioSampleRate, inSamples); + converter_->resample (out, rsmpl_out, mainBufferSampleRate, audioSampleRate_, inSamples); write (rsmpl_out, outSamples * sizeof(SFLDataFormat), playbackHandle_); free (rsmpl_out); } else { @@ -932,19 +926,19 @@ void AlsaLayer::audioCallback (void) free(in); return; } - adjustVolume (in, toPutSamples, _manager->getSpkrVolume()); + adjustVolume (in, toPutSamples, manager_->getSpkrVolume()); if (resample) { - int outSamples = toPutSamples * ((double) _audioSampleRate / _mainBufferSampleRate); + int outSamples = toPutSamples * ((double) audioSampleRate_ / mainBufferSampleRate); int outBytes = outSamples * sizeof (SFLDataFormat); SFLDataFormat* rsmpl_out = (SFLDataFormat*) malloc (outBytes); - converter_->resample ( (SFLDataFormat*) in, rsmpl_out, _mainBufferSampleRate, _audioSampleRate, toPutSamples); - _audiofilter->processAudio (rsmpl_out, outBytes); + converter_->resample ( (SFLDataFormat*) in, rsmpl_out, mainBufferSampleRate, audioSampleRate_, toPutSamples); + audiofilter_->processAudio (rsmpl_out, outBytes); getMainBuffer()->putData (rsmpl_out, outBytes); free (rsmpl_out); } else { SFLDataFormat* filter_out = (SFLDataFormat*) malloc (toPutBytes); - _audiofilter->processAudio (in, filter_out, toPutBytes); + audiofilter_->processAudio (in, filter_out, toPutBytes); getMainBuffer()->putData (filter_out, toPutBytes); free (filter_out); } diff --git a/daemon/src/audio/alsa/alsalayer.h b/daemon/src/audio/alsa/alsalayer.h index ff4f8ace624342b6730e6792204c5fdbae38a40a..46c5c92edbeefcabcb17ed572cb79a5c1f2adc50 100644 --- a/daemon/src/audio/alsa/alsalayer.h +++ b/daemon/src/audio/alsa/alsalayer.h @@ -144,19 +144,6 @@ class AlsaLayer : public AudioLayer void audioCallback (void); - /** - * Get the noise suppressor state - * @return true if noise suppressor activated - */ - virtual bool getNoiseSuppressState (void) const { - return AudioLayer::_noisesuppressstate; - } - - /** - * Set the noise suppressor state - * @param state true if noise suppressor active, false elsewhere - */ - virtual void setNoiseSuppressState (bool state); private: void closeLayer (void); diff --git a/daemon/src/audio/audiolayer.cpp b/daemon/src/audio/audiolayer.cpp index 973f0272e13dc78783a83f19dda6e0feafcaee5c..dc19e57380e72e92ecba7d370ac492b6b9c4d6e2 100644 --- a/daemon/src/audio/audiolayer.cpp +++ b/daemon/src/audio/audiolayer.cpp @@ -36,66 +36,66 @@ #include <cc++/numbers.h> AudioLayer::AudioLayer (ManagerImpl* manager , int type) - : _layerType (type) - , _isStarted(false) - , _manager (manager) - , _urgentRingBuffer (SIZEBUF, Call::DEFAULT_ID) - , _mainBuffer(0) - , _recorder(0) - , _indexIn (0) - , _indexOut (0) - , _indexRing(0) - , _audioSampleRate (0) - , _frameSize (0) - , _inChannel (1) - , _outChannel (1) - , _errorMessage (0) - , _mutex () - , _dcblocker(0) - , _audiofilter(0) - , _noisesuppressstate(false) - , _countNotificationTime(0) - , _time (new ost::Time) + : layerType_ (type) + , isStarted_ (false) + , manager_ (manager) + , urgentRingBuffer_ (SIZEBUF, Call::DEFAULT_ID) + , mainBuffer_ (0) + , recorder_ (0) + , indexIn_ (0) + , indexOut_ (0) + , indexRing_ (0) + , audioSampleRate_ (0) + , frameSize_ (0) + , inChannel_ (1) + , outChannel_ (1) + , errorMessage_ (0) + , mutex_ () + , dcblocker_ (0) + , audiofilter_ (0) + , noiseSuppressState_ (false) + , countNotificationTime_ (0) + , time_ (new ost::Time) {} AudioLayer::~AudioLayer () { - delete _time; - delete _audiofilter; - delete _dcblocker; + delete time_; + delete audiofilter_; + delete dcblocker_; } void AudioLayer::flushMain (void) { - ost::MutexLock guard (_mutex); + ost::MutexLock guard (mutex_); // should pass call id getMainBuffer()->flushAllBuffers(); } void AudioLayer::flushUrgent (void) { - ost::MutexLock guard (_mutex); - _urgentRingBuffer.flushAll(); + ost::MutexLock guard (mutex_); + urgentRingBuffer_.flushAll(); } void AudioLayer::putUrgent (void* buffer, int toCopy) { - ost::MutexLock guard (_mutex); - _urgentRingBuffer.Put (buffer, toCopy); + ost::MutexLock guard (mutex_); + urgentRingBuffer_.Put (buffer, toCopy); } void AudioLayer::notifyincomingCall() { // Notify (with a beep) an incoming call when there is already a call if (Manager::instance().incomingCallWaiting()) { - _countNotificationTime += _time->getSecond(); - int countTimeModulo = _countNotificationTime % 5000; + countNotificationTime_ += time_->getSecond(); + int countTimeModulo = countNotificationTime_ % 5000; - if ((countTimeModulo - _countNotificationTime) < 0) + if ((countTimeModulo - countNotificationTime_) < 0) Manager::instance().notificationIncomingCall(); - _countNotificationTime = countTimeModulo; + countNotificationTime_ = countTimeModulo; } } diff --git a/daemon/src/audio/audiolayer.h b/daemon/src/audio/audiolayer.h index 0ba22e506243c5c48340a84bd5ec677d18785637..47a4fc70fa6d20543e9079360e48fbff982cf6d9 100644 --- a/daemon/src/audio/audiolayer.h +++ b/daemon/src/audio/audiolayer.h @@ -101,7 +101,7 @@ class AudioLayer */ virtual void stopStream (void) = 0; - bool isStarted(void) { return _isStarted; } + bool isStarted(void) const { return isStarted_; } /** * Send a chunk of data to the hardware buffer to start the playback @@ -121,8 +121,8 @@ class AudioLayer * Could be: ALSA_PLAYBACK_DEVICE * ALSA_CAPTURE_DEVICE */ - void setErrorMessage (const int& error) { - _errorMessage = error; + void setErrorMessage (int error) { + errorMessage_ = error; } /** @@ -130,7 +130,7 @@ class AudioLayer * @return int The error code */ int getErrorMessage() const { - return _errorMessage; + return errorMessage_; } /** @@ -139,7 +139,7 @@ class AudioLayer * 0 for the first available card on the system, 1 ... */ int getIndexIn() const { - return _indexIn; + return indexIn_; } /** @@ -148,7 +148,7 @@ class AudioLayer * 0 for the first available card on the system, 1 ... */ int getIndexOut() const { - return _indexOut; + return indexOut_; } /** @@ -157,7 +157,7 @@ class AudioLayer * 0 for the first available card on the system, 1 ... */ int getIndexRing() const { - return _indexRing; + return indexRing_; } /** @@ -166,7 +166,7 @@ class AudioLayer * default: 44100 HZ */ unsigned int getSampleRate() const { - return _audioSampleRate; + return audioSampleRate_; } /** @@ -175,7 +175,7 @@ class AudioLayer * default: 20 ms */ unsigned int getFrameSize() const { - return _frameSize; + return frameSize_; } /** @@ -184,7 +184,7 @@ class AudioLayer * */ int getLayerType (void) const { - return _layerType; + return layerType_; } /** @@ -196,54 +196,56 @@ class AudioLayer * @return MainBuffer* a pointer to the MainBuffer instance */ MainBuffer* getMainBuffer (void) const { - return _mainBuffer; + return mainBuffer_; } /** * Set the mainbuffer once the audiolayer is created */ void setMainBuffer (MainBuffer* mainbuffer) { - _mainBuffer = mainbuffer; + mainBuffer_ = mainbuffer; } /** * Set the audio recorder */ void setRecorderInstance (Recordable* rec) { - _recorder = rec; + recorder_ = rec; } /** * Get the audio recorder */ Recordable* getRecorderInstance (void) const { - return _recorder; + return recorder_; } - /** - * Get the noise suppressor state - * @return true if noise suppressor activated - */ - virtual bool getNoiseSuppressState (void) const = 0; - /** * Set the noise suppressor state * @param state true if noise suppressor active, false elsewhere */ - virtual void setNoiseSuppressState (bool state) = 0; + void setNoiseSuppressState (bool state) { noiseSuppressState_ = state; } + + /** + * Get the noise suppressor state + * @return true if noise suppressor activated + */ + bool getNoiseSuppressState (void) const { + return noiseSuppressState_; + } /** * Get the mutex lock for the entire audio layer */ ost::Mutex* getMutexLock (void) { - return &_mutex; + return &mutex_; } void notifyincomingCall (void); protected: - int _layerType; + int layerType_; /** * Drop the pending frames and close the capture device @@ -258,15 +260,15 @@ class AudioLayer /** * Wether or not the audio layer stream is started */ - bool _isStarted; + bool isStarted_; /** Augment coupling, reduce indirect access */ - ManagerImpl* _manager; + ManagerImpl* manager_; /** * Urgent ring buffer used for ringtones */ - RingBuffer _urgentRingBuffer; + RingBuffer urgentRingBuffer_; /** * Instance of the MainBuffer for the whole application @@ -275,72 +277,72 @@ class AudioLayer * Audio instances must be registered into the MainBuffer and bound together via the ManagerImpl. * */ - MainBuffer* _mainBuffer; + MainBuffer* mainBuffer_; /** * A pointer to the recordable instance (may be a call or a conference) */ - Recordable* _recorder; + Recordable* recorder_; /** * Number of audio cards on which capture stream has been opened */ - int _indexIn; + int indexIn_; /** * Number of audio cards on which playback stream has been opened */ - int _indexOut; + int indexOut_; /** * Number of audio cards on which ringtone stream has been opened */ - int _indexRing; + int indexRing_; /** * Sample Rate SFLphone should send sound data to the sound card * The value can be set in the user config file- now: 44100HZ */ - unsigned int _audioSampleRate; + unsigned int audioSampleRate_; /** * Length of the sound frame we capture or read in ms * The value can be set in the user config file - now: 20ms */ - unsigned int _frameSize; + unsigned int frameSize_; /** * Input channel (mic) should be 1 mono */ - unsigned int _inChannel; + unsigned int inChannel_; /** * Output channel (stereo) should be 1 mono */ - unsigned int _outChannel; + unsigned int outChannel_; /** Contains the current error code */ - int _errorMessage; + int errorMessage_; /** * Lock for the entire audio layer */ - ost::Mutex _mutex; + ost::Mutex mutex_; - DcBlocker *_dcblocker; - AudioProcessing *_audiofilter; + DcBlocker *dcblocker_; + AudioProcessing *audiofilter_; - bool _noisesuppressstate; + bool noiseSuppressState_; /** * Time counter used to trigger incoming call notification */ - int _countNotificationTime; + int countNotificationTime_; /** * Used to get formated system time in order to compute incoming call notification */ - ost::Time * _time; + ost::Time * time_; }; #endif // _AUDIO_LAYER_H_ diff --git a/daemon/src/audio/pulseaudio/pulselayer.cpp b/daemon/src/audio/pulseaudio/pulselayer.cpp index d46b0016bf55e9cab9911d67ea838845c2d91d92..da0d04fa451968cef82e4766db12cf09001e0551 100644 --- a/daemon/src/audio/pulseaudio/pulselayer.cpp +++ b/daemon/src/audio/pulseaudio/pulselayer.cpp @@ -227,9 +227,9 @@ PulseLayer::PulseLayer (ManagerImpl* manager) , ringtone_(0) , converter_(0) { - _urgentRingBuffer.createReadPointer(); + urgentRingBuffer_.createReadPointer(); - AudioLayer::_noisesuppressstate = true; + noiseSuppressState_ = true; openLayer(); } @@ -244,14 +244,14 @@ PulseLayer::~PulseLayer (void) void PulseLayer::openLayer (void) { - if(_isStarted) + if (isStarted_) return; _info ("Audio: Open Pulseaudio layer"); connectPulseAudioServer(); - _isStarted = true; + isStarted_ = true; } void @@ -259,7 +259,7 @@ PulseLayer::closeLayer (void) { _info ("Audio: Close Pulseaudio layer"); - _isStarted = false; + isStarted_ = false; disconnectAudioStream(); @@ -375,19 +375,19 @@ void PulseLayer::context_state_callback (pa_context* c, void* user_data) void PulseLayer::openDevice (int indexIn UNUSED, int indexOut UNUSED, int indexRing UNUSED, int sampleRate, int frameSize , int stream UNUSED, const std::string &plugin UNUSED) { - _debug ("Audio: Open device sampling rate %d, frame size %d", _audioSampleRate, _frameSize); + _debug ("Audio: Open device sampling rate %d, frame size %d", audioSampleRate_, frameSize_); - _audioSampleRate = sampleRate; - _frameSize = frameSize; + audioSampleRate_ = sampleRate; + frameSize_ = frameSize; flushUrgent(); // use 1 sec buffer for resampling - converter_ = new SamplerateConverter (_audioSampleRate); + converter_ = new SamplerateConverter (audioSampleRate_); // Instantiate the algorithm - AudioLayer::_dcblocker = new DcBlocker; - AudioLayer::_audiofilter = new AudioProcessing (_dcblocker); + dcblocker_ = new DcBlocker; + audiofilter_ = new AudioProcessing (dcblocker_); } @@ -426,11 +426,11 @@ void PulseLayer::createStreams (pa_context* c) { _info ("Audio: Create streams"); - playback_ = new AudioStream (c, mainloop_, PLAYBACK_STREAM_NAME, PLAYBACK_STREAM, _audioSampleRate); + playback_ = new AudioStream (c, mainloop_, PLAYBACK_STREAM_NAME, PLAYBACK_STREAM, audioSampleRate_); - std::string playbackDevice(_manager->audioPreference.getDevicePlayback()); - std::string recordDevice(_manager->audioPreference.getDeviceRecord()); - std::string ringtoneDevice(_manager->audioPreference.getDeviceRingtone()); + std::string playbackDevice(manager_->audioPreference.getDevicePlayback()); + std::string recordDevice(manager_->audioPreference.getDeviceRecord()); + std::string ringtoneDevice(manager_->audioPreference.getDeviceRingtone()); _debug ("Audio: Device for playback: %s", playbackDevice.c_str()); _debug ("Audio: Device for record: %s", recordDevice.c_str()); @@ -447,7 +447,7 @@ void PulseLayer::createStreams (pa_context* c) pa_stream_set_moved_callback (playback_->pulseStream(), stream_moved_callback, this); pa_stream_set_latency_update_callback (playback_->pulseStream(), latency_update_callback, this); - record_ = new AudioStream (c, mainloop_, CAPTURE_STREAM_NAME, CAPTURE_STREAM, _audioSampleRate); + record_ = new AudioStream (c, mainloop_, CAPTURE_STREAM_NAME, CAPTURE_STREAM, audioSampleRate_); if (inSourceList (recordDevice)) record_->connectStream (&recordDevice); @@ -458,7 +458,7 @@ void PulseLayer::createStreams (pa_context* c) pa_stream_set_moved_callback (record_->pulseStream(), stream_moved_callback, this); pa_stream_set_latency_update_callback (record_->pulseStream(), latency_update_callback, this); - ringtone_ = new AudioStream (c, mainloop_, RINGTONE_STREAM_NAME, RINGTONE_STREAM, _audioSampleRate); + ringtone_ = new AudioStream (c, mainloop_, RINGTONE_STREAM_NAME, RINGTONE_STREAM, audioSampleRate_); if (inSourceList (ringtoneDevice)) ringtone_->connectStream (&ringtoneDevice); @@ -493,7 +493,7 @@ void PulseLayer::closeCaptureStream (void) if (name && strlen (name)) { _debug ("Audio: record device to be stored in config: %s", name); - _manager->audioPreference.setDeviceRecord (name); + manager_->audioPreference.setDeviceRecord (name); } } @@ -511,7 +511,7 @@ void PulseLayer::closePlaybackStream (void) if (name && strlen (name)) { _debug ("Audio: playback device to be stored in config: %s", name); - _manager->audioPreference.setDevicePlayback (name); + manager_->audioPreference.setDevicePlayback (name); } } @@ -525,7 +525,7 @@ void PulseLayer::closePlaybackStream (void) if (name && strlen (name)) { _debug ("Audio: ringtone device to be stored in config: %s", name); - _manager->audioPreference.setDeviceRingtone (name); + manager_->audioPreference.setDeviceRingtone (name); } } @@ -622,14 +622,6 @@ void PulseLayer::processData (void) readFromMic(); } -void PulseLayer::setNoiseSuppressState (bool state) -{ - // if a stream already opened - AudioLayer::_noisesuppressstate = state; - -} - - void PulseLayer::writeToSpeaker (void) { notifyincomingCall(); @@ -641,12 +633,12 @@ void PulseLayer::writeToSpeaker (void) return; } - int urgentBytes = _urgentRingBuffer.AvailForGet(); + int urgentBytes = urgentRingBuffer_.AvailForGet(); if (urgentBytes > writeableSizeBytes) urgentBytes = writeableSizeBytes; if (urgentBytes) { SFLDataFormat *out = (SFLDataFormat*) pa_xmalloc (urgentBytes); - _urgentRingBuffer.Get (out, urgentBytes); + urgentRingBuffer_.Get (out, urgentBytes); pa_stream_write (playback_->pulseStream(), out, urgentBytes, NULL, 0, PA_SEEK_RELATIVE); pa_xfree (out); // Consume the regular one as well (same amount of bytes) @@ -654,7 +646,7 @@ void PulseLayer::writeToSpeaker (void) return; } - AudioLoop *toneToPlay = _manager->getTelephoneTone(); + AudioLoop *toneToPlay = manager_->getTelephoneTone(); if (toneToPlay) { if (playback_->getStreamState() == PA_STREAM_READY) { SFLDataFormat *out = (SFLDataFormat*) pa_xmalloc (writeableSizeBytes); @@ -677,7 +669,7 @@ void PulseLayer::writeToSpeaker (void) } unsigned int mainBufferSampleRate = getMainBuffer()->getInternalSamplingRate(); - bool resample = _audioSampleRate != mainBufferSampleRate; + bool resample = audioSampleRate_ != mainBufferSampleRate; // how much samples we can write in the output int outSamples = writeableSizeBytes / sizeof(SFLDataFormat); @@ -687,7 +679,7 @@ void PulseLayer::writeToSpeaker (void) double resampleFactor = 1.; if (resample) { - resampleFactor = (double) _audioSampleRate / mainBufferSampleRate; + resampleFactor = (double) audioSampleRate_ / mainBufferSampleRate; inSamples = (double) inSamples / resampleFactor; } @@ -702,7 +694,7 @@ void PulseLayer::writeToSpeaker (void) // test if resampling is required if (resample) { SFLDataFormat* rsmpl_out = (SFLDataFormat*) pa_xmalloc (outBytes); - converter_->resample (out, rsmpl_out, mainBufferSampleRate, _audioSampleRate, inSamples); + converter_->resample (out, rsmpl_out, mainBufferSampleRate, audioSampleRate_, inSamples); pa_stream_write (playback_->pulseStream(), rsmpl_out, outBytes, NULL, 0, PA_SEEK_RELATIVE); pa_xfree (rsmpl_out); } else @@ -717,7 +709,7 @@ void PulseLayer::readFromMic (void) size_t r; unsigned int mainBufferSampleRate = getMainBuffer()->getInternalSamplingRate(); - bool resample = _audioSampleRate != mainBufferSampleRate; + bool resample = audioSampleRate_ != mainBufferSampleRate; if (pa_stream_peek (record_->pulseStream() , (const void**) &data , &r) < 0 or !data) { _error("Audio: Error capture stream peek failed: %s" , pa_strerror (pa_context_errno (context_))); @@ -726,20 +718,20 @@ void PulseLayer::readFromMic (void) if (resample) { int inSamples = r / sizeof(SFLDataFormat); - double resampleFactor = (double) _audioSampleRate / mainBufferSampleRate; + double resampleFactor = (double) audioSampleRate_ / mainBufferSampleRate; int outSamples = (double) inSamples * resampleFactor; int outBytes = outSamples * sizeof(SFLDataFormat); SFLDataFormat* rsmpl_out = (SFLDataFormat*) pa_xmalloc (outBytes); - converter_->resample ( (SFLDataFormat *) data, rsmpl_out, mainBufferSampleRate, _audioSampleRate, inSamples); + converter_->resample ( (SFLDataFormat *) data, rsmpl_out, mainBufferSampleRate, audioSampleRate_, inSamples); // remove dc offset - _audiofilter->processAudio (rsmpl_out, outBytes); + audiofilter_->processAudio (rsmpl_out, outBytes); getMainBuffer()->putData (rsmpl_out, outBytes); pa_xfree (rsmpl_out); } else { SFLDataFormat* filter_out = (SFLDataFormat*) pa_xmalloc (r); // remove dc offset - _audiofilter->processAudio ( (SFLDataFormat *) data, filter_out, r); + audiofilter_->processAudio ( (SFLDataFormat *) data, filter_out, r); getMainBuffer()->putData (filter_out, r); pa_xfree (filter_out); } @@ -752,7 +744,7 @@ end: void PulseLayer::ringtoneToSpeaker (void) { - AudioLoop* fileToPlay = _manager->getTelephoneFile(); + AudioLoop* fileToPlay = manager_->getTelephoneFile(); int writableSize = pa_stream_writable_size (ringtone_->pulseStream()); if (fileToPlay) { diff --git a/daemon/src/audio/pulseaudio/pulselayer.h b/daemon/src/audio/pulseaudio/pulselayer.h index 05ed174a8ad31e5169419eba7f1417bbd9966709..353f1668667ebffa83f31b12dc2983ac7b8a2403 100644 --- a/daemon/src/audio/pulseaudio/pulselayer.h +++ b/daemon/src/audio/pulseaudio/pulselayer.h @@ -173,20 +173,6 @@ class PulseLayer : public AudioLayer */ void processData (void); - /** - * Get the noise suppressor state - * @return true if noise suppressor activated - */ - bool getNoiseSuppressState (void) const { - return AudioLayer::_noisesuppressstate; - } - - /** - * Set the noise suppressor state - * @param state true if noise suppressor active, false elsewhere - */ - void setNoiseSuppressState (bool state); - private: // Copy Constructor PulseLayer (const PulseLayer& rh);