mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-06 11:36:59 +03:00
Validated 256 pixels SSD1326
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
#include "log_util.h"
|
||||
|
||||
#define RTSP_STACK_SIZE (8*1024)
|
||||
#define SEARCH_STACK_SIZE (2*1048)
|
||||
#define SEARCH_STACK_SIZE (3*1048)
|
||||
|
||||
typedef struct raop_ctx_s {
|
||||
#ifdef WIN32
|
||||
@@ -86,7 +86,7 @@ typedef struct raop_ctx_s {
|
||||
struct mDNShandle_s *handle;
|
||||
pthread_t thread;
|
||||
#else
|
||||
TaskHandle_t thread, joiner;
|
||||
TaskHandle_t thread;
|
||||
StaticTask_t *xTaskBuffer;
|
||||
StackType_t xStack[SEARCH_STACK_SIZE] __attribute__ ((aligned (4)));;
|
||||
SemaphoreHandle_t destroy_mutex;
|
||||
@@ -100,7 +100,7 @@ extern log_level raop_loglevel;
|
||||
static log_level *loglevel = &raop_loglevel;
|
||||
|
||||
static void* rtsp_thread(void *arg);
|
||||
static void abort_rtsp(raop_ctx_t *ctx);
|
||||
static void cleanup_rtsp(raop_ctx_t *ctx, bool abort);
|
||||
static bool handle_rtsp(raop_ctx_t *ctx, int sock);
|
||||
|
||||
static char* rsa_apply(unsigned char *input, int inlen, int *outlen, int mode);
|
||||
@@ -248,18 +248,6 @@ void raop_delete(struct raop_ctx_s *ctx) {
|
||||
if (ctx->active_remote.handle) {
|
||||
close_mDNS(ctx->active_remote.handle);
|
||||
pthread_join(ctx->active_remote.thread, NULL);
|
||||
}
|
||||
|
||||
// stop broadcasting devices
|
||||
mdns_service_remove(ctx->svr, ctx->svc);
|
||||
mdnsd_stop(ctx->svr);
|
||||
#else
|
||||
// first stop the search task if any
|
||||
if (ctx->active_remote.running) {
|
||||
ctx->active_remote.joiner = xTaskGetCurrentTaskHandle();
|
||||
ctx->active_remote.running = false;
|
||||
|
||||
vTaskResume(ctx->active_remote.thread);
|
||||
}
|
||||
|
||||
// stop broadcasting devices
|
||||
@@ -268,10 +256,11 @@ void raop_delete(struct raop_ctx_s *ctx) {
|
||||
#else
|
||||
// then the RTSP task
|
||||
ctx->joiner = xTaskGetCurrentTaskHandle();
|
||||
ctx->running = false;
|
||||
|
||||
ctx->running = false;
|
||||
|
||||
ulTaskNotifyTake(pdFALSE, portMAX_DELAY);
|
||||
vTaskDelete(ctx->thread);
|
||||
heap_caps_free(ctx->xTaskBuffer);
|
||||
|
||||
shutdown(ctx->sock, SHUT_RDWR);
|
||||
closesocket(ctx->sock);
|
||||
@@ -406,7 +395,7 @@ static void *rtsp_thread(void *arg) {
|
||||
FD_SET(sock, &rfds);
|
||||
|
||||
n = select(sock + 1, &rfds, NULL, NULL, &timeout);
|
||||
|
||||
|
||||
if (!n && !ctx->abort) continue;
|
||||
|
||||
if (n > 0) res = handle_rtsp(ctx, sock);
|
||||
@@ -581,37 +570,11 @@ static bool handle_rtsp(raop_ctx_t *ctx, int sock)
|
||||
unsigned short seqno = 0;
|
||||
unsigned rtptime = 0;
|
||||
char *p;
|
||||
|
||||
buf = kd_lookup(headers, "RTP-Info");
|
||||
|
||||
buf = kd_lookup(headers, "RTP-Info");
|
||||
if ((p = strcasestr(buf, "seq")) != NULL) sscanf(p, "%*[^=]=%hu", &seqno);
|
||||
if ((p = strcasestr(buf, "rtptime")) != NULL) sscanf(p, "%*[^=]=%u", &rtptime);
|
||||
// only send FLUSH if useful (discards frames above buffer head and top)
|
||||
if (ctx->rtp && rtp_flush(ctx->rtp, seqno, rtptime))
|
||||
success = ctx->cmd_cb(RAOP_FLUSH);
|
||||
|
||||
} else if (!strcmp(method, "TEARDOWN")) {
|
||||
|
||||
rtp_end(ctx->rtp);
|
||||
|
||||
ctx->rtp = NULL;
|
||||
|
||||
// need to make sure no search is on-going and reclaim pthread memory
|
||||
#ifdef WIN32
|
||||
if (ctx->active_remote.handle) close_mDNS(ctx->active_remote.handle);
|
||||
pthread_join(ctx->active_remote.thread, NULL);
|
||||
#else
|
||||
ctx->active_remote.joiner = xTaskGetCurrentTaskHandle();
|
||||
ctx->active_remote.running = false;
|
||||
|
||||
xSemaphoreTake(ctx->active_remote.destroy_mutex, portMAX_DELAY);
|
||||
vTaskDelete(ctx->active_remote.thread);
|
||||
vSemaphoreDelete(ctx->active_remote.thread);
|
||||
|
||||
heap_caps_free(ctx->active_remote.xTaskBuffer);
|
||||
|
||||
LOG_INFO("[%p]: mDNS search task terminated", ctx);
|
||||
#endif
|
||||
|
||||
// only send FLUSH if useful (discards frames above buffer head and top)
|
||||
if (ctx->rtp && rtp_flush(ctx->rtp, seqno, rtptime)) success = ctx->cmd_cb(RAOP_FLUSH);
|
||||
|
||||
@@ -681,12 +644,12 @@ static bool handle_rtsp(raop_ctx_t *ctx, int sock)
|
||||
NFREE(body);
|
||||
NFREE(buf);
|
||||
kd_free(resp);
|
||||
kd_free(headers);
|
||||
kd_free(headers);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void cleanup_rtsp(raop_ctx_t *ctx, bool abort) {
|
||||
// first stop RTP process
|
||||
if (ctx->rtp) {
|
||||
@@ -695,9 +658,7 @@ void abort_rtsp(raop_ctx_t *ctx) {
|
||||
if (abort) LOG_INFO("[%p]: RTP thread aborted", ctx);
|
||||
}
|
||||
|
||||
if (ctx->active_remote.running) {
|
||||
if (ctx->active_remote.running) {
|
||||
pthread_join(ctx->active_remote.thread, NULL);
|
||||
#ifdef WIN32
|
||||
pthread_join(ctx->active_remote.thread, NULL);
|
||||
close_mDNS(ctx->active_remote.handle);
|
||||
@@ -705,8 +666,6 @@ void abort_rtsp(raop_ctx_t *ctx) {
|
||||
// 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);
|
||||
vTaskDelete(ctx->active_remote.thread);
|
||||
vSemaphoreDelete(ctx->active_remote.thread);
|
||||
vTaskDelete(ctx->active_remote.thread);
|
||||
vSemaphoreDelete(ctx->active_remote.thread);
|
||||
|
||||
@@ -776,7 +735,7 @@ static void* search_remote(void *args) {
|
||||
if (r) {
|
||||
for (a = r->addr; a && a->addr.type != IPADDR_TYPE_V4; a = a->next);
|
||||
if (a) {
|
||||
found = true;
|
||||
found = true;
|
||||
ctx->active_remote.host.s_addr = a->addr.u_addr.ip4.addr;
|
||||
ctx->active_remote.port = r->port;
|
||||
LOG_INFO("found remote %s %s:%hu", r->instance_name, inet_ntoa(ctx->active_remote.host), ctx->active_remote.port);
|
||||
|
||||
Reference in New Issue
Block a user