Skip to content
Snippets Groups Projects
Commit 42ae12dd authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#2598] Use larger value for ALSA's period size and frame size

parent df85a6d2
Branches
Tags
No related merge requests found
......@@ -135,7 +135,8 @@ AlsaLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize,
std::string pcmc = buildDeviceTopo (plugin, indexIn, 0);
_converter = new SamplerateConverter (_audioSampleRate, _frameSize);
// use 1 sec buffer for resampling
_converter = new SamplerateConverter (_audioSampleRate, 1000);
// open_device (pcmp, pcmc, stream);
return true; // open_device (pcmp, pcmc, stream);
......@@ -383,12 +384,12 @@ bool AlsaLayer::alsa_set_params (snd_pcm_t *pcm_handle, int type, int rate)
int err;
int format;
int periods = 4;
int periodsize = 1024;
int periodsize = 2048;
/* Allocate the snd_pcm_hw_params_t struct */
snd_pcm_hw_params_malloc (&hwparams);
_periodSize = 940;
_periodSize = 2048;
/* Full configuration space */
if ( (err = snd_pcm_hw_params_any (pcm_handle, hwparams)) < 0) {
......
......@@ -285,7 +285,8 @@ bool PulseLayer::openDevice (int indexIn UNUSED, int indexOut UNUSED, int sample
// _urgentRingBuffer.flushAll();
flushUrgent();
_converter = new SamplerateConverter (_audioSampleRate, _frameSize*4);
// use 1 sec buffer for resampling
_converter = new SamplerateConverter (_audioSampleRate, 1000);
return true;
}
......
......@@ -77,8 +77,7 @@ void SamplerateConverter::init (void)
_src_state_spkr = src_new (SRC_LINEAR, 1, &_src_err);
int nbSamplesMax = (int) (getFrequence() * getFramesize() / 1000);
// TODO: fix this hack that make sure we have enought place in buffers to upsample
nbSamplesMax = nbSamplesMax*4;
_floatBufferDownMic = new float32[nbSamplesMax];
_floatBufferUpMic = new float32[nbSamplesMax];
_floatBufferDownSpkr = new float32[nbSamplesMax];
......@@ -104,9 +103,8 @@ int SamplerateConverter::upsampleData (SFLDataFormat* dataIn , SFLDataFormat* da
{
double upsampleFactor = (double) samplerate2 / samplerate1 ;
//_debug("factor = %f" , upsampleFactor);
int nbSamplesMax = (int) (samplerate2 * getFramesize() / 1000);
nbSamplesMax = nbSamplesMax*4;
if (upsampleFactor != 1 && dataIn != NULL) {
SRC_DATA src_data;
......@@ -136,10 +134,8 @@ int SamplerateConverter::downsampleData (SFLDataFormat* dataIn , SFLDataFormat*
{
double downsampleFactor = (double) samplerate1 / samplerate2;
//_debug("factor = %f" , downsampleFactor);
int nbSamplesMax = (int) (samplerate1 * getFramesize() / 1000);
nbSamplesMax = nbSamplesMax*4;
int nbSamplesMax = (int) (samplerate1 * getFramesize() / 1000);
if (downsampleFactor != 1) {
SRC_DATA src_data;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment