Component should ignore repeated requests to set the same state and return with a value >0 so the state doesn't get propagated further down the pipeline.
Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- src/audio/component.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/src/audio/component.c b/src/audio/component.c index 319b401..8f8ddde 100644 --- a/src/audio/component.c +++ b/src/audio/component.c @@ -122,6 +122,15 @@ int comp_set_state(struct comp_dev *dev, int cmd)
switch (cmd) { case COMP_TRIGGER_START: + + /* + * No state change. + * Return a value >0 so the state won't be propagated further + */ + if (dev->state == COMP_STATE_ACTIVE) + return 1; + + /* Set new state */ if (dev->state == COMP_STATE_PREPARE || dev->state == COMP_STATE_PAUSED) { dev->state = COMP_STATE_ACTIVE; @@ -132,6 +141,7 @@ int comp_set_state(struct comp_dev *dev, int cmd) } break; case COMP_TRIGGER_RELEASE: + if (dev->state == COMP_STATE_PAUSED) { dev->state = COMP_STATE_ACTIVE; } else { @@ -142,6 +152,15 @@ int comp_set_state(struct comp_dev *dev, int cmd) break; case COMP_TRIGGER_STOP: case COMP_TRIGGER_XRUN: + + /* + * No state change. + * Return a value >0 so the state won't be propagated further + */ + if (dev->state == COMP_STATE_PREPARE) + return 1; + + /* set new state */ if (dev->state == COMP_STATE_ACTIVE) { dev->state = COMP_STATE_PREPARE; } else {