1111#include <sof/audio/format.h>
1212#include <sof/audio/ipc-config.h>
1313#include <sof/audio/pipeline.h>
14+ #include <sof/audio/sink_source_utils.h>
1415#include <sof/ipc/msg.h>
1516#include <sof/lib/memory.h>
1617#include <sof/lib/uuid.h>
@@ -269,25 +270,30 @@ __cold static int drc_get_config(struct processing_module *mod,
269270}
270271
271272static int drc_process (struct processing_module * mod ,
272- struct input_stream_buffer * input_buffers ,
273- int num_input_buffers ,
274- struct output_stream_buffer * output_buffers ,
275- int num_output_buffers )
273+ struct sof_source * * sources ,
274+ int num_of_sources ,
275+ struct sof_sink * * sinks ,
276+ int num_of_sinks )
276277{
277278 struct drc_comp_data * cd = module_get_private_data (mod );
278279 struct comp_dev * dev = mod -> dev ;
279- struct audio_stream * source = input_buffers [0 ].data ;
280- struct audio_stream * sink = output_buffers [0 ].data ;
281- int frames = input_buffers [0 ].size ;
280+ struct sof_source * source = sources [0 ];
281+ struct sof_sink * sink = sinks [0 ];
282+ struct cir_buf_source source_buf ;
283+ struct cir_buf_sink sink_buf ;
284+ size_t source_frame_bytes = source_get_frame_bytes (source );
285+ size_t sink_frame_bytes = sink_get_frame_bytes (sink );
286+ size_t source_bytes , sink_bytes , bytes ;
287+ uint32_t frames ;
282288 int ret ;
283289
284290 comp_dbg (dev , "entry" );
285291
286292 /* Check for changed configuration */
287293 if (comp_is_new_data_blob_available (cd -> model_handler )) {
288294 cd -> config = comp_get_data_blob (cd -> model_handler , NULL , NULL );
289- ret = drc_setup (mod , audio_stream_get_channels (source ),
290- audio_stream_get_rate (source ));
295+ ret = drc_setup (mod , source_get_channels (source ),
296+ source_get_rate (source ));
291297 if (ret < 0 ) {
292298 comp_err (dev , "drc_copy(), failed DRC setup" );
293299 return ret ;
@@ -309,10 +315,32 @@ static int drc_process(struct processing_module *mod,
309315 /* Control pass-though in processing function with switch control */
310316 cd -> enabled = cd -> config && cd -> config -> params .enabled && cd -> enable_switch ;
311317
312- cd -> drc_func (mod , source , sink , frames );
318+ frames = source_sink_avail_frames_aligned (source , sink );
319+ if (!frames )
320+ return 0 ;
321+
322+ source_bytes = frames * source_frame_bytes ;
323+ sink_bytes = frames * sink_frame_bytes ;
324+
325+ /* acquire source and sink circular buffers for the whole period */
326+ ret = source_get_data (source , source_bytes , & source_buf .ptr ,
327+ & source_buf .buf_start , & bytes );
328+ if (ret < 0 )
329+ return ret ;
330+ source_buf .buf_end = (const char * )source_buf .buf_start + bytes ;
331+
332+ ret = sink_get_buffer (sink , sink_bytes , & sink_buf .ptr , & sink_buf .buf_start , & bytes );
333+ if (ret < 0 ) {
334+ source_release_data (source , 0 );
335+ return ret ;
336+ }
337+ sink_buf .buf_end = (char * )sink_buf .buf_start + bytes ;
338+
339+ cd -> drc_func (mod , & source_buf , & sink_buf , frames );
313340
314- /* calc new free and available */
315- module_update_buffer_position (& input_buffers [0 ], & output_buffers [0 ], frames );
341+ /* commit the consumed and produced data */
342+ source_release_data (source , source_bytes );
343+ sink_commit_buffer (sink , sink_bytes );
316344 return 0 ;
317345}
318346
@@ -367,6 +395,7 @@ static int drc_prepare(struct processing_module *mod,
367395 cd -> source_format = audio_stream_get_frm_fmt (& sourceb -> stream );
368396 channels = audio_stream_get_channels (& sinkb -> stream );
369397 rate = audio_stream_get_rate (& sinkb -> stream );
398+ cd -> channels = channels ;
370399
371400 /* Initialize DRC */
372401 comp_info (dev , "source_format=%d" , cd -> source_format );
@@ -414,7 +443,7 @@ static int drc_reset(struct processing_module *mod)
414443static const struct module_interface drc_interface = {
415444 .init = drc_init ,
416445 .prepare = drc_prepare ,
417- .process_audio_stream = drc_process ,
446+ .process = drc_process ,
418447 .set_configuration = drc_set_config ,
419448 .get_configuration = drc_get_config ,
420449 .reset = drc_reset ,
0 commit comments