mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-06 11:36:59 +03:00
move some staks to external memory
This commit is contained in:
@@ -75,6 +75,8 @@
|
||||
#define BUFFER_FRAMES ( (150 * RAOP_SAMPLE_RATE * 2) / (352 * 100) )
|
||||
#define MAX_PACKET 1408
|
||||
#define MIN_LATENCY 11025
|
||||
#define MAX_LATENCY ( (120 * RAOP_SAMPLE_RATE * 2) / 100 )
|
||||
|
||||
#define RTP_STACK_SIZE (4*1024)
|
||||
|
||||
#define RTP_SYNC (0x01)
|
||||
@@ -133,9 +135,11 @@ typedef struct rtp_s {
|
||||
u32_t discarded;
|
||||
abuf_t audio_buffer[BUFFER_FRAMES];
|
||||
seq_t ab_read, ab_write;
|
||||
pthread_mutex_t ab_mutex;
|
||||
pthread_mutex_t ab_mutex;
|
||||
#ifdef WIN32
|
||||
pthread_t rtp_thread;
|
||||
pthread_t thread;
|
||||
#else
|
||||
TaskHandle_t thread, joiner;
|
||||
StaticTask_t *xTaskBuffer;
|
||||
StackType_t *xStack;
|
||||
#endif
|
||||
@@ -259,9 +263,13 @@ rtp_resp_t rtp_init(struct in_addr host, int latency, char *aeskey, char *aesiv,
|
||||
resp.aport = ctx->rtp_sockets[DATA].lport;
|
||||
|
||||
if (rc) {
|
||||
ctx->running = true;
|
||||
ctx->running = true;
|
||||
#ifdef WIN32
|
||||
pthread_create(&ctx->rtp_thread, NULL, rtp_thread_func, (void *) ctx);
|
||||
pthread_create(&ctx->thread, NULL, rtp_thread_func, (void *) ctx);
|
||||
#else
|
||||
// xTaskCreate((TaskFunction_t) rtp_thread_func, "RTP_thread", RTP_TASK_SIZE, ctx, CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT + 1 , &ctx->thread);
|
||||
ctx->xTaskBuffer = (StaticTask_t*) heap_caps_malloc(sizeof(StaticTask_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||
ctx->xStack = (StackType_t*) malloc(RTP_STACK_SIZE);
|
||||
ctx->thread = xTaskCreateStatic( (TaskFunction_t) rtp_thread_func, "RTP_thread", RTP_STACK_SIZE, ctx,
|
||||
CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT + 1, ctx->xStack, ctx->xTaskBuffer );
|
||||
#endif
|
||||
@@ -281,14 +289,19 @@ void rtp_end(rtp_t *ctx)
|
||||
int i;
|
||||
|
||||
if (!ctx) return;
|
||||
|
||||
if (ctx->running) {
|
||||
#if !defined WIN32
|
||||
ctx->joiner = xTaskGetCurrentTaskHandle();
|
||||
#endif
|
||||
ctx->running = false;
|
||||
#ifdef WIN32
|
||||
pthread_join(ctx->rtp_thread, NULL);
|
||||
pthread_join(ctx->rtp_thread, NULL);
|
||||
#else
|
||||
xTaskNotifyWait(0, 0, NULL, portMAX_DELAY);
|
||||
free(ctx->xStack);
|
||||
heap_caps_free(ctx->xTaskBuffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) closesocket(ctx->rtp_sockets[i].sock);
|
||||
|
||||
Reference in New Issue
Block a user