mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-06 11:36:59 +03:00
terminate correctly statically created tasks
This commit is contained in:
@@ -185,9 +185,6 @@ struct raop_ctx_s *raop_create(struct in_addr host, char *name,
|
||||
#ifdef WIN32
|
||||
// seems that Windows snprintf does not add NULL char if actual size > max
|
||||
id[63] = '\0';
|
||||
ctx->svc = mdnsd_register_svc(ctx->svr, id, "_raop._tcp.local", ctx->port, NULL, (const char**) txt);
|
||||
pthread_create(&ctx->thread, NULL, &rtsp_thread, ctx);
|
||||
|
||||
ctx->svc = mdnsd_register_svc(ctx->svr, id, "_raop._tcp.local", ctx->port, NULL, (const char**) txt);
|
||||
pthread_create(&ctx->thread, NULL, &rtsp_thread, ctx);
|
||||
|
||||
@@ -221,6 +218,7 @@ void raop_delete(struct raop_ctx_s *ctx) {
|
||||
// wake-up thread by connecting socket, needed for freeBSD
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
getsockname(ctx->sock, (struct sockaddr *) &addr, &nlen);
|
||||
connect(sock, (struct sockaddr*) &addr, sizeof(addr));
|
||||
closesocket(sock);
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -369,7 +367,7 @@ static void *rtsp_thread(void *arg) {
|
||||
if (n > 0) res = handle_rtsp(ctx, sock);
|
||||
|
||||
if (n < 0 || !res) {
|
||||
closesocket(sock);
|
||||
closesocket(sock);
|
||||
LOG_INFO("RTSP close %u", sock);
|
||||
sock = -1;
|
||||
}
|
||||
|
||||
@@ -305,6 +305,7 @@ void rtp_end(rtp_t *ctx)
|
||||
ctx->running = false;
|
||||
#ifdef WIN32
|
||||
pthread_join(ctx->thread, NULL);
|
||||
#else
|
||||
xTaskNotifyWait(0, 0, NULL, portMAX_DELAY);
|
||||
vTaskDelete(ctx->thread);
|
||||
free(ctx->xStack);
|
||||
@@ -709,7 +710,7 @@ static void *rtp_thread_func(void *arg) {
|
||||
|
||||
free(packet);
|
||||
LOG_INFO("[%p]: terminating", ctx);
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
xTaskNotify(ctx->joiner, 0, eNoAction);
|
||||
vTaskSuspend(NULL);
|
||||
|
||||
@@ -35,6 +35,10 @@ extern struct buffer *outputbuf;
|
||||
// this is the only system-wide loglevel variable
|
||||
extern log_level loglevel;
|
||||
|
||||
// not great to have these here, but they should not be in embedded.h
|
||||
bool enable_bt_sink;
|
||||
bool enable_airplay;
|
||||
|
||||
#define RAOP_OUTPUT_SIZE (RAOP_SAMPLE_RATE * 2 * 2 * 2 * 1.2)
|
||||
|
||||
static raop_event_t raop_state;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef EMBEDDED_H
|
||||
#define EMBEDDED_H
|
||||
#include "esp_system.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/* must provide
|
||||
@@ -8,6 +8,7 @@
|
||||
- pthread_create_name
|
||||
- stack size
|
||||
- s16_t, s32_t, s64_t and u64_t
|
||||
- EXT_BSS
|
||||
can overload (use #define)
|
||||
- exit
|
||||
- gettime_ms
|
||||
@@ -25,6 +26,7 @@
|
||||
#define IR_THREAD_STACK_SIZE 6 * 1024
|
||||
|
||||
//#define BASE_CAP "Model=squeezelite,AccuratePlayPoints=0,HasDigitalOut=1,HasPolarityInversion=1,Firmware=" VERSION
|
||||
#define EXT_BSS __attribute__((section(".ext_ram.bss")))
|
||||
|
||||
typedef int16_t s16_t;
|
||||
typedef int32_t s32_t;
|
||||
@@ -41,10 +43,6 @@ uint32_t _gettime_ms_(void);
|
||||
int pthread_create_name(pthread_t *thread, _CONST pthread_attr_t *attr,
|
||||
void *(*start_routine)( void * ), void *arg, char *name);
|
||||
|
||||
// these are here as they can be #define to nothing
|
||||
extern bool enable_bt_sink;
|
||||
extern bool enable_airplay;
|
||||
|
||||
void register_external(void);
|
||||
void deregister_external(void);
|
||||
|
||||
|
||||
@@ -533,7 +533,7 @@ static void process(u8_t *pack, int len) {
|
||||
static bool running;
|
||||
|
||||
static void slimproto_run() {
|
||||
static u8_t *buffer = NULL;
|
||||
static u8_t EXT_BSS buffer[MAXBUF];
|
||||
int expect = 0;
|
||||
int got = 0;
|
||||
u32_t now;
|
||||
@@ -541,9 +541,6 @@ static void slimproto_run() {
|
||||
event_handle ehandles[2];
|
||||
int timeouts = 0;
|
||||
|
||||
// just to avoid having to free that up at multiple places
|
||||
if (!buffer) buffer = malloc(MAXBUF);
|
||||
|
||||
set_readwake_handles(ehandles, sock, wake_e);
|
||||
|
||||
while (running && !new_server) {
|
||||
@@ -626,14 +623,12 @@ static void slimproto_run() {
|
||||
bool _start_output = false;
|
||||
decode_state _decode_state;
|
||||
disconnect_code disconnect_code;
|
||||
static char *header = NULL;
|
||||
static char EXT_BSS header[MAX_HEADER];
|
||||
size_t header_len = 0;
|
||||
#if IR
|
||||
bool _sendIR = false;
|
||||
u32_t ir_code, ir_ts;
|
||||
#endif
|
||||
// just to avoid allocating it at every pass
|
||||
if (!header) header = malloc(MAX_HEADER);
|
||||
|
||||
last = now;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user