Skip to content

Commit e58abfa

Browse files
committed
pipeline: move End Of Stream to component
DP components cannot access pipeline objects. Move the End Of Stream flag to the component type. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 2a92f66 commit e58abfa

9 files changed

Lines changed: 50 additions & 10 deletions

File tree

src/audio/component.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ static bool comp_check_eos(struct comp_dev *dev)
506506
enum sof_audio_buffer_state sink_state = AUDIOBUF_STATE_INITIAL;
507507
struct comp_buffer *buffer;
508508

509-
if (!dev->pipeline->expect_eos)
509+
if (!dev->expect_eos)
510510
return false;
511511

512512
comp_dev_for_each_producer(dev, buffer) {

src/audio/host-zephyr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static inline bool host_handle_eos(struct host_data *hd, struct comp_dev *dev,
396396
struct sof_audio_buffer *buffer = &hd->local_buffer->audio_buffer;
397397
enum sof_audio_buffer_state state = audio_buffer_get_state(buffer);
398398

399-
if (!dev->pipeline->expect_eos)
399+
if (!dev->expect_eos)
400400
return false;
401401

402402
if (!avail_samples) {

src/audio/module_adapter/module/cadence.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ int cadence_codec_process_data(struct processing_module *mod,
541541
return 0;
542542
}
543543

544-
if (dev->pipeline->expect_eos) {
544+
if (dev->expect_eos) {
545545
/* Signal that the stream is expected to end anytime soon */
546546
API_CALL(cd, XA_API_CMD_INPUT_OVER, 0, NULL, ret);
547547
if (ret != LIB_NO_ERROR) {
@@ -596,7 +596,7 @@ int cadence_codec_process_data(struct processing_module *mod,
596596
return ret;
597597
}
598598

599-
if (dev->pipeline->expect_eos) {
599+
if (dev->expect_eos) {
600600
/*
601601
* AAC decoder cannot signal DONE, check if it stopped
602602
* producing data when EOS is expected

src/audio/pipeline/pipeline-graph.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,39 @@ int pipeline_free(struct pipeline *p)
344344
return 0;
345345
}
346346

347+
static int pipeline_comp_set_eos(struct comp_dev *current,
348+
struct comp_buffer *calling_buf,
349+
struct pipeline_walk_context *ctx, int dir)
350+
{
351+
if (ctx->comp_data != (void *)current->pipeline)
352+
return 0;
353+
354+
current->expect_eos = *(bool *)ctx->buff_data;
355+
356+
return pipeline_for_each_comp(current, ctx, dir);
357+
}
358+
359+
void pipeline_set_eos(struct pipeline *p, bool eos)
360+
{
361+
struct pipeline_walk_context walk_ctx = {
362+
.comp_func = pipeline_comp_set_eos,
363+
.comp_data = p,
364+
.buff_data = &eos,
365+
};
366+
struct comp_dev *start;
367+
int dir;
368+
369+
if (p->source_comp->direction == SOF_IPC_STREAM_PLAYBACK) {
370+
dir = PPL_DIR_UPSTREAM;
371+
start = p->sink_comp;
372+
} else {
373+
dir = PPL_DIR_DOWNSTREAM;
374+
start = p->source_comp;
375+
}
376+
377+
walk_ctx.comp_func(start, NULL, &walk_ctx, dir);
378+
}
379+
347380
static int pipeline_comp_complete(struct comp_dev *current,
348381
struct comp_buffer *calling_buf,
349382
struct pipeline_walk_context *ctx, int dir)

src/include/sof/audio/component.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ struct comp_dev {
647647
/* runtime */
648648
uint16_t state; /**< COMP_STATE_ */
649649
uint32_t frames; /**< number of frames we copy to sink */
650+
bool expect_eos; /**< end of stream expected */
650651
struct pipeline *pipeline; /**< pipeline we belong to */
651652

652653
struct task *task; /**< component's processing task used

src/include/sof/audio/pipeline.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ struct pipeline {
7070
int32_t xrun_bytes; /* last xrun length */
7171
uint32_t status; /* pipeline status */
7272
struct tr_ctx tctx; /* trace settings */
73-
bool expect_eos; /* pipeline is expecting end of stream */
7473

7574
/* scheduling */
7675
#ifdef CONFIG_IPC_MAJOR_4
@@ -225,6 +224,13 @@ void pipeline_posn_grant_access(struct k_thread *thread);
225224
*/
226225
int pipeline_reset(struct pipeline *p, struct comp_dev *host_cd);
227226

227+
/**
228+
* \brief Sets End Of Stream state for all devices in the pipeline.
229+
* \param[in] p pipeline.
230+
* \param[in] eos End Of Stream state.
231+
*/
232+
void pipeline_set_eos(struct pipeline *p, bool eos);
233+
228234
/**
229235
* \brief Walks the pipeline graph for each component.
230236
* \param[in] current Current pipeline component.

src/ipc/ipc4/handler-user.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd)
256256

257257
switch (cmd) {
258258
case SOF_IPC4_PIPELINE_STATE_RUNNING:
259-
if (ppl_icd->pipeline->expect_eos) {
259+
if (ppl_icd->pipeline->source_comp && ppl_icd->pipeline->source_comp->expect_eos) {
260260
ipc_cmd_err(&ipc_tr, "pipeline %d: Can't transition from EOS to RUNNING",
261261
ppl_icd->id);
262262
return IPC4_INVALID_REQUEST;
@@ -320,7 +320,7 @@ int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd)
320320
ppl_icd->id, status);
321321
return IPC4_INVALID_REQUEST;
322322
}
323-
ppl_icd->pipeline->expect_eos = true;
323+
pipeline_set_eos(ppl_icd->pipeline, true);
324324
return 0; /* Must return here. Any other transition clears expect_eos. */
325325
/* special case - TODO */
326326
case SOF_IPC4_PIPELINE_STATE_SAVED:
@@ -334,7 +334,7 @@ int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd)
334334
if (ret < 0)
335335
return IPC4_INVALID_REQUEST;
336336

337-
ppl_icd->pipeline->expect_eos = false;
337+
pipeline_set_eos(ppl_icd->pipeline, false);
338338

339339
return ret;
340340
}

test/cmocka/src/audio/mux/demux_copy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static int setup_test_case(void **state)
169169
dummy_pipe = test_malloc(sizeof(*dummy_pipe));
170170
if (!dummy_pipe)
171171
return -ENOMEM;
172-
dummy_pipe->expect_eos = false;
172+
dev->expect_eos = false;
173173
dev->pipeline = dummy_pipe;
174174

175175
mod = comp_mod(dev);

test/cmocka/src/audio/mux/mux_copy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static int setup_test_case(void **state)
191191
dummy_pipe = test_malloc(sizeof(*dummy_pipe));
192192
if (!dummy_pipe)
193193
return -ENOMEM;
194-
dummy_pipe->expect_eos = false;
194+
dev->expect_eos = false;
195195
dev->pipeline = dummy_pipe;
196196

197197
mod = comp_mod(dev);

0 commit comments

Comments
 (0)