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

add condition on resampling for decoder (#1143)

parent ebe38528
No related branches found
No related tags found
No related merge requests found
...@@ -365,7 +365,7 @@ AudioRtpRTX::sendSessionFromMic(int timestamp) ...@@ -365,7 +365,7 @@ AudioRtpRTX::sendSessionFromMic(int timestamp)
_debug("fixed_codec_framesize: %i \n", fixed_codec_framesize); _debug("fixed_codec_framesize: %i \n", fixed_codec_framesize);
int maxBytesToGet = _layerSampleRate * fixed_codec_framesize * sizeof(SFLDataFormat) / 1000; int maxBytesToGet = _layerSampleRate * fixed_codec_framesize * sizeof(SFLDataFormat) / 1000;
_debug("maxBytesToGet %i \n", maxBytesToGet);
// available bytes inside ringbuffer // available bytes inside ringbuffer
int availBytesFromMic = audiolayer->canGetMic(); int availBytesFromMic = audiolayer->canGetMic();
...@@ -379,6 +379,7 @@ AudioRtpRTX::sendSessionFromMic(int timestamp) ...@@ -379,6 +379,7 @@ AudioRtpRTX::sendSessionFromMic(int timestamp)
// Get bytes from micRingBuffer to data_from_mic // Get bytes from micRingBuffer to data_from_mic
//_debug("get data from mic\n"); //_debug("get data from mic\n");
int nbSample = audiolayer->getMic( micData , bytesAvail ) / sizeof(SFLDataFormat); int nbSample = audiolayer->getMic( micData , bytesAvail ) / sizeof(SFLDataFormat);
_debug("nb of sample from mic %i \n", nbSample);
int compSize = 0; int compSize = 0;
// test if resampling is required // test if resampling is required
...@@ -483,20 +484,27 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime) ...@@ -483,20 +484,27 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime)
} }
int nbSample = nbInt16; int nbSample = nbInt16;
if (_audiocodec->getClockRate() != _layerSampleRate) {
// Do sample rate conversion // Do sample rate conversion
int nb_sample_down = nbSample; int nb_sample_down = nbSample;
nbSample = reSampleData(_codecSampleRate , nb_sample_down, UP_SAMPLING); nbSample = reSampleData(_codecSampleRate , nb_sample_down, UP_SAMPLING);
#ifdef DATAFORMAT_IS_FLOAT // #ifdef DATAFORMAT_IS_FLOAT
#else // #else
#endif // #endif
// Stor the number of samples for recording // Stor the number of samples for recording
_nSamplesSpkr = nbSample; _nSamplesSpkr = nbSample;
//audiolayer->playSamples( spkrDataConverted, nbSample * sizeof(SFLDataFormat), true); //audiolayer->playSamples( spkrDataConverted, nbSample * sizeof(SFLDataFormat), true);
audiolayer->putMain (spkrDataConverted, nbSample * sizeof(SFLDataFormat)); audiolayer->putMain (spkrDataConverted, nbSample * sizeof(SFLDataFormat));
} else {
// Stor the number of samples for recording
_nSamplesSpkr = nbSample;
audiolayer->putMain (spkrDataDecoded, nbSample * sizeof(SFLDataFormat));
}
// Notify (with a beep) an incoming call when there is already a call // Notify (with a beep) an incoming call when there is already a call
countTime += time->getSecond(); countTime += time->getSecond();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment