mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 03:57:07 +03:00
Merge remote-tracking branch 'origin/master' into httpd
This commit is contained in:
@@ -57,9 +57,9 @@ typedef struct raop_ctx_s {
|
||||
struct in_addr peer; // IP of the iDevice (airplay sender)
|
||||
bool running;
|
||||
#ifdef WIN32
|
||||
pthread_t thread, search_thread;
|
||||
pthread_t thread;
|
||||
#else
|
||||
TaskHandle_t thread, search_thread, joiner;
|
||||
TaskHandle_t thread, joiner;
|
||||
StaticTask_t *xTaskBuffer;
|
||||
StackType_t xStack[RTSP_STACK_SIZE] __attribute__ ((aligned (4)));
|
||||
#endif
|
||||
@@ -81,10 +81,11 @@ typedef struct raop_ctx_s {
|
||||
char DACPid[32], id[32];
|
||||
struct in_addr host;
|
||||
u16_t port;
|
||||
bool running;
|
||||
#ifdef WIN32
|
||||
struct mDNShandle_s *handle;
|
||||
pthread_t thread;
|
||||
#else
|
||||
bool running;
|
||||
TaskHandle_t thread, joiner;
|
||||
StaticTask_t *xTaskBuffer;
|
||||
StackType_t xStack[SEARCH_STACK_SIZE] __attribute__ ((aligned (4)));;
|
||||
@@ -218,7 +219,7 @@ void raop_delete(struct raop_ctx_s *ctx) {
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void raop_delete(struct raop_ctx_s *ctx) {
|
||||
void raop_delete(struct raop_ctx_s *ctx) {
|
||||
#ifdef WIN32
|
||||
int sock;
|
||||
struct sockaddr addr;
|
||||
@@ -240,7 +241,7 @@ void raop_delete(struct raop_ctx_s *ctx) {
|
||||
|
||||
rtp_end(ctx->rtp);
|
||||
|
||||
shutdown(ctx->sock, SD_BOTH);
|
||||
shutdown(ctx->sock, SD_BOTH);
|
||||
closesocket(ctx->sock);
|
||||
|
||||
// terminate search, but do not reclaim memory of pthread if never launched
|
||||
@@ -515,7 +516,7 @@ static bool handle_rtsp(raop_ctx_t *ctx, int sock)
|
||||
NFREE(p);
|
||||
}
|
||||
|
||||
// on announce, search remote
|
||||
// on announce, search remote
|
||||
if ((buf = kd_lookup(headers, "DACP-ID")) != NULL) strcpy(ctx->active_remote.DACPid, buf);
|
||||
if ((buf = kd_lookup(headers, "Active-Remote")) != NULL) strcpy(ctx->active_remote.id, buf);
|
||||
|
||||
@@ -592,7 +593,7 @@ static bool handle_rtsp(raop_ctx_t *ctx, int sock)
|
||||
} 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
|
||||
@@ -631,18 +632,16 @@ static bool handle_rtsp(raop_ctx_t *ctx, int sock)
|
||||
success = ctx->cmd_cb(RAOP_VOLUME, volume);
|
||||
} else if (body && (p = strcasestr(body, "progress")) != NULL) {
|
||||
int start, current, stop = 0;
|
||||
|
||||
// we want ms, not s
|
||||
sscanf(p, "%*[^:]:%u/%u/%u", &start, ¤t, &stop);
|
||||
current = ((current - start) / 44100) * 1000;
|
||||
if (stop) stop = ((stop - start) / 44100) * 1000;
|
||||
|
||||
// we want ms, not s
|
||||
sscanf(p, "%*[^:]:%u/%u/%u", &start, ¤t, &stop);
|
||||
current = ((current - start) / 44100) * 1000;
|
||||
if (stop) stop = ((stop - start) / 44100) * 1000;
|
||||
else stop = -1;
|
||||
LOG_INFO("[%p]: SET PARAMETER progress %d/%u %s", ctx, current, stop, p);
|
||||
success = ctx->cmd_cb(RAOP_PROGRESS, max(current, 0), stop);
|
||||
} else if (body && ((p = kd_lookup(headers, "Content-Type")) != NULL) && !strcasecmp(p, "application/x-dmap-tagged")) {
|
||||
struct metadata_s metadata;
|
||||
struct metadata_s metadata;
|
||||
dmap_settings settings = {
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, on_dmap_string, NULL,
|
||||
NULL
|
||||
@@ -651,6 +650,10 @@ static bool handle_rtsp(raop_ctx_t *ctx, int sock)
|
||||
LOG_INFO("[%p]: received metadata", ctx);
|
||||
settings.ctx = &metadata;
|
||||
memset(&metadata, 0, sizeof(struct metadata_s));
|
||||
if (!dmap_parse(&settings, body, len)) {
|
||||
LOG_INFO("[%p]: received metadata\n\tartist: %s\n\talbum: %s\n\ttitle: %s",
|
||||
ctx, metadata.artist, metadata.album, metadata.title);
|
||||
success = ctx->cmd_cb(RAOP_METADATA, metadata.artist, metadata.album, metadata.title);
|
||||
free_metadata(&metadata);
|
||||
}
|
||||
} else {
|
||||
@@ -684,9 +687,13 @@ void abort_rtsp(raop_ctx_t *ctx) {
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void abort_rtsp(raop_ctx_t *ctx) {
|
||||
void abort_rtsp(raop_ctx_t *ctx) {
|
||||
// first stop RTP process
|
||||
if (ctx->rtp) {
|
||||
rtp_end(ctx->rtp);
|
||||
ctx->rtp = NULL;
|
||||
LOG_INFO("[%p]: RTP thread aborted", ctx);
|
||||
}
|
||||
|
||||
if (ctx->active_remote.running) {
|
||||
#ifdef WIN32
|
||||
@@ -696,8 +703,10 @@ void abort_rtsp(raop_ctx_t *ctx) {
|
||||
// need to make sure no search is on-going and reclaim task memory
|
||||
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);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user