Skip to content

Commit

Permalink
google_aec: Sparse fixups
Browse files Browse the repository at this point in the history
Commit 0eb34db ("google_aec: Don't allocate giant blobs on the
heap") dropped some sparse annotations and exposed warnings with
dealing with the cached temporary buffers handed to the AEC code.

Unfortunately the underlying API isn't sparse-aware, so rather than go
through the trouble to keep the tags consistent through the new
conversion API (which is a little non-trivial syntactically) just to
throw it away on entry to the library, force it off at conversion time
for simplicity.  Essentially now it's checking that all computation in
this module is "uncached", which is fine as long as we don't try to
mix conventions.

Signed-off-by: Andy Ross <andyross@google.com>
  • Loading branch information
andyross authored and kv2019i committed Jul 4, 2024
1 parent 2688f63 commit 0a39bb5
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/audio/google/google_rtc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ struct google_rtc_audio_processing_comp_data {
void (*out_copy)(struct sof_sink *dst, int frames, float **src_bufs);
};

/* The underlying API is not sparse-aware, so rather than try to
* finesse the conversions everywhere the buffers touch, turn checking
* off when we computed the cached address
*/
static void *cached_ptr(void *p)
{
return (__sparse_force void *) sys_cache_cached_ptr_get(p);
}

void *GoogleRtcMalloc(size_t size)
{
return rballoc(0, SOF_MEM_CAPS_RAM, size);
Expand Down Expand Up @@ -526,7 +535,7 @@ static int google_rtc_audio_processing_init(struct processing_module *mod)
cd->num_frames = NUM_FRAMES;

/* Giant blob of scratch memory. */
GoogleRtcAudioProcessingAttachMemoryBuffer(sys_cache_cached_ptr_get(&aec_mem_blob[0]),
GoogleRtcAudioProcessingAttachMemoryBuffer(cached_ptr(&aec_mem_blob[0]),
sizeof(aec_mem_blob));

cd->state = GoogleRtcAudioProcessingCreateWithConfig(CONFIG_COMP_GOOGLE_RTC_AUDIO_PROCESSING_SAMPLE_RATE_HZ,
Expand Down Expand Up @@ -554,8 +563,8 @@ static int google_rtc_audio_processing_init(struct processing_module *mod)
}

for (i = 0; i < CHAN_MAX; i++) {
cd->raw_mic_buffers[i] = sys_cache_cached_ptr_get(&micbuf[i][0]);
cd->refout_buffers[i] = sys_cache_cached_ptr_get(&refoutbuf[i][0]);
cd->raw_mic_buffers[i] = cached_ptr(&micbuf[i][0]);
cd->refout_buffers[i] = cached_ptr(&refoutbuf[i][0]);
}

cd->buffered_frames = 0;
Expand Down Expand Up @@ -804,7 +813,7 @@ static int mod_process(struct processing_module *mod, struct sof_source **source

/* Clear the buffer if the reference pipeline shuts off */
if (!ref_ok && cd->last_ref_ok)
bzero(sys_cache_cached_ptr_get(refoutbuf), sizeof(refoutbuf));
bzero(cached_ptr(refoutbuf), sizeof(refoutbuf));

int fmic = source_get_data_frames_available(mic);
int fref = source_get_data_frames_available(ref);
Expand Down

0 comments on commit 0a39bb5

Please sign in to comment.