Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
google_rtc_audio_processing: Work around IPC4 stream setup issues
IPC4 fails to set up stream metadata on the buffer objects at pipeline creation time (see Issue thesofproject#8639). Traditionally components have been responsible for doing this. The way this works here is that during the init() call, we cache the relevant ipc4_audio_format records from the module "extended config" (which is untyped byte-packed data, I think it's raw bytes from the host?) that correspond to our connected streams. This config struct gets freed after initialization, so it has to be done then. Then at prepare time, we must use ipc4_update_source/sink_format() to set values on the (incompletely initialized) streams. Similarly, we have to call audio_stream_init_alignment_constants(), otherwise needed values on the audio stream remain uninitialized. It's not really documented what happens if our settings disagree with the component on the other side of the buffer! Presumably that would be a fatal topology bug, but nothing is set up to detect it. In fact in practice most other components DON'T do this, so our settings win (and thus we must do this, or else the rest of the stream sees garbage and misbehaves, generally with buffer overruns or short reads). Finally, there is somewhat... unique handling needed to get correct IBS/OBS buffer sizing. We have two inputs with different stream formats, and thus different minimum block sizes. The "base" module config only has space for one IBS value. So the pipeline code has an "extended" config with separate IBS per pin, but it will only use it if it knows about it, which it doesn't by default because module initialization throws away the data! So it falls to us to duplicate a copy and store it ourselves, in a separate field from where we found it. Also ntoe: The "pin" index (the value of the pin_index field of the ipc4_in/output_pin_format structs seen in module config at init() time) and the "source" index (the ordering of the sources[] argument to prepare()/process()) ARE PRESENTED BACKWARDS! And I don't see any API to tell me which is which (note that the ordering of the connected buffers in the comp_dev sink/source lists is a THIRD convention, and matches sources[]/sinks[]). Signed-off-by: Andy Ross <[email protected]>
- Loading branch information