mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-05-04 04:19:28 +01:00
style: apply clang-format and enforce left pointer alignment
This commit is contained in:
@@ -19,7 +19,6 @@ extern esp_err_t process_recovery_ota(const char* bin_url, char* bin_buffer, uin
|
||||
extern int squeezelite_main_start();
|
||||
extern sys_dac_default_sets* default_dac_sets;
|
||||
|
||||
|
||||
static const char* TAG = "squeezelite_cmd";
|
||||
#define SQUEEZELITE_THREAD_STACK_SIZE (8 * 1024)
|
||||
#define ADDITIONAL_SQUEEZELITE_ARGS 5
|
||||
@@ -75,42 +74,36 @@ static void squeezelite_thread(void* arg) {
|
||||
int wait = 60;
|
||||
int ret = squeezelite_main_start();
|
||||
|
||||
if (ret == -2) {
|
||||
cmd_send_messaging("cfg-audio-tmpl", MESSAGING_ERROR,
|
||||
"Squeezelite not configured. Rebooting to factory in %d sec\n", wait);
|
||||
if(ret == -2) {
|
||||
cmd_send_messaging("cfg-audio-tmpl", MESSAGING_ERROR, "Squeezelite not configured. Rebooting to factory in %d sec\n", wait);
|
||||
vTaskDelay(pdMS_TO_TICKS(wait * 1000));
|
||||
guided_factory();
|
||||
} else {
|
||||
cmd_send_messaging("cfg-audio-tmpl", ret > 1 ? MESSAGING_ERROR : MESSAGING_WARNING,
|
||||
"squeezelite exited with error code %d\n", ret);
|
||||
if (ret <= 1) {
|
||||
cmd_send_messaging("cfg-audio-tmpl", ret > 1 ? MESSAGING_ERROR : MESSAGING_WARNING, "squeezelite exited with error code %d\n", ret);
|
||||
if(ret <= 1) {
|
||||
|
||||
cmd_send_messaging(
|
||||
"cfg-audio-tmpl", MESSAGING_ERROR, "Rebooting to factory in %d sec\n", wait);
|
||||
cmd_send_messaging("cfg-audio-tmpl", MESSAGING_ERROR, "Rebooting to factory in %d sec\n", wait);
|
||||
vTaskDelay(pdMS_TO_TICKS(wait * 1000));
|
||||
guided_factory();
|
||||
} else {
|
||||
|
||||
cmd_send_messaging(
|
||||
"cfg-audio-tmpl", MESSAGING_ERROR, "Correct command line and reboot\n");
|
||||
cmd_send_messaging("cfg-audio-tmpl", MESSAGING_ERROR, "Correct command line and reboot\n");
|
||||
vTaskSuspend(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, "Exited from squeezelite's main(). Freeing argv structure.");
|
||||
|
||||
for (int i = 0; i < thread_parms.argc; i++)
|
||||
free(thread_parms.argv[i]);
|
||||
for(int i = 0; i < thread_parms.argc; i++) free(thread_parms.argv[i]);
|
||||
free(thread_parms.argv);
|
||||
}
|
||||
|
||||
static int launchsqueezelite(int argc, char** argv) {
|
||||
static DRAM_ATTR StaticTask_t xTaskBuffer __attribute__((aligned(4)));
|
||||
static EXT_RAM_ATTR StackType_t xStack[SQUEEZELITE_THREAD_STACK_SIZE]
|
||||
__attribute__((aligned(4)));
|
||||
static EXT_RAM_ATTR StackType_t xStack[SQUEEZELITE_THREAD_STACK_SIZE] __attribute__((aligned(4)));
|
||||
static bool isRunning = false;
|
||||
|
||||
if (isRunning) {
|
||||
if(isRunning) {
|
||||
ESP_LOGE(TAG, "Squeezelite already running. Exiting!");
|
||||
return -1;
|
||||
}
|
||||
@@ -118,14 +111,13 @@ static int launchsqueezelite(int argc, char** argv) {
|
||||
ESP_LOGV(TAG, "Begin");
|
||||
isRunning = true;
|
||||
|
||||
// load the presets here, as the squeezelite cannot access the
|
||||
// load the presets here, as the squeezelite cannot access the
|
||||
// spiffs storage
|
||||
// proto_load_file("/spiffs/presets/default_sets.bin", &sys_dac_default_sets_msg, default_dac_sets, false);
|
||||
|
||||
ESP_LOGD(TAG, "Starting Squeezelite Thread");
|
||||
xTaskCreateStaticPinnedToCore(squeezelite_thread, "squeezelite", SQUEEZELITE_THREAD_STACK_SIZE,
|
||||
NULL, CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT, xStack, &xTaskBuffer,
|
||||
CONFIG_PTHREAD_TASK_CORE_DEFAULT);
|
||||
xTaskCreateStaticPinnedToCore(squeezelite_thread, "squeezelite", SQUEEZELITE_THREAD_STACK_SIZE, NULL, CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT,
|
||||
xStack, &xTaskBuffer, CONFIG_PTHREAD_TASK_CORE_DEFAULT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -142,7 +134,7 @@ void start_squeezelite() { launchsqueezelite(0, NULL); }
|
||||
// }
|
||||
|
||||
esp_err_t start_ota(const char* bin_url, char* bin_buffer, uint32_t length) {
|
||||
if (!bin_url || strlen(bin_url) == 0) {
|
||||
if(!bin_url || strlen(bin_url) == 0) {
|
||||
ESP_LOGE(TAG, "missing URL parameter. Unable to start OTA");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
@@ -150,9 +142,7 @@ esp_err_t start_ota(const char* bin_url, char* bin_buffer, uint32_t length) {
|
||||
system_set_string(&sys_state_data_msg, sys_state_data_ota_url_tag, sys_state, bin_url);
|
||||
config_raise_state_changed();
|
||||
|
||||
if (!config_waitcommit()) {
|
||||
ESP_LOGW(TAG, "Unable to commit configuration. ");
|
||||
}
|
||||
if(!config_waitcommit()) { ESP_LOGW(TAG, "Unable to commit configuration. "); }
|
||||
ESP_LOGW(TAG, "Rebooting to recovery to complete the installation");
|
||||
return guided_factory();
|
||||
return ESP_OK;
|
||||
|
||||
Reference in New Issue
Block a user