Skip to content

Commit

Permalink
audio_stream: Fix uninitialized data in alignment_constants
Browse files Browse the repository at this point in the history
Audio stream objects are generally allocated out of zero'd heap
memory, but the computed alignment fields need non-zero values to have
correct behavior.  These were being left as garbage.

Set them to a byte and frame alignmnt of 1, as this corresponds to
pervasive convention in the tree.  But note that a byte alignment of 1
is actually technically incorrect, as all existing DSP targets are on
architectures which don't allow misaligned loads.  But existing
component code is universally coded correctly anyway.

(It's worth pointing out that "set_alignment_constants()" is now
exposed as an API call on abstracted source/sink objects.  But the
only current implementation is on audio_stream.  Future
implementations will need to correctly initialize themselves.)

This is a partial fix for Issue thesofproject#8639

Signed-off-by: Andy Ross <andyross@google.com>
  • Loading branch information
andyross committed Dec 23, 2023
1 parent d66ad57 commit d2b638f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/audio/audio_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ void audio_stream_init(struct audio_stream *audio_stream, void *buff_addr, uint3
audio_stream->addr = buff_addr;
audio_stream->end_addr = (char *)audio_stream->addr + size;

audio_stream_init_alignment_constants(1, 1, audio_stream);
source_init(audio_stream_get_source(audio_stream), &audio_stream_source_ops,
&audio_stream->runtime_stream_params);
sink_init(audio_stream_get_sink(audio_stream), &audio_stream_sink_ops,
Expand Down

0 comments on commit d2b638f

Please sign in to comment.