diff --git a/.gitignore b/.gitignore index 31ee9568..75d2bfa7 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,5 @@ $RECYCLE.BIN/ libs/ /cdump.cmd -/_codecs +/_* sdkconfig -/tmp diff --git a/components/platform_esp32/CMakeLists.txt b/components/driver_bt/CMakeLists.txt similarity index 54% rename from components/platform_esp32/CMakeLists.txt rename to components/driver_bt/CMakeLists.txt index d0463eae..cb35ab91 100644 --- a/components/platform_esp32/CMakeLists.txt +++ b/components/driver_bt/CMakeLists.txt @@ -1,6 +1,6 @@ set(COMPONENT_ADD_INCLUDEDIRS . ) -set(COMPONENT_SRCS "esp_app_main.c" "platform_esp32.c" "bt_app_core.c" "cmd_wifi.c" "console.c" "nvs_utilities.c" "cmd_squeezelite.c") +set(COMPONENT_SRCS "bt_app_core.c" ) set(REQUIRES esp_common) set(REQUIRES_COMPONENTS freertos nvs_flash esp32 spi_flash newlib log console ) diff --git a/components/platform_esp32/bt_app_core.c b/components/driver_bt/bt_app_core.c similarity index 100% rename from components/platform_esp32/bt_app_core.c rename to components/driver_bt/bt_app_core.c diff --git a/components/platform_esp32/bt_app_core.h b/components/driver_bt/bt_app_core.h similarity index 100% rename from components/platform_esp32/bt_app_core.h rename to components/driver_bt/bt_app_core.h diff --git a/components/platform_esp32/bt_app_handler.c b/components/driver_bt/bt_app_handler.c similarity index 99% rename from components/platform_esp32/bt_app_handler.c rename to components/driver_bt/bt_app_handler.c index eaf5673d..bc37ff15 100644 --- a/components/platform_esp32/bt_app_handler.c +++ b/components/driver_bt/bt_app_handler.c @@ -17,8 +17,7 @@ #include "argtable3/argtable3.h" #include "bt_app_core.h" - -#include "platform_esp32.h" +#include "trace.h" static const char * TAG = "platform"; diff --git a/components/platform_esp32/component.mk b/components/driver_bt/component.mk similarity index 80% rename from components/platform_esp32/component.mk rename to components/driver_bt/component.mk index 77265992..0c83faa9 100644 --- a/components/platform_esp32/component.mk +++ b/components/driver_bt/component.mk @@ -6,4 +6,6 @@ # lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable, # please read the SDK documents if you need to do this. # -CFLAGS += -D LOG_LOCAL_LEVEL=ESP_LOG_DEBUG + +CFLAGS += -I$(COMPONENT_PATH)/../tools +#CFLAGS += -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG diff --git a/main/alac.c b/components/squeezelite/alac.c similarity index 100% rename from main/alac.c rename to components/squeezelite/alac.c diff --git a/main/buffer.c b/components/squeezelite/buffer.c similarity index 100% rename from main/buffer.c rename to components/squeezelite/buffer.c diff --git a/components/squeezelite/component.mk b/components/squeezelite/component.mk new file mode 100644 index 00000000..53a25b0c --- /dev/null +++ b/components/squeezelite/component.mk @@ -0,0 +1,18 @@ +# +# "main" pseudo-component makefile. +# +# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) +CFLAGS += -O3 -DLINKALL -DLOOPBACK -DNO_FAAD -DRESAMPLE16 -DEMBEDDED -DTREMOR_ONLY -DBYTES_PER_FRAME=4 \ + -I$(COMPONENT_PATH)/../codecs/inc \ + -I$(COMPONENT_PATH)/../codecs/inc/mad \ + -I$(COMPONENT_PATH)/../codecs/inc/alac \ + -I$(COMPONENT_PATH)/../codecs/inc/helix-aac \ + -I$(COMPONENT_PATH)/../codecs/inc/vorbis \ + -I$(COMPONENT_PATH)/../codecs/inc/soxr \ + -I$(COMPONENT_PATH)/../codecs/inc/resample16 \ + -I$(COMPONENT_PATH)/../tools + +# -I$(COMPONENT_PATH)/../codecs/inc/faad2 + + + diff --git a/main/decode.c b/components/squeezelite/decode.c similarity index 100% rename from main/decode.c rename to components/squeezelite/decode.c diff --git a/main/embedded.c b/components/squeezelite/embedded.c similarity index 100% rename from main/embedded.c rename to components/squeezelite/embedded.c diff --git a/main/embedded.h b/components/squeezelite/embedded.h similarity index 100% rename from main/embedded.h rename to components/squeezelite/embedded.h diff --git a/main/faad.c.nocompile b/components/squeezelite/faad.c.nocompile similarity index 100% rename from main/faad.c.nocompile rename to components/squeezelite/faad.c.nocompile diff --git a/main/flac.c b/components/squeezelite/flac.c similarity index 100% rename from main/flac.c rename to components/squeezelite/flac.c diff --git a/main/helix-aac.c b/components/squeezelite/helix-aac.c similarity index 100% rename from main/helix-aac.c rename to components/squeezelite/helix-aac.c diff --git a/main/mad.c b/components/squeezelite/mad.c similarity index 100% rename from main/mad.c rename to components/squeezelite/mad.c diff --git a/main/main.c b/components/squeezelite/main.c similarity index 100% rename from main/main.c rename to components/squeezelite/main.c diff --git a/main/mpg.c b/components/squeezelite/mpg.c similarity index 100% rename from main/mpg.c rename to components/squeezelite/mpg.c diff --git a/main/output.c b/components/squeezelite/output.c similarity index 100% rename from main/output.c rename to components/squeezelite/output.c diff --git a/main/output_bt.c b/components/squeezelite/output_bt.c similarity index 100% rename from main/output_bt.c rename to components/squeezelite/output_bt.c diff --git a/main/output_embedded.c b/components/squeezelite/output_embedded.c similarity index 100% rename from main/output_embedded.c rename to components/squeezelite/output_embedded.c diff --git a/main/output_i2s.c b/components/squeezelite/output_i2s.c similarity index 100% rename from main/output_i2s.c rename to components/squeezelite/output_i2s.c diff --git a/main/output_pack.c b/components/squeezelite/output_pack.c similarity index 100% rename from main/output_pack.c rename to components/squeezelite/output_pack.c diff --git a/main/pcm.c b/components/squeezelite/pcm.c similarity index 100% rename from main/pcm.c rename to components/squeezelite/pcm.c diff --git a/main/process.c b/components/squeezelite/process.c similarity index 100% rename from main/process.c rename to components/squeezelite/process.c diff --git a/main/resample.c b/components/squeezelite/resample.c similarity index 100% rename from main/resample.c rename to components/squeezelite/resample.c diff --git a/main/resample16.c b/components/squeezelite/resample16.c similarity index 100% rename from main/resample16.c rename to components/squeezelite/resample16.c diff --git a/main/slimproto.c b/components/squeezelite/slimproto.c similarity index 100% rename from main/slimproto.c rename to components/squeezelite/slimproto.c diff --git a/main/slimproto.h b/components/squeezelite/slimproto.h similarity index 100% rename from main/slimproto.h rename to components/squeezelite/slimproto.h diff --git a/main/squeezelite.h b/components/squeezelite/squeezelite.h similarity index 99% rename from main/squeezelite.h rename to components/squeezelite/squeezelite.h index 89dec4b3..fabe626a 100644 --- a/main/squeezelite.h +++ b/components/squeezelite/squeezelite.h @@ -287,10 +287,10 @@ #include #endif /* SUN */ -#define STREAM_THREAD_STACK_SIZE 64 * 1024 -#define DECODE_THREAD_STACK_SIZE 128 * 1024 -#define OUTPUT_THREAD_STACK_SIZE 64 * 1024 -#define IR_THREAD_STACK_SIZE 64 * 1024 +#define STREAM_THREAD_STACK_SIZE 8 * 1024 +#define DECODE_THREAD_STACK_SIZE 20 * 1024 +#define OUTPUT_THREAD_STACK_SIZE 8 * 1024 +#define IR_THREAD_STACK_SIZE 8 * 1024 #if !OSX #define thread_t pthread_t; #endif diff --git a/main/stream.c b/components/squeezelite/stream.c similarity index 100% rename from main/stream.c rename to components/squeezelite/stream.c diff --git a/main/utils.c b/components/squeezelite/utils.c similarity index 100% rename from main/utils.c rename to components/squeezelite/utils.c diff --git a/main/vorbis.c b/components/squeezelite/vorbis.c similarity index 100% rename from main/vorbis.c rename to components/squeezelite/vorbis.c diff --git a/components/platform_esp32/perf_trace.h b/components/tools/perf_trace.h similarity index 100% rename from components/platform_esp32/perf_trace.h rename to components/tools/perf_trace.h diff --git a/components/tools/trace.h b/components/tools/trace.h new file mode 100644 index 00000000..d62dcd71 --- /dev/null +++ b/components/tools/trace.h @@ -0,0 +1,30 @@ +/* + * Squeezelite for esp32 + * + * (c) Sebastien 2019 + * Philippe G. 2019, philippe_44@outlook.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#ifndef QUOTE +#define QUOTE(name) #name +#endif + +#define ESP_LOG_DEBUG_EVENT(tag,e) ESP_LOGD(tag,"evt: " e) + + diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt new file mode 100644 index 00000000..44152c3c --- /dev/null +++ b/main/CMakeLists.txt @@ -0,0 +1,7 @@ +set(COMPONENT_ADD_INCLUDEDIRS . ) + +set(COMPONENT_SRCS "esp_app_main.c" "platform_esp32.c" "cmd_wifi.c" "console.c" "nvs_utilities.c" "cmd_squeezelite.c") +set(REQUIRES esp_common) +set(REQUIRES_COMPONENTS freertos nvs_flash esp32 spi_flash newlib log console ) + +register_component() diff --git a/main/Params.txt b/main/Params.txt new file mode 100644 index 00000000..faf2af16 --- /dev/null +++ b/main/Params.txt @@ -0,0 +1,24 @@ +LWIP +Enable Copy between L2 and L3 no (no) +Default receive window size 32768 (5740) +Default transmit window size 8192 (5740) +TCP:Default TCP receive mail box size 32 (6) + +WiFi +Max number of WiFi static RX buffer 12-16 (6) +Max number of WiFi dynamic buffer 24-64 (16 or 10) +Max number of WiFi static TX buffer 12-16 (6) + +SPI RAM +Maximum malloc() to always put in internal memory 512 (2048) + +MBED_TLS +Memory allocation strategy: external + +Put .bss in SPIRAM? + +nvs_set autoexec2 str -v "squeezelite -o \"BT -n 'RIVAARENA'\" -b 500:2000 -d all=info -m ESP32 -R -Z 96000 -r \"44100-44100\" -e flac" +nvs_set autoexec2 str -v "squeezelite -o \"BT -n 'RIVAARENA'\" -b 500:2000 -d all=info -m ESP32 -R -Z 96000 -r \"44100-44100\"" +nvs_set autoexec2 str -v "squeezelite -o \"BT -n 'RIVAARENA'\" -b 500:2000 -d all=info -m ESP32 -R -u m -Z 192000 -r \"44100-44100\" -s 192.168.2.144" +nvs_set autoexec2 str -v "squeezelite -o \"BT -n 'RIVAARENA'\" -b 500:2000 -d all=info -m ESP32 -r \"44100-44100\" -e flac" +nvs_set autoexec2 str -v "squeezelite -o I2S -b 500:2000 -d all=info -m ESP32 -R -Z 96000 -r \"44100-44100\"" diff --git a/components/platform_esp32/cmd_decl.h b/main/cmd_decl.h similarity index 100% rename from components/platform_esp32/cmd_decl.h rename to main/cmd_decl.h diff --git a/components/platform_esp32/cmd_squeezelite.c b/main/cmd_squeezelite.c similarity index 100% rename from components/platform_esp32/cmd_squeezelite.c rename to main/cmd_squeezelite.c diff --git a/components/platform_esp32/cmd_squeezelite.h b/main/cmd_squeezelite.h similarity index 100% rename from components/platform_esp32/cmd_squeezelite.h rename to main/cmd_squeezelite.h diff --git a/components/platform_esp32/cmd_wifi.c b/main/cmd_wifi.c similarity index 100% rename from components/platform_esp32/cmd_wifi.c rename to main/cmd_wifi.c diff --git a/components/platform_esp32/cmd_wifi.h b/main/cmd_wifi.h similarity index 100% rename from components/platform_esp32/cmd_wifi.h rename to main/cmd_wifi.h diff --git a/main/component.mk b/main/component.mk index ec21c2eb..a0fd0ee8 100644 --- a/main/component.mk +++ b/main/component.mk @@ -1,20 +1,10 @@ # -# "main" pseudo-component makefile. +# Component Makefile # -# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) -CFLAGS += -O3 -DLINKALL -DLOOPBACK -DNO_FAAD -DRESAMPLE16 -DEMBEDDED -DTREMOR_ONLY -DBYTES_PER_FRAME=4 \ - -I$(COMPONENT_PATH)/../components/codecs/inc \ - -I$(COMPONENT_PATH)/../components/codecs/inc/mad \ - -I$(COMPONENT_PATH)/../components/codecs/inc/alac \ - -I$(COMPONENT_PATH)/../components/codecs/inc/helix-aac \ - -I$(COMPONENT_PATH)/../components/codecs/inc/vorbis \ - -I$(COMPONENT_PATH)/../components/codecs/inc/soxr \ - -I$(COMPONENT_PATH)/../components/codecs/inc/resample16 \ - -I$(COMPONENT_PATH)/../components/platform_esp32 - -LDFLAGS += -s - -# -I$(COMPONENT_PATH)/../components/codecs/inc/faad2 - - - +# This Makefile should, at the very least, just include $(SDK_PATH)/Makefile. By default, +# this will take the sources in the src/ directory, compile them and link them into +# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable, +# please read the SDK documents if you need to do this. +# +CFLAGS += -D LOG_LOCAL_LEVEL=ESP_LOG_DEBUG +LDFLAGS += -s \ No newline at end of file diff --git a/components/platform_esp32/console.c b/main/console.c similarity index 99% rename from components/platform_esp32/console.c rename to main/console.c index 0bacaa7e..5476c617 100644 --- a/components/platform_esp32/console.c +++ b/main/console.c @@ -22,6 +22,7 @@ #include "nvs_flash.h" #include "pthread.h" #include "platform_esp32.h" +#include "esp_pthread.h" #include "cmd_decl.h" #include "console.h" diff --git a/components/platform_esp32/console.h b/main/console.h similarity index 100% rename from components/platform_esp32/console.h rename to main/console.h diff --git a/components/platform_esp32/esp_app_main.c b/main/esp_app_main.c similarity index 100% rename from components/platform_esp32/esp_app_main.c rename to main/esp_app_main.c diff --git a/components/platform_esp32/nvs_utilities.c b/main/nvs_utilities.c similarity index 100% rename from components/platform_esp32/nvs_utilities.c rename to main/nvs_utilities.c diff --git a/components/platform_esp32/nvs_utilities.h b/main/nvs_utilities.h similarity index 100% rename from components/platform_esp32/nvs_utilities.h rename to main/nvs_utilities.h diff --git a/components/platform_esp32/platform_esp32.h b/main/platform_esp32.h similarity index 84% rename from components/platform_esp32/platform_esp32.h rename to main/platform_esp32.h index b01e4754..1e113d81 100644 --- a/components/platform_esp32/platform_esp32.h +++ b/main/platform_esp32.h @@ -21,24 +21,10 @@ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "esp_pthread.h" -#ifndef QUOTE -#define QUOTE(name) #name -#endif - -#define ESP_LOG_DEBUG_EVENT(tag,e) ESP_LOGD(tag,"evt: " e) - extern void run_command(char * line); extern bool wait_for_wifi(); extern void console_start(); extern pthread_cond_t wifi_connect_suspend_cond; extern pthread_t wifi_connect_suspend_mutex; - -#ifdef __cplusplus -} -#endif