Commit 90d9c09c authored by Rafaël Carré's avatar Rafaël Carré
Browse files

* #6629 : use DC blocker directly in audio layers

parent 0171ee72
......@@ -162,8 +162,6 @@ AlsaLayer::openDevice (int indexIn, int indexOut, int indexRing, int sampleRate,
// use 1 sec buffer for resampling
converter_ = new SamplerateConverter (audioSampleRate_);
dcblocker_ = new DcBlocker;
audiofilter_ = new AudioProcessing (dcblocker_);
}
void
......@@ -171,8 +169,7 @@ AlsaLayer::startStream (void)
{
_debug ("Audio: Start stream");
if (audiofilter_)
audiofilter_->resetAlgorithm();
dcblocker_.reset();
if (is_playback_running_ and is_capture_running_)
return;
......@@ -931,12 +928,12 @@ void AlsaLayer::audioCallback (void)
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);
dcblocker_.process(rsmpl_out, outBytes);
getMainBuffer()->putData (rsmpl_out, outBytes);
free (rsmpl_out);
} else {
SFLDataFormat* filter_out = (SFLDataFormat*) malloc (toPutBytes);
audiofilter_->processAudio (in, filter_out, toPutBytes);
dcblocker_.process(in, filter_out, toPutBytes);
getMainBuffer()->putData (filter_out, toPutBytes);
free (filter_out);
}
......
......@@ -49,8 +49,6 @@ AudioLayer::AudioLayer (int type)
, outChannel_ (1)
, errorMessage_ (0)
, mutex_ ()
, dcblocker_ (0)
, audiofilter_ (0)
, audioPref(Manager::instance().audioPreference)
, lastNotificationTime_ (0)
{}
......@@ -58,8 +56,6 @@ AudioLayer::AudioLayer (int type)
AudioLayer::~AudioLayer ()
{
delete audiofilter_;
delete dcblocker_;
}
void AudioLayer::flushMain (void)
......
......@@ -39,15 +39,15 @@
#include "manager.h"
#include "ringbuffer.h"
#include "dcblocker.h"
/**
* @file audiolayer.h
* @brief Main sound class. Manages the data transfers between the application and the hardware.
*/
class DcBlocker;
class MainBuffer;
class AudioProcessing;
namespace ost {
class Time;
}
......@@ -296,8 +296,7 @@ class AudioLayer
*/
ost::Mutex mutex_;
DcBlocker *dcblocker_;
AudioProcessing *audiofilter_;
DcBlocker dcblocker_;
AudioPreference &audioPref;
......
......@@ -382,10 +382,6 @@ void PulseLayer::openDevice (int indexIn UNUSED, int indexOut UNUSED, int indexR
// use 1 sec buffer for resampling
converter_ = new SamplerateConverter (audioSampleRate_);
// Instantiate the algorithm
dcblocker_ = new DcBlocker;
audiofilter_ = new AudioProcessing (dcblocker_);
}
......@@ -723,13 +719,13 @@ void PulseLayer::readFromMic (void)
SFLDataFormat* rsmpl_out = (SFLDataFormat*) pa_xmalloc (outBytes);
converter_->resample ( (SFLDataFormat *) data, rsmpl_out, mainBufferSampleRate, audioSampleRate_, inSamples);
// remove dc offset
audiofilter_->processAudio (rsmpl_out, outBytes);
dcblocker_.process(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);
dcblocker_.process( (SFLDataFormat *) data, filter_out, r);
getMainBuffer()->putData (filter_out, r);
pa_xfree (filter_out);
}
......
......@@ -2425,20 +2425,16 @@ std::string ManagerImpl::getCurrentAudioOutputPlugin (void) const
std::string ManagerImpl::getNoiseSuppressState (void) const
{
// noise suppress disabled by default
return audioPreference.getNoiseReduce() ? "enabled" : "disabled";
}
void ManagerImpl::setNoiseSuppressState (const std::string &state)
{
bool isEnabled = (state == "enabled");
audioPreference.setNoiseReduce (isEnabled);
audioPreference.setNoiseReduce (state == "enabled");
}
std::string ManagerImpl::getEchoCancelState() const
{
// echo canceller disabled by default
return audioPreference.getEchoCancel() ? "enabled" : "disabled";
}
......
Supports Markdown
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