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

[#1966] Add timing info in pulseaudio layer

parent 83037f49
No related branches found
No related tags found
No related merge requests found
......@@ -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));
......
......@@ -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
......
......@@ -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);
......
......@@ -67,18 +67,15 @@ 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_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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment