You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In audio_element_resume(),if its state is FINISHED,it only report a status to event iface. How to resume an element if its state turned into FINISHED? esp_err_t audio_element_resume(audio_element_handle_t el, float wait_for_rb_threshold, TickType_t timeout) { if (!el->task_run) { ESP_LOGW(TAG, "[%s] Element has not create when AUDIO_ELEMENT_RESUME", el->tag); return ESP_FAIL; } if (el->state == AEL_STATE_RUNNING) { audio_element_report_status(el, AEL_STATUS_STATE_RUNNING); ESP_LOGW(TAG, "[%s] RESUME: Element is already running, state:%d, task_run:%d, is_running:%d", el->tag, el->state, el->task_run, el->is_running); return ESP_OK; } if (el->task_stack <= 0) { el->is_running = true; audio_element_force_set_state(el, AEL_STATE_RUNNING); audio_element_report_status(el, AEL_STATUS_STATE_RUNNING); return ESP_OK; } if (el->state == AEL_STATE_ERROR) { ESP_LOGE(TAG, "[%s] RESUME: Element error, state:%d", el->tag, el->state); return ESP_FAIL; } if (el->state == AEL_STATE_FINISHED) { ESP_LOGW(TAG, "[%s] RESUME: Element has finished, state:%d", el->tag, el->state); audio_element_report_status(el, AEL_STATUS_STATE_FINISHED); return ESP_OK; } if (wait_for_rb_threshold > 1 || wait_for_rb_threshold < 0) { return ESP_FAIL; } int ret = ESP_OK; xEventGroupClearBits(el->state_event, RESUMED_BIT); if (audio_element_cmd_send(el, AEL_MSG_CMD_RESUME) == ESP_FAIL) { ESP_LOGW(TAG, "[%s] Send resume command failed", el->tag); return ESP_FAIL; } EventBits_t uxBits = xEventGroupWaitBits(el->state_event, RESUMED_BIT, false, true, timeout); if ((uxBits & RESUMED_BIT) != RESUMED_BIT) { ESP_LOGW(TAG, "[%s-%p] RESUME timeout", el->tag, el); ret = ESP_FAIL; } else { if (wait_for_rb_threshold != 0 && el->read_type == IO_TYPE_RB) { ret = audio_element_wait_for_buffer(el, rb_get_size(el->in.input_rb) * wait_for_rb_threshold, timeout); } } return ret; }
The text was updated successfully, but these errors were encountered:
github-actionsbot
changed the title
How to resume a element if its state turned into FINISHED?
How to resume a element if its state turned into FINISHED? (AUD-5434)
May 28, 2024
Hmm...need to reset state and then resume.
It is recommended that the API documentation be more detailed. If the use of a component's external API requires analyzing the source code for correct usage, then this is truly user-unfriendly.
In audio_element_resume(),if its state is FINISHED,it only report a status to event iface. How to resume an element if its state turned into FINISHED?
esp_err_t audio_element_resume(audio_element_handle_t el, float wait_for_rb_threshold, TickType_t timeout) { if (!el->task_run) { ESP_LOGW(TAG, "[%s] Element has not create when AUDIO_ELEMENT_RESUME", el->tag); return ESP_FAIL; } if (el->state == AEL_STATE_RUNNING) { audio_element_report_status(el, AEL_STATUS_STATE_RUNNING); ESP_LOGW(TAG, "[%s] RESUME: Element is already running, state:%d, task_run:%d, is_running:%d", el->tag, el->state, el->task_run, el->is_running); return ESP_OK; } if (el->task_stack <= 0) { el->is_running = true; audio_element_force_set_state(el, AEL_STATE_RUNNING); audio_element_report_status(el, AEL_STATUS_STATE_RUNNING); return ESP_OK; } if (el->state == AEL_STATE_ERROR) { ESP_LOGE(TAG, "[%s] RESUME: Element error, state:%d", el->tag, el->state); return ESP_FAIL; } if (el->state == AEL_STATE_FINISHED) { ESP_LOGW(TAG, "[%s] RESUME: Element has finished, state:%d", el->tag, el->state); audio_element_report_status(el, AEL_STATUS_STATE_FINISHED); return ESP_OK; } if (wait_for_rb_threshold > 1 || wait_for_rb_threshold < 0) { return ESP_FAIL; } int ret = ESP_OK; xEventGroupClearBits(el->state_event, RESUMED_BIT); if (audio_element_cmd_send(el, AEL_MSG_CMD_RESUME) == ESP_FAIL) { ESP_LOGW(TAG, "[%s] Send resume command failed", el->tag); return ESP_FAIL; } EventBits_t uxBits = xEventGroupWaitBits(el->state_event, RESUMED_BIT, false, true, timeout); if ((uxBits & RESUMED_BIT) != RESUMED_BIT) { ESP_LOGW(TAG, "[%s-%p] RESUME timeout", el->tag, el); ret = ESP_FAIL; } else { if (wait_for_rb_threshold != 0 && el->read_type == IO_TYPE_RB) { ret = audio_element_wait_for_buffer(el, rb_get_size(el->in.input_rb) * wait_for_rb_threshold, timeout); } } return ret; }
The text was updated successfully, but these errors were encountered: