Skip to content

Commit e1e5fd0

Browse files
lyakhkv2019i
authored andcommitted
pipeline: handle failed latency calculation
copier_comp_trigger() calls pipeline_get_dai_comp_latency() for playback pipelines to obtain the pipeline DAI copier, if there is one, and to calculate the pipeline latency. The latency is calculated using the .get_total_data_processed() component operation, but that operation is only available for DAI, host and copier components. SOF pipelines often have other components at one of the pipeline ends, so the latency calculation fails. However, that shouldn't prevent pipeline_get_dai_comp_latency() from finding the DAI component. This fixes the notorious "failed to find dai comp or sink pipeline not running." error message. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 85367b7 commit e1e5fd0

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/audio/copier/copier.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ static int create_ipcgtw(struct comp_dev *parent_dev, struct copier_data *cd,
551551
}
552552
#endif
553553

554+
/* Playback only */
554555
static int init_pipeline_reg(struct comp_dev *dev)
555556
{
556557
struct copier_data *cd = comp_get_drvdata(dev);
@@ -985,6 +986,7 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd)
985986
}
986987
}
987988

989+
/* For capture cd->pipeline_reg_offset == 0 */
988990
if (ret < 0 || !cd->endpoint_num || !cd->pipeline_reg_offset)
989991
return ret;
990992

src/audio/pipeline/pipeline-graph.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ struct comp_dev *pipeline_get_dai_comp(uint32_t pipeline_id, int dir)
486486
}
487487

488488
#if CONFIG_IPC_MAJOR_4
489-
/* visit connected pipeline to find the dai comp and latency.
489+
/* Playback only: visit connected pipeline to find the dai comp and latency.
490490
* This function walks down through a pipelines chain looking for the target dai component.
491491
* Calculates the delay of each pipeline by determining the number of buffered blocks.
492492
*/
@@ -521,8 +521,6 @@ struct comp_dev *pipeline_get_dai_comp_latency(uint32_t pipeline_id, uint32_t *l
521521
/* Calculate pipeline latency */
522522
input_data = comp_get_total_data_processed(source, 0, true);
523523
output_data = comp_get_total_data_processed(ipc_sink->cd, 0, false);
524-
if (!input_data || !output_data)
525-
return NULL;
526524

527525
ret = comp_get_attribute(source, COMP_ATTR_BASE_CONFIG, &input_base_cfg);
528526
if (ret < 0)
@@ -532,19 +530,21 @@ struct comp_dev *pipeline_get_dai_comp_latency(uint32_t pipeline_id, uint32_t *l
532530
if (ret < 0)
533531
return NULL;
534532

535-
*latency += input_data / input_base_cfg.ibs - output_data / output_base_cfg.obs;
533+
if (input_data && output_data)
534+
*latency += input_data / input_base_cfg.ibs -
535+
output_data / output_base_cfg.obs;
536536

537-
/* If the component doesn't have a sink buffer, this is a dai. */
537+
/* If the component doesn't have a sink buffer, it can be a dai. */
538538
if (list_is_empty(&ipc_sink->cd->bsink_list))
539-
return ipc_sink->cd;
539+
return dev_comp_type(ipc_sink->cd) == SOF_COMP_DAI ? ipc_sink->cd : NULL;
540540

541541
/* Get a component connected to our sink buffer - hop to a next pipeline */
542542
buffer = buffer_from_list(comp_buffer_list(ipc_sink->cd, PPL_DIR_DOWNSTREAM)->next,
543543
PPL_DIR_DOWNSTREAM);
544544
source = buffer_get_comp(buffer, PPL_DIR_DOWNSTREAM);
545545

546546
/* buffer_comp is in another pipeline and it is not complete */
547-
if (!source->pipeline)
547+
if (!source || !source->pipeline)
548548
return NULL;
549549

550550
/* Get a next sink component */

0 commit comments

Comments
 (0)