diff --git a/src/audio/google/google_rtc_audio_processing.c b/src/audio/google/google_rtc_audio_processing.c index e3a8d95a72c9..c06f13eb4471 100644 --- a/src/audio/google/google_rtc_audio_processing.c +++ b/src/audio/google/google_rtc_audio_processing.c @@ -91,6 +91,8 @@ struct google_rtc_audio_processing_comp_data { int aec_reference_source; int raw_microphone_source; struct comp_buffer *ref_comp_buffer; + int ref_frame_bytes; + int out_frame_bytes; }; #if CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MIC_BITS == 16 @@ -607,7 +609,9 @@ static int google_rtc_audio_processing_prepare(struct processing_module *mod, if (mic_fmt != bits_fmt(CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MIC_BITS)) { comp_err(dev, "Mic stream must be %d bit samples\n", CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MIC_BITS); - ret = -EINVAL; + + // FIXME: squash for now, the streams lie. See below. + //ret = -EINVAL; } if (mic_fmt != out_fmt) { @@ -615,6 +619,14 @@ static int google_rtc_audio_processing_prepare(struct processing_module *mod, ret = -EINVAL; } + // FIXME: the streams have a bad format on MTL, so we can't + // use this API. Compute by hand. + // + //cd->ref_frame_bytes = source_get_frame_bytes(sources[cd->aec_reference_source]); + //cd->out_frame_bytes = sink_get_frame_bytes(sinks[0]); + cd->ref_frame_bytes = sizeof(mic_sample_t) * source_get_channels(sources[cd->aec_reference_source]); + cd->out_frame_bytes = cd->ref_frame_bytes; + /* Blobs sent during COMP_STATE_READY is assigned to blob_handler->data * directly, so comp_is_new_data_blob_available always returns false. */ @@ -777,7 +789,7 @@ static int mod_process(struct processing_module *mod, struct sof_source **source * samples so AEC compares the most recent values. */ if (ref_ok && fref > fmic) - source_release_data(ref, (fref - fmic) * source_get_frame_bytes(ref)); + source_release_data(ref, (fref - fmic) * cd->ref_frame_bytes); for (frames_rem = frames; frames_rem; frames_rem -= n) { n = MIN(frames_rem, cd->num_frames - cd->buffered_frames); @@ -814,7 +826,7 @@ static bool mod_is_ready_to_process(struct processing_module *mod, * Currently the topology sets IBS incorrectly */ if (ref_ok && (source_get_data_available(ref) - < cd->num_frames * source_get_frame_bytes(ref))) + < cd->num_frames * cd->ref_frame_bytes)) return false; if (source_get_data_available(mic) < source_get_min_available(mic)) @@ -823,7 +835,7 @@ static bool mod_is_ready_to_process(struct processing_module *mod, /* Output comes out all at once, the output sink much have * space for the full block */ - if (sink_get_free_size(out) < cd->num_frames * sink_get_frame_bytes(out)) + if (sink_get_free_size(out) < cd->num_frames * cd->out_frame_bytes) return false; return true;