Commit 8f3bbf3c authored by Rafaël Carré's avatar Rafaël Carré

Fix crash with noise suppressor

parent 201847af
......@@ -103,7 +103,7 @@ void AudioRtpRecordHandler::initNoiseSuppress()
delete _audioRtpRecord._noiseSuppress;
_audioRtpRecord._noiseSuppress = new NoiseSuppress (getCodecFrameSize(), getCodecSampleRate());
_audioRtpRecord._noiseSuppress = new NoiseSuppress(getCodecFrameSize(), getCodecSampleRate());
_audioRtpRecord.audioProcessMutex.leave();
}
......@@ -146,14 +146,9 @@ int AudioRtpRecordHandler::processDataEncode (void)
fadeIn (micData, samples, &_audioRtpRecord._micAmplFactor);
if(Manager::instance().getEchoCancelState() == "enabled")
if(Manager::instance().getEchoCancelState())
echoCanceller.getData(micData);
_audioRtpRecord.audioProcessMutex.enter();
if (Manager::instance().audioPreference.getNoiseReduce())
_audioRtpRecord._noiseSuppress->process(micData, samples);
_audioRtpRecord.audioProcessMutex.leave();
#ifdef DUMP_PROCESS_DATA_ENCODE
teststream.write(reinterpret_cast<char *>(micData), bytesToGet);
#endif
......@@ -164,8 +159,14 @@ int AudioRtpRecordHandler::processDataEncode (void)
_audioRtpRecord._converter->resample (micData, micDataConverted, codecSampleRate, mainBufferSampleRate, samplesToGet);
}
if (Manager::instance().audioPreference.getNoiseReduce()) {
_audioRtpRecord.audioProcessMutex.enter();
_audioRtpRecord._noiseSuppress->process(micData, getCodecFrameSize());
_audioRtpRecord.audioProcessMutex.leave();
}
_audioRtpRecord.audioCodecMutex.enter();
int compSize = _audioRtpRecord._audioCodec->encode (micDataEncoded, out, DEC_BUFFER_SIZE);
int compSize = _audioRtpRecord._audioCodec->encode (micDataEncoded, out, getCodecFrameSize());
_audioRtpRecord.audioCodecMutex.leave();
return compSize;
......@@ -205,7 +206,7 @@ void AudioRtpRecordHandler::processDataDecode (unsigned char *spkrData, unsigned
out = spkrDataConverted;
}
if(Manager::instance().getEchoCancelState() == "enabled")
if(Manager::instance().getEchoCancelState())
echoCanceller.putData(out, outSamples);
Manager::instance().getMainBuffer()->putData (out, outSamples * sizeof (SFLDataFormat), id_);
}
......
......@@ -288,7 +288,7 @@ void ConfigurationManager::setNoiseSuppressState (const std::string& state)
std::string ConfigurationManager::getEchoCancelState(void)
{
return Manager::instance().getEchoCancelState();
return Manager::instance().getEchoCancelState() ? "enabled" : "disabled";
}
void ConfigurationManager::setEchoCancelState(const std::string& state)
......
......@@ -2246,9 +2246,9 @@ void ManagerImpl::setNoiseSuppressState (const std::string &state)
audioPreference.setNoiseReduce (state == "enabled");
}
std::string ManagerImpl::getEchoCancelState() const
bool ManagerImpl::getEchoCancelState() const
{
return audioPreference.getEchoCancel() ? "enabled" : "disabled";
return audioPreference.getEchoCancel();
}
void ManagerImpl::setEchoCancelState(const std::string &state)
......
......@@ -567,7 +567,7 @@ class ManagerImpl
* Get the echo canceller engin state from
* the current audio layer
*/
std::string getEchoCancelState(void) const;
bool getEchoCancelState(void) const;
/**
* Set the echo canceller engin state
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment