optimize telnet, stacks and threads

This commit is contained in:
Philippe G
2021-12-20 23:32:02 -08:00
parent de86a10d82
commit b13fa88033
4 changed files with 83 additions and 76 deletions

View File

@@ -9,9 +9,14 @@
*
*/
#include <math.h>
#ifdef ESP_PLATFORM
#include "freertos/FreeRTOS.h"
#include "freertos/timers.h"
#endif
#include "platform_config.h"
#include "squeezelite.h"
#include <math.h>
#if CONFIG_BT_SINK
#include "bt_app_sink.h"
@@ -315,9 +320,26 @@ static bool raop_sink_cmd_handler(raop_event_t event, va_list args)
}
#endif
/****************************************************************************************
/****************************************************************************************
* We provide the generic codec register option
*/
#if defined(ESP_PLATFORM) && defined(CONFIG_BT_SINK)
void bt_delay_start(TimerHandle_t xTimer) {
xTimerDelete(xTimer, portMAX_DELAY);
bt_sink_init(bt_sink_cmd_handler, sink_data_handler);
LOG_INFO("Initializing BT sink");
}
void bt_delay_stop(TimerHandle_t xTimer) {
xTimerDelete(xTimer, portMAX_DELAY);
bt_sink_deinit();
LOG_INFO("Stopping BT sink");
}
#endif
void register_external(void) {
char *p;
@@ -338,8 +360,13 @@ void register_external(void) {
#if CONFIG_BT_SINK
if (!strcasestr(output.device, "BT ") ) {
if(enable_bt_sink){
#ifdef ESP_PLATFORM
// we need to delay the start because current task is in spiram
TimerHandle_t timer = xTimerCreate("delay", 1, pdFALSE, NULL, bt_delay_start);
xTimerStart(timer, portMAX_DELAY);
#else
bt_sink_init(bt_sink_cmd_handler, sink_data_handler);
LOG_INFO("Initializing BT sink");
#endif
}
} else {
LOG_WARN("Cannot be a BT sink and source");
@@ -358,10 +385,16 @@ void register_external(void) {
void deregister_external(void) {
#if CONFIG_BT_SINK
if (!strcasestr(output.device, "BT ") && enable_bt_sink) {
LOG_INFO("Stopping BT sink");
#ifdef ESP_PLATFORM
// we need to delay the stop because current task is in spiram
TimerHandle_t timer = xTimerCreate("delay", 1, pdFALSE, NULL, bt_delay_stop);
xTimerStart(timer, portMAX_DELAY);
#else
bt_sink_deinit();
#endif
}
#endif
#if CONFIG_AIRPLAY_SINK
if (enable_airplay){
LOG_INFO("Stopping AirPlay sink");