Give some love to AIrPlay/BT screens + better "safe TCB release" - release

This commit is contained in:
Philippe G
2021-12-18 15:20:22 -08:00
parent f872623785
commit 975f34f01b
9 changed files with 92 additions and 34 deletions

View File

@@ -18,6 +18,11 @@
#include "platform.h"
#include "pthread.h"
#ifndef WIN32
#include "freertos/FreeRTOS.h"
#include "freertos/timers.h"
#endif
#define NFREE(p) if (p) { free(p); p = NULL; }
typedef struct metadata_s {
@@ -46,19 +51,21 @@ char *strndup(const char *s, size_t n);
char *strndup(const char *s, size_t n);
int asprintf(char **strp, const char *fmt, ...);
void winsock_init(void);
void winsock_close(void);
void winsock_close(void);
#define SAFE_PTR_FREE(P) free(P)
#else
char *strlwr(char *str);
// reason is that TCB might be cleanup in idle task
#define SAFE_TCB_FREE(T) \
do { \
int priority = uxTaskPriorityGet(NULL); \
vTaskPrioritySet(NULL, tskIDLE_PRIORITY); \
vTaskDelay(1); \
vTaskPrioritySet(NULL, priority); \
#define SAFE_PTR_FREE(P) \
do { \
TimerHandle_t timer = xTimerCreate("cleanup", pdMS_TO_TICKS(5000), pdFALSE, P, _delayed_free); \
xTimerStart(timer, portMAX_DELAY); \
} while (0)
static void inline _delayed_free(TimerHandle_t xTimer) {
free(pvTimerGetTimerID(xTimer));
xTimerDelete(xTimer, portMAX_DELAY);
}
#endif
char* strextract(char *s1, char *beg, char *end);