pjsip / pjproject

PJSIP project
http://www.pjsip.org
GNU General Public License v2.0
2.06k stars 782 forks source link

pjmedia_echo_cancel does not get called whilst using Speex aec #3444

Closed IWaheed closed 1 year ago

IWaheed commented 1 year ago

Describe the bug

The function "pjmedia_echo_capture" is structured as such: `PJ_DEF(pj_status_t) pjmedia_echo_capture( pjmedia_echo_state echo, pj_int16_t rec_frm, unsigned options ) { struct frame *oldest_frm; pj_status_t status, rc;

/* If EC algo has capture handler, just pass the frame. */
if (echo->op->ec_capture) {
return (*echo->op->ec_capture)(echo->state, rec_frm, options);
}

if (!echo->lat_ready) {
/* Prefetching to fill in the desired latency */
PJ_LOG(5,(echo->obj_name, "Prefetching.."));
return PJ_SUCCESS;
}

/* Retrieve oldest frame from the latency buffer */
oldest_frm = echo->lat_buf.next;
pj_list_erase(oldest_frm);

/* Cancel echo using this reference frame */
status = pjmedia_echo_cancel(echo, rec_frm, oldest_frm->buf, 
             options, NULL);

`

Therefore when capture handler is defined, it is called only and _pjmedia_echocancel does not get cancelled. Therefore the function _speex_aec_cancelecho never gets called. I don't expect that any echo cancelling will occur without the function being called.

There is no other instance in the library where _pjmedia_echocancel gets called

Steps to reproduce

Using makefile

`DISABLE_FEATURES := \

l16-codec   \

ilbc-codec  \

gsm-codec   \

g722-codec  \

g7221-codec \

libyuv \

libwebrtc \

#speex-codec \

#speex-aec   \

#g711-codec   \

ifeq ($(PJSIP_ENABLE_CXX),false)

DISABLE_FEATURES += pjsua2

endif

BUILD_ROOT := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VER)

PJSIP_INSTALL_DIR := $(EXTERNAL_BUILD_DIR)/third_party/pjproject/core/install

$(CONFIGURE) :

export EMBOX_GCC_LINK=full; \

cd $(BUILD_ROOT) && ( \

    ./configure \

        CC=$(EMBOX_GCC) \

        CXX=$(EMBOX_GXX) \

        --host=$(AUTOCONF_TARGET_TRIPLET) \

        --target=$(AUTOCONF_TARGET_TRIPLET) \

        --prefix=$(PJSIP_INSTALL_DIR) \

        $(DISABLE_FEATURES:%=--disable-%) \

        --enable-speex-aec \

        --with-external-pa; \
if [ -f $(CONF_DIR)/pjsip/config_site.h ]; then \

    cp $(CONF_DIR)/pjsip/config_site.h $(BUILD_ROOT)/pjlib/include/pj/config_site.h; \

else \

    cp ./config_site.h $(BUILD_ROOT)/pjlib/include/pj/config_site.h; \

fi

touch $@

$(BUILD) :

cd $(BUILD_ROOT) && ( \

    $(MAKE) dep; \

    $(MAKE) MAKEFLAGS='$(EMBOX_IMPORTED_MAKEFLAGS)'; \

)

touch $@`

PJSIP version

from archive https://github.com/pjsip/pjproject/archive/6470fb9e4bd9baa14d50f754dc7f945e7a76c828.zip

Context

Embox OS on stm32f7 board

Log, call stack, etc

Nothing relevant here
andreas-wehrmann commented 1 year ago

It's working fine. If you look inside speex_aec_capture() https://github.com/pjsip/pjproject/blob/8c41a770fe21d982ec911a6508fb56d15bc5cf29/pjmedia/src/pjmedia/echo_speex.c#L275 it calls speex_echo_capture() which cancels echo using the internal playback buffer.