33// Copyright(c) 2025 Intel Corporation. All rights reserved.
44
55#include <sof/audio/module_adapter/module/generic.h>
6- #include <sof/audio/buffer.h>
76#include <sof/audio/component.h>
7+ #include <sof/audio/sink_api.h>
8+ #include <sof/audio/source_api.h>
89#include <sof/audio/data_blob.h>
910#include <sof/audio/format.h>
1011#include <sof/audio/ipc-config.h>
@@ -174,16 +175,15 @@ int8_t expected_feature_yes[TFLM_FEATURE_SIZE] = {
174175 */
175176
176177static int tflm_process (struct processing_module * mod ,
177- struct input_stream_buffer * input_buffers ,
178- int num_input_buffers ,
179- struct output_stream_buffer * output_buffers ,
180- int num_output_buffers )
178+ struct sof_source * * sources , int num_of_sources ,
179+ struct sof_sink * * sinks , int num_of_sinks )
181180{
182181 struct tflm_comp_data * cd = module_get_private_data (mod );
183182 struct comp_dev * dev = mod -> dev ;
184- struct audio_stream * source = input_buffers [0 ].data ;
185- struct audio_stream * sink = output_buffers [0 ].data ;
186- int features = input_buffers [0 ].size ;
183+ size_t frame_bytes = source_get_frame_bytes (sources [0 ]);
184+ int features = source_get_data_frames_available (sources [0 ]);
185+ const void * data_ptr , * buf_start ;
186+ size_t buf_size ;
187187 int ret ;
188188
189189 comp_dbg (dev , "entry" );
@@ -192,12 +192,18 @@ static int tflm_process(struct processing_module *mod,
192192 * by TFLM_FEATURE_SIZE until buffer empty.
193193 */
194194 while (features >= TFLM_FEATURE_ELEM_COUNT ) {
195- cd -> tfc .audio_features = source -> r_ptr ;
195+ ret = source_get_data (sources [0 ], TFLM_FEATURE_ELEM_COUNT * frame_bytes ,
196+ & data_ptr , & buf_start , & buf_size );
197+ if (ret )
198+ return ret ;
199+
200+ cd -> tfc .audio_features = data_ptr ;
196201 cd -> tfc .audio_data_size = TFLM_FEATURE_ELEM_COUNT ;
197202 ret = TF_ProcessClassify (& cd -> tfc );
198203 if (!ret ) {
199204 comp_err (dev , "classify failed %s." ,
200205 cd -> tfc .error );
206+ source_release_data (sources [0 ], 0 );
201207 return ret ;
202208 }
203209
@@ -207,10 +213,9 @@ static int tflm_process(struct processing_module *mod,
207213 cd -> tfc .predictions [i ], prediction [i ]);
208214 }
209215
210- /* calc new free and available after moving onto next feature */
211- module_update_buffer_position (& input_buffers [0 ],
212- & output_buffers [0 ], TFLM_FEATURE_SIZE );
213- features = input_buffers [0 ].size ;
216+ /* advance by one stride */
217+ source_release_data (sources [0 ], TFLM_FEATURE_SIZE * frame_bytes );
218+ features = source_get_data_frames_available (sources [0 ]);
214219 }
215220
216221 return ret ;
@@ -226,7 +231,7 @@ static int tflm_reset(struct processing_module *mod)
226231static const struct module_interface tflmcly_interface = {
227232 .init = tflm_init ,
228233// .prepare = tflm_prepare,
229- .process_audio_stream = tflm_process ,
234+ .process = tflm_process ,
230235 .set_configuration = tflm_set_config ,
231236// .get_configuration = tflm_get_config,
232237 .reset = tflm_reset ,
0 commit comments