@@ -79,6 +79,8 @@ struct mixin_data {
7979#if CONFIG_XRUN_NOTIFICATIONS_ENABLE
8080 uint32_t last_reported_underrun ;
8181 uint32_t underrun_notification_period ;
82+ uint32_t eos_delay_periods ;
83+ bool eos_delay_configured ;
8284#endif
8385};
8486
@@ -248,23 +250,40 @@ static void silence(struct cir_buf_ptr *stream, uint32_t start_offset,
248250
249251#if CONFIG_XRUN_NOTIFICATIONS_ENABLE
250252static void mixin_check_notify_underrun (struct comp_dev * dev , struct mixin_data * mixin_data ,
253+ enum sof_audio_buffer_state state ,
251254 size_t source_avail , size_t sinks_free )
252255{
256+ const bool eos_detected = state == AUDIOBUF_STATE_END_OF_STREAM_FLUSH ||
257+ state == AUDIOBUF_STATE_END_OF_STREAM ;
258+
253259 struct ipc_msg * notify ;
254260
255261 mixin_data -> last_reported_underrun ++ ;
256262
257- if (!source_avail && mixin_data -> last_reported_underrun >=
258- mixin_data -> underrun_notification_period ) {
259- mixin_data -> last_reported_underrun = 0 ;
263+ if (!source_avail || eos_detected ) {
264+ if (eos_detected ) {
265+ if (mixin_data -> eos_delay_configured ) {
266+ mixin_data -> eos_delay_periods -- ;
267+ } else {
268+ pipeline_get_dai_comp_latency (dev -> pipeline -> pipeline_id ,
269+ & mixin_data -> eos_delay_periods );
270+ mixin_data -> eos_delay_configured = true;
271+ }
272+ }
273+
274+ if ((!eos_detected && mixin_data -> last_reported_underrun >=
275+ mixin_data -> underrun_notification_period ) ||
276+ (eos_detected && mixin_data -> eos_delay_periods == 0 )) {
277+ mixin_data -> last_reported_underrun = 0 ;
260278
261- notify = ipc_notification_pool_get (IPC4_RESOURCE_EVENT_SIZE );
262- if (!notify )
263- return ;
279+ notify = ipc_notification_pool_get (IPC4_RESOURCE_EVENT_SIZE );
280+ if (!notify )
281+ return ;
264282
265- mixer_underrun_notif_msg_init (notify , dev -> ipc_config .id , false,
266- source_avail , sinks_free );
267- ipc_msg_send (notify , notify -> tx_data , false);
283+ mixer_underrun_notif_msg_init (notify , dev -> ipc_config .id , eos_detected ,
284+ source_avail , sinks_free );
285+ ipc_msg_send (notify , notify -> tx_data , false);
286+ }
268287 }
269288}
270289#endif
@@ -294,9 +313,10 @@ static int mixin_process(struct processing_module *mod,
294313 uint32_t source_avail_frames , sinks_free_frames ;
295314 struct processing_module * active_mixouts [MIXIN_MAX_SINKS ];
296315 uint16_t sinks_ids [MIXIN_MAX_SINKS ];
316+ struct pending_frames * pending_frames ;
297317 uint32_t bytes_to_consume = 0 ;
298318 uint32_t frames_to_copy ;
299- struct pending_frames * pending_frames ;
319+ size_t frame_bytes ;
300320 int i , ret ;
301321 struct cir_buf_ptr source_ptr ;
302322
@@ -389,10 +409,10 @@ static int mixin_process(struct processing_module *mod,
389409 return 0 ;
390410
391411#if CONFIG_XRUN_NOTIFICATIONS_ENABLE
392- size_t frame_bytes = source_get_frame_bytes (sources [0 ]);
393- size_t min_frames = MIN (dev -> frames , sinks_free_frames );
412+ frame_bytes = source_get_frame_bytes (sources [0 ]);
413+ const size_t min_frames = MIN (dev -> frames , sinks_free_frames );
394414
395- mixin_check_notify_underrun (dev , mixin_data ,
415+ mixin_check_notify_underrun (dev , mixin_data , source_get_state ( sources [ 0 ]),
396416 source_avail_frames * frame_bytes ,
397417 min_frames * frame_bytes );
398418#endif
@@ -461,7 +481,7 @@ static int mixin_process(struct processing_module *mod,
461481 * silence instead of that source data
462482 */
463483 if (source_avail_frames == 0 ) {
464- uint32_t frame_bytes = sink_get_frame_bytes (mixout_mod -> sinks [0 ]);
484+ frame_bytes = sink_get_frame_bytes (mixout_mod -> sinks [0 ]);
465485
466486 /* generate silence */
467487 silence (& mixout_data -> acquired_buf , start_frame * frame_bytes ,
@@ -698,6 +718,7 @@ static int mixin_prepare(struct processing_module *mod,
698718 int ret ;
699719
700720 comp_info (dev , "mixin_prepare()" );
721+ md -> eos_delay_configured = false;
701722
702723 ret = mixin_params (mod );
703724 if (ret < 0 )
0 commit comments