Skip to content

Commit 9e4d5e4

Browse files
committed
audio: stream: Introduce audio stream state
Add enum describing the state of a audio stream. Change the hw_params_configured field to state. A stream is initially in the STREAM_STATE_INITIAL state. After configuring the parameters, it transitions to the STREAM_STATE_READY state. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent ed6c0f1 commit 9e4d5e4

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

src/include/module/audio/audio_stream.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@
1313
#include <stdbool.h>
1414
#include "../ipc/stream.h"
1515

16+
17+
/**
18+
* @enum sof_audio_buffer_state
19+
* @brief Define states of an audio stream buffer connecting two components.
20+
*
21+
* This enum represents the lifecycle of an audio stream, including its
22+
* initialization, readiness, and end-of-stream handling. It is used to
23+
* track and manage the state transitions of the stream during audio processing.
24+
*/
25+
enum sof_audio_buffer_state {
26+
AUDIOBUF_STATE_INITIAL, /* Initial state, hw params not configured. */
27+
AUDIOBUF_STATE_READY, /* Stream ready, hw params configured */
28+
};
29+
1630
/**
1731
* set of parameters describing audio stream
1832
* this structure is shared between audio_stream.h and sink/source interface
@@ -53,7 +67,7 @@ struct sof_audio_stream_params {
5367

5468
uint16_t chmap[SOF_IPC_MAX_CHANNELS]; /**< channel map - SOF_CHMAP_ */
5569

56-
bool hw_params_configured; /**< indicates whether hw params were set */
70+
enum sof_audio_buffer_state state; /**< audio stream state */
5771
};
5872

5973
#endif /* __MODULE_AUDIO_AUDIO_STREAM_H__ */

src/include/sof/audio/audio_buffer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,17 @@ static inline bool audio_buffer_is_shared(struct sof_audio_buffer *buffer)
214214

215215
static inline bool audio_buffer_hw_params_configured(struct sof_audio_buffer *buffer)
216216
{
217-
return buffer->audio_stream_params->hw_params_configured;
217+
return buffer->audio_stream_params->state != AUDIOBUF_STATE_INITIAL;
218218
}
219219

220220
static inline void audio_buffer_set_hw_params_configured(struct sof_audio_buffer *buffer)
221221
{
222-
buffer->audio_stream_params->hw_params_configured = true;
222+
buffer->audio_stream_params->state = AUDIOBUF_STATE_READY;
223223
}
224224

225225
static inline void audio_buffer_reset_params(struct sof_audio_buffer *buffer)
226226
{
227-
buffer->audio_stream_params->hw_params_configured = false;
227+
buffer->audio_stream_params->state = AUDIOBUF_STATE_INITIAL;
228228
}
229229

230230
static inline uint16_t audio_buffer_get_chmap(struct sof_audio_buffer *buffer, size_t index)

0 commit comments

Comments
 (0)