Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions developer_guides/firmware/components/component-overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,10 @@ Entry called to create a new component device::
Handling the Component Device State
***********************************

Utility function ``comp_set_state()`` should be called a component code at
the beginning of its state transition to verify whether the trigger is valid
in the current state and set a new state accordingly to the state diagram.

.. uml:: images/comp-dev-states.pu
:caption: Component Device States

READY
This is an initial state of a component device once it is created.

PREPARE
Transition to this state is usually invoked internally by the component's
implementation of the ``prepare()`` handler.

ACTIVE, PAUSE
Transitions to these states is caused by external trigger passed to the
component's implementation of the ``trigger()`` handler.
Refer to ``comp_set_state()`` in :ref:`component-api` for details.

Implementing Component API (comp_ops)
*************************************
Expand Down
17 changes: 8 additions & 9 deletions developer_guides/firmware/components/images/comp-dev-states.pu
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
hide empty description
[*] -right-> READY : <b>comp_ops.new()</b>
[*] -right-> COMP_STATE_READY : <b>comp_ops.new()</b>

READY -right-> PREPARE : <b>prepare</b>
COMP_STATE_READY -right-> COMP_STATE_PREPARE : <b>COMP_TRIGGER_PREPARE</b>

PREPARE --> ACTIVE : <b>start</b>
PAUSED --> ACTIVE : start
COMP_STATE_PREPARE --> COMP_STATE_ACTIVE : <b>COMP_TRIGGER_START</b>

ACTIVE --> PREPARE : stop, xrun
PAUSED --> PREPARE : stop, xrun
COMP_STATE_ACTIVE --> COMP_STATE_PREPARE : COMP_TRIGGER_STOP, COMP_TRIGGER_XRUN
COMP_STATE_PAUSED --> COMP_STATE_PREPARE : COMP_TRIGGER_STOP, COMP_TRIGGER_XRUN

ACTIVE -> PAUSED : pause
COMP_STATE_ACTIVE -> COMP_STATE_PAUSED : COMP_TRIGGER_PAUSE

PAUSED --> ACTIVE : release
COMP_STATE_PAUSED --> COMP_STATE_ACTIVE : COMP_TRIGGER_RELEASE

PREPARE --> READY : reset
COMP_STATE_PREPARE --> COMP_STATE_READY : COMP_TRIGGER_RESET