Skip to content

Commit

Permalink
google_rtc_audio_processing: Guard buffer pointer following
Browse files Browse the repository at this point in the history
It seems like in IPC4 SOF will dynamically tear down streams not in
use, such that the stream pointer field of a comp_buffer object will
become null when and existing playback stream ends (which is oddly
asymmetric, given that the topology/kernel itself will otherwise try
to artificially START the reference stream for the benefit of AEC).
In IPC3, the topology seems static and those pointers never change.

Add an extra test for safety.  It's cheap.

Signed-off-by: Andy Ross <[email protected]>
  • Loading branch information
andyross committed Dec 13, 2023
1 parent 32596c0 commit 6026501
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/audio/google/google_rtc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,12 @@ static void mic_out_copy(struct sof_sink *sink, int frames, float **src_bufs)
sink_commit_buffer(sink, bytes);
}

static bool ref_stream_active(struct google_rtc_audio_processing_comp_data *cd)
{
return cd->ref_comp_buffer->source &&
cd->ref_comp_buffer->source->state == COMP_STATE_ACTIVE;
}

static int mod_process(struct processing_module *mod, struct sof_source **sources,
int num_of_sources, struct sof_sink **sinks, int num_of_sinks)
{
Expand All @@ -768,8 +774,7 @@ static int mod_process(struct processing_module *mod, struct sof_source **source
struct sof_source *mic = sources[cd->raw_microphone_source];
struct sof_source *ref = sources[cd->aec_reference_source];
struct sof_sink *out = sinks[0];

bool ref_ok = cd->ref_comp_buffer->source->state == COMP_STATE_ACTIVE;
bool ref_ok = ref_stream_active(cd);

/* Would be cleaner to store a bit of state to elide a bzero
* we already did, but we'd be doing the copy of real data in
Expand Down Expand Up @@ -819,7 +824,7 @@ static bool mod_is_ready_to_process(struct processing_module *mod,
struct sof_source *mic = sources[cd->raw_microphone_source];
struct sof_source *ref = sources[cd->aec_reference_source];
struct sof_sink *out = sinks[0];
bool ref_ok = cd->ref_comp_buffer->source->state == COMP_STATE_ACTIVE;
bool ref_ok = ref_stream_active(cd);

/* this should source_get_min_available(ref_stream)!!!
* Currently the topology sets IBS incorrectly
Expand Down

0 comments on commit 6026501

Please sign in to comment.