Skip to content

Commit 1e6d473

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 57bb540 commit 1e6d473

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/include/module/audio/audio_stream.h

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

16+
enum sof_audio_stream_state {
17+
STREAM_STATE_INITIAL, /* Initial state, hw params not configured. */
18+
STREAM_STATE_READY /* Stream ready, hw params configured */
19+
};
20+
1621
/**
1722
* set of parameters describing audio stream
1823
* this structure is shared between audio_stream.h and sink/source interface
@@ -53,7 +58,7 @@ struct sof_audio_stream_params {
5358

5459
uint16_t chmap[SOF_IPC_MAX_CHANNELS]; /**< channel map - SOF_CHMAP_ */
5560

56-
bool hw_params_configured; /**< indicates whether hw params were set */
61+
enum sof_audio_stream_state state; /**< stream state */
5762
};
5863

5964
#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 != STREAM_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 = STREAM_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 = STREAM_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)