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

How to resume a element if its state turned into FINISHED? (AUD-5434) #1206

Closed
Oreobird opened this issue May 28, 2024 · 1 comment
Closed

Comments

@Oreobird
Copy link

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; }

@github-actions github-actions bot 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
@Oreobird
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant