Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i2s_stream: do not unconditionally install I2S driver (AUD-5119) #1130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 6 additions & 4 deletions components/audio_stream/i2s_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,12 @@ audio_element_handle_t i2s_stream_init(i2s_stream_cfg_t *config)
cfg.write = _i2s_write;
}

esp_err_t ret = i2s_driver_install(i2s->config.i2s_port, &i2s->config.i2s_config, 0, NULL);
if (ret != ESP_OK && ret != ESP_ERR_INVALID_STATE) {
audio_free(i2s);
return NULL;
if (config->install_drv) {
esp_err_t ret = i2s_driver_install(i2s->config.i2s_port, &i2s->config.i2s_config, 0, NULL);
if (ret != ESP_OK && ret != ESP_ERR_INVALID_STATE) {
audio_free(i2s);
return NULL;
}
}
i2s_stream_check_data_bits(i2s, i2s->config.i2s_config.bits_per_sample);

Expand Down
7 changes: 7 additions & 0 deletions components/audio_stream/include/i2s_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ typedef struct {
int task_prio; /*!< Task priority (based on freeRTOS priority) */
bool stack_in_ext; /*!< Try to allocate stack in external memory */
int multi_out_num; /*!< The number of multiple output */
bool install_drv; /*!< whether to install the i2s driver when initializing stream*/
bool uninstall_drv; /*!< whether uninstall the i2s driver when stream destroyed*/
bool need_expand; /*!< whether to expand i2s data */
i2s_bits_per_sample_t expand_src_bits; /*!< The source bits per sample when data expand */
Expand Down Expand Up @@ -87,6 +88,7 @@ typedef struct {
.task_prio = I2S_STREAM_TASK_PRIO, \
.stack_in_ext = false, \
.multi_out_num = 0, \
.install_drv = true, \
.uninstall_drv = true, \
.need_expand = false, \
.expand_src_bits = I2S_BITS_PER_SAMPLE_16BIT, \
Expand Down Expand Up @@ -117,6 +119,7 @@ typedef struct {
.task_prio = I2S_STREAM_TASK_PRIO, \
.stack_in_ext = false, \
.multi_out_num = 0, \
.install_drv = true, \
.uninstall_drv = false, \
.need_expand = false, \
.expand_src_bits = I2S_BITS_PER_SAMPLE_16BIT, \
Expand Down Expand Up @@ -145,6 +148,7 @@ typedef struct {
.task_prio = I2S_STREAM_TASK_PRIO, \
.stack_in_ext = false, \
.multi_out_num = 0, \
.install_drv = true, \
.uninstall_drv = false, \
.need_expand = false, \
.expand_src_bits = I2S_BITS_PER_SAMPLE_16BIT, \
Expand Down Expand Up @@ -174,6 +178,7 @@ typedef struct {
.task_prio = I2S_STREAM_TASK_PRIO, \
.stack_in_ext = false, \
.multi_out_num = 0, \
.install_drv = true, \
.uninstall_drv = true, \
.need_expand = false, \
.expand_src_bits = I2S_BITS_PER_SAMPLE_16BIT, \
Expand Down Expand Up @@ -204,6 +209,7 @@ typedef struct {
.task_prio = I2S_STREAM_TASK_PRIO, \
.stack_in_ext = false, \
.multi_out_num = 0, \
.install_drv = true, \
.uninstall_drv = false, \
.need_expand = false, \
.expand_src_bits = I2S_BITS_PER_SAMPLE_16BIT, \
Expand Down Expand Up @@ -232,6 +238,7 @@ typedef struct {
.task_prio = I2S_STREAM_TASK_PRIO, \
.stack_in_ext = false, \
.multi_out_num = 0, \
.install_drv = true, \
.uninstall_drv = false, \
.need_expand = false, \
.expand_src_bits = I2S_BITS_PER_SAMPLE_16BIT, \
Expand Down