AirPlay: no realloc, safe TCB cleanup, tools convergence

This commit is contained in:
Philippe G
2021-12-17 10:54:25 -08:00
parent a266c07114
commit 3b6299dc1a
14 changed files with 144 additions and 59 deletions

View File

@@ -255,7 +255,7 @@ void raop_delete(struct raop_ctx_s *ctx) {
// brute-force exit of accept()
shutdown(ctx->sock, SHUT_RDWR);
closesocket(ctx->sock);
closesocket(ctx->sock);
// wait to make sure LWIP if scheduled (avoid issue with NotifyTake)
vTaskDelay(100 / portTICK_PERIOD_MS);
@@ -525,15 +525,17 @@ static bool handle_rtsp(raop_ctx_t *ctx, int sock)
ctx->active_remote.destroy_mutex = xSemaphoreCreateBinary();
ctx->active_remote.xTaskBuffer = (StaticTask_t*) heap_caps_malloc(sizeof(StaticTask_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
ctx->active_remote.thread = xTaskCreateStatic( (TaskFunction_t) search_remote, "search_remote", SEARCH_STACK_SIZE, ctx, ESP_TASK_PRIO_MIN + 2, ctx->active_remote.xStack, ctx->active_remote.xTaskBuffer);
#endif
} else if (!strcmp(method, "SETUP") && ((buf = kd_lookup(headers, "Transport")) != NULL)) {
} else if (!strcmp(method, "SETUP") && ((buf = kd_lookup(headers, "Transport")) != NULL)) {
char *p;
rtp_resp_t rtp = { 0 };
short unsigned tport = 0, cport = 0;
uint8_t *buffer = NULL;
size_t size = 0;
// we are about to stream, do something if needed and optionally give buffers to play with
success = ctx->cmd_cb(RAOP_SETUP);
success = ctx->cmd_cb(RAOP_SETUP, &buffer, &size);
if ((p = strcasestr(buf, "timing_port")) != NULL) sscanf(p, "%*[^=]=%hu", &tport);
if ((p = strcasestr(buf, "control_port")) != NULL) sscanf(p, "%*[^=]=%hu", &cport);
@@ -672,9 +674,8 @@ void cleanup_rtsp(raop_ctx_t *ctx, bool abort) {
if (ctx->active_remote.running) {
#ifdef WIN32
pthread_join(ctx->active_remote.thread, NULL);
close_mDNS(ctx->active_remote.handle);
#else
#else
// need to make sure no search is on-going and reclaim task memory
// need to make sure no search is on-going and reclaim task memory
ctx->active_remote.running = false;
xSemaphoreTake(ctx->active_remote.destroy_mutex, portMAX_DELAY);