Загрузка данных


static void imx_ai_aec_process(MSFilter *f) {
	ImxAiAecState *s = (ImxAiAecState *)f->data;
	int nbytes = s->framesize * sizeof(int16_t);
	mblk_t *refm;
	int8_t *ref_tmp = (int8_t *)alloca(nbytes);
	int8_t *echo_tmp = (int8_t *)alloca(nbytes);

	if (s->bypass_mode) {
		while ((refm = ms_queue_get(f->inputs[0])) != NULL) ms_queue_put(f->outputs[0], refm);
		while ((refm = ms_queue_get(f->inputs[1])) != NULL) ms_queue_put(f->outputs[1], refm);
		return;
	}

	// 1. Get ref signal (from remote)
	if (f->inputs[0] != NULL) {
		if (s->echostarted) {
			while ((refm = ms_queue_get(f->inputs[0])) != NULL) {
				ms_bufferizer_put(&s->delayed_ref, dupmsg(refm));
				ms_flow_controlled_bufferizer_put(&s->ref, refm);
			}
		} else {
			ms_queue_flush(f->inputs[0]);
		}
	}

	// 2. Get mic signal
	ms_bufferizer_put_from_queue(&s->echo, f->inputs[1]);

	// 3. Main cycle
	while (ms_bufferizer_get_avail(&s->echo) >= (size_t)nbytes) {
		mblk_t *out_clean = allocb(nbytes, 0);
		int avail;

		if (!s->echostarted) s->echostarted = TRUE;

		// Checking if there is data in the delay buffer
		avail = (int)ms_bufferizer_get_avail(&s->delayed_ref);
        ms_message("%s(%d) avail=%u\n",__FUNCTION__,__LINE__,avail);
		if (avail < ((s->nominal_ref_samples * 2) + nbytes)) {
			// Silence injection if the reference is lagging behind
			avail = nbytes;
			refm = allocb(nbytes, 0);
			memset(refm->b_wptr, 0, nbytes);
			refm->b_wptr += nbytes;
			ms_bufferizer_put(&s->delayed_ref, refm);
			ms_queue_put(f->outputs[0], dupmsg(refm));
			if (!s->using_zeroes) {
				ms_warning("IMX AEC: Not enough ref samples, using zeroes");
				s->using_zeroes = TRUE;
			}
		} else {
			s->using_zeroes = FALSE;
			refm = allocb(nbytes, 0);
			ms_flow_controlled_bufferizer_read(&s->ref, refm->b_wptr, nbytes);
			refm->b_wptr += nbytes;
			ms_queue_put(f->outputs[0], refm);
		}

		// Reading aligned data
		ms_bufferizer_read(&s->echo, (uint8_t *)echo_tmp, nbytes);
		ms_bufferizer_read(&s->delayed_ref, (uint8_t *)ref_tmp, nbytes);
		avail -= nbytes;

		// AI Processing (AEC + NR)
#ifdef MY_CODE
		if (imx_ai_aecnr_core_process(s->aec_core, ref_tmp, echo_tmp, out_clean->b_wptr) != 0)
#endif
		{
			ms_error("imx_ai_aecnr_core_process failed");
			memcpy(out_clean->b_wptr, echo_tmp, nbytes); // Fallback
		}

		out_clean->b_wptr += nbytes;
		ms_queue_put(f->outputs[1], out_clean);
	}
}

Надо сконвертировать типы данных int8_t* to float* для переменных ref_tmp,echo_tmp,out_clean->b_wptr