diff --git a/sflphone-common/src/audio/echocancel.cpp b/sflphone-common/src/audio/echocancel.cpp index 66e8780172a4db082dbdfaad9788cdfd727cfcef..59d962b141762f736cee282a489e5047e465038a 100644 --- a/sflphone-common/src/audio/echocancel.cpp +++ b/sflphone-common/src/audio/echocancel.cpp @@ -188,12 +188,14 @@ void EchoCancel::putData(SFLDataFormat *inputData, int nbBytes) { // std::cout << "putData nbBytes: " << nbBytes << std::endl; + /* if(_spkrStoped) { _debug("EchoCancel: Flush data"); _micData->flushAll(); _spkrData->flushAll(); _spkrStoped = false; } + */ // Put data in speaker ring buffer _spkrData->Put(inputData, nbBytes); @@ -204,10 +206,11 @@ void EchoCancel::process(SFLDataFormat *data, int nbBytes) {} int EchoCancel::process(SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes) { - + /* if(_spkrStoped) { return 0; } + */ int byteSize = _smplPerFrame*sizeof(SFLDataFormat); @@ -357,7 +360,7 @@ void EchoCancel::updateEchoCancel(SFLDataFormat *micData, SFLDataFormat *spkrDat if(_adaptCnt == _micAdaptSize) { _debug("EchoCancel: Echo path adaptation completed"); _adaptDone = true; - _amplDelayIndexOut = getMaximumIndex(_correlationArray, _correlationSize); + _amplDelayIndexOut = 0;// getMaximumIndex(_correlationArray, _correlationSize); _debug("EchoCancel: Echo length %d", _amplDelayIndexOut); spkrLearningData->write((const char *)_spkrAdaptArray, _spkrAdaptSize*sizeof(int)); micLearningData->write((const char *)_micAdaptArray, _micAdaptSize*sizeof(int)); diff --git a/sflphone-common/src/audio/echocancel.h b/sflphone-common/src/audio/echocancel.h index a06863fa19d7d6e68aab2b8504ffce8b71c03795..ab0c2bdd04d995379677a3c2f410b163157ef646 100644 --- a/sflphone-common/src/audio/echocancel.h +++ b/sflphone-common/src/audio/echocancel.h @@ -35,7 +35,7 @@ #define ECHO_LENGTH 50 // Voice level threashold -#define MIN_SIG_LEVEL 100 +#define MIN_SIG_LEVEL 1000 // Delay between mic and speaker #define DELAY_AMPLIFY 60 diff --git a/sflphone-common/src/audio/pulseaudio/audiostream.cpp b/sflphone-common/src/audio/pulseaudio/audiostream.cpp index 7a1d25d63ad275f397c186a4b4bc3a5fa51daa25..71f4a5bc4b5ddd433dd2e5e801686e9cd6ea9ff4 100644 --- a/sflphone-common/src/audio/pulseaudio/audiostream.cpp +++ b/sflphone-common/src/audio/pulseaudio/audiostream.cpp @@ -145,6 +145,13 @@ AudioStream::stream_state_callback (pa_stream* s, void* user_data) case PA_STREAM_READY: _info ("Audio: Stream successfully created, connected to %s", pa_stream_get_device_name (s)); + // pa_buffer_attr *buffattr = (pa_buffer_attr *)pa_xmalloc (sizeof(pa_buffer_attr)); + _debug("Audio: maxlength %u", pa_stream_get_buffer_attr(s)->maxlength); + _debug("Audio: tlength %u", pa_stream_get_buffer_attr(s)->tlength); + _debug("Audio: prebug %u", pa_stream_get_buffer_attr(s)->prebuf); + _debug("Audio: minreq %u", pa_stream_get_buffer_attr(s)->minreq); + _debug("Audio: fragsize %u", pa_stream_get_buffer_attr(s)->fragsize); + // pa_xfree (buffattr); break; case PA_STREAM_UNCONNECTED: @@ -210,7 +217,9 @@ AudioStream::createStream (pa_context* c, std::string *deviceName) } else if (_streamType == CAPTURE_STREAM) { attributes->maxlength = (uint32_t) -1; - attributes->fragsize = pa_usec_to_bytes (20 * PA_USEC_PER_MSEC, &_sample_spec); + attributes->tlength = pa_usec_to_bytes (20 * PA_USEC_PER_MSEC, &_sample_spec); + attributes->prebuf = 0; + attributes->fragsize = pa_usec_to_bytes (100 * PA_USEC_PER_MSEC, &_sample_spec); pa_threaded_mainloop_lock(_mainloop); diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp index bee3833e3b04cf8a6a26a47755bad9836a3a3bfb..74e3298ccbb2e0fd91eaace180a98656fea523c6 100644 --- a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp +++ b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp @@ -66,19 +66,16 @@ static void pa_success_callback(pa_context *c, int success, void *userdata) { static void latency_update_callback(pa_stream *p, void *userdata) { - pa_usec_t r_usec; - pa_buffer_attr *buffattr; + pa_usec_t r_usec; - pa_stream_get_latency (p, &r_usec, NULL); + pa_stream_get_latency (p, &r_usec, NULL); - // buffattr = pa_stream_get_buffer_attr(p); - _debug("Audio: Stream letency update %0.0f ms for device %s", (float)r_usec/1000, pa_stream_get_device_name(p)); - // _debug("Audio: maxlength %d", buffattr->maxlength); - // _debug("Audio: tlength %d", buffattr->tlength); - // _debug("Audio: prebug %d", buffattr->prebuf); - // _debug("Audio: minreq %d", buffattr->minreq); - // _debug("Audio: fragsize %d", buffattr->fragsize); + _debug("Audio: maxlength %u", pa_stream_get_buffer_attr(p)->maxlength); + _debug("Audio: tlength %u", pa_stream_get_buffer_attr(p)->tlength); + _debug("Audio: prebuf %u", pa_stream_get_buffer_attr(p)->prebuf); + _debug("Audio: minreq %u", pa_stream_get_buffer_attr(p)->minreq); + _debug("Audio: fragsize %u", pa_stream_get_buffer_attr(p)->fragsize); } @@ -558,6 +555,7 @@ bool PulseLayer::createStreams (pa_context* c) pa_stream_set_latency_update_callback(record->pulseStream(), latency_update_callback, this); delete recordParam; + /* PulseLayerType * ringtoneParam = new PulseLayerType(); ringtoneParam->context = c; ringtoneParam->type = RINGTONE_STREAM; @@ -575,7 +573,7 @@ bool PulseLayer::createStreams (pa_context* c) pa_stream_set_write_callback(ringtone->pulseStream(), ringtone_callback, this); pa_stream_set_moved_callback(ringtone->pulseStream(), stream_moved_callback, this); delete ringtoneParam; - + */ pa_threaded_mainloop_signal (m , 0); flushMain(); @@ -943,6 +941,7 @@ void PulseLayer::readFromMic (void) // echo cancellation processing int sampleready = _echoCanceller->processAudio(rsmpl_out, echoCancelledMic, nbSample*sizeof(SFLDataFormat)); + _debug("sampleready: %d", sampleready); // getMainBuffer()->putData ( (void*) rsmpl_out, nbSample*sizeof (SFLDataFormat), 100); if(sampleready) getMainBuffer()->putData ( echoCancelledMic, sampleready*sizeof (SFLDataFormat), 100);