Browse Source

add OggFlac & disable AMPDU

Philippe G 4 năm trước cách đây
mục cha
commit
899ea8b9e8

+ 5 - 5
build-scripts/ESP32-A1S-sdkconfig.defaults

@@ -322,11 +322,11 @@ CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=40
 CONFIG_ESP32_WIFI_STATIC_TX_BUFFER=y
 CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=0
 CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM=12
-# CONFIG_ESP32_WIFI_CSI_ENABLED is not set
-CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
-CONFIG_ESP32_WIFI_TX_BA_WIN=6
-CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
-CONFIG_ESP32_WIFI_RX_BA_WIN=16
+CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=n
+CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=n
+
+
+
 CONFIG_ESP32_WIFI_NVS_ENABLED=y
 CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y
 # CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set

+ 5 - 5
build-scripts/I2S-4MFlash-sdkconfig.defaults

@@ -325,11 +325,11 @@ CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=40
 CONFIG_ESP32_WIFI_STATIC_TX_BUFFER=y
 CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=0
 CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM=12
-# CONFIG_ESP32_WIFI_CSI_ENABLED is not set
-CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
-CONFIG_ESP32_WIFI_TX_BA_WIN=6
-CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
-CONFIG_ESP32_WIFI_RX_BA_WIN=16
+CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=n
+CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=n
+
+
+
 CONFIG_ESP32_WIFI_NVS_ENABLED=y
 CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y
 # CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set

+ 5 - 5
build-scripts/SqueezeAmp4MBFlash-sdkconfig.defaults

@@ -336,11 +336,11 @@ CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=40
 CONFIG_ESP32_WIFI_STATIC_TX_BUFFER=y
 CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=0
 CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM=12
-# CONFIG_ESP32_WIFI_CSI_ENABLED is not set
-CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
-CONFIG_ESP32_WIFI_TX_BA_WIN=6
-CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
-CONFIG_ESP32_WIFI_RX_BA_WIN=16
+CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=n
+CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=n
+
+
+
 CONFIG_ESP32_WIFI_NVS_ENABLED=y
 CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y
 # CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set

+ 4 - 5
build-scripts/SqueezeAmp8MBFlash-sdkconfig.defaults

@@ -343,11 +343,10 @@ CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=40
 CONFIG_ESP32_WIFI_STATIC_TX_BUFFER=y
 CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=0
 CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM=12
-# CONFIG_ESP32_WIFI_CSI_ENABLED is not set
-CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
-CONFIG_ESP32_WIFI_TX_BA_WIN=6
-CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
-CONFIG_ESP32_WIFI_RX_BA_WIN=16
+CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=n
+CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=n
+
+
 CONFIG_ESP32_WIFI_NVS_ENABLED=y
 CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y
 # CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set

+ 3 - 3
components/codecs/CMakeLists.txt

@@ -1,10 +1,10 @@
 idf_component_register(SRC_DIRS . 
-					   INCLUDE_DIRS .  ./inc  inc/alac inc/faad2 inc/FLAC  inc/helix-aac inc/mad inc/ogg inc/opus inc/opusfile inc/resample16 inc/soxr inc/vorbis
+					   INCLUDE_DIRS .  ./inc  inc/alac inc/FLAC  inc/helix-aac inc/mad inc/ogg inc/opus inc/opusfile inc/resample16 inc/soxr inc/vorbis
 					   PRIV_REQUIRES newlib
 )
 
 add_prebuilt_library(libmad 		lib/libmad.a)
-add_prebuilt_library(libesp-flac 	lib/libesp-flac.a ) 
+add_prebuilt_library(libFLAC 		lib/libFLAC.a ) 
 add_prebuilt_library(libhelix-aac 	lib/libhelix-aac.a ) 
 add_prebuilt_library(libvorbisidec 	lib/libvorbisidec.a ) 
 add_prebuilt_library(libogg 		lib/libogg.a )
@@ -14,7 +14,7 @@ add_prebuilt_library(libsoxr 		lib/libsoxr.a )
 add_prebuilt_library(libopusfile 	lib/libopusfile.a ) 
 add_prebuilt_library(libopus 		lib/libopus.a ) 
 target_link_libraries(${COMPONENT_LIB} PRIVATE libmad)
-target_link_libraries(${COMPONENT_LIB} PRIVATE libesp-flac)
+target_link_libraries(${COMPONENT_LIB} PRIVATE libFLAC)
 target_link_libraries(${COMPONENT_LIB} PRIVATE libhelix-aac)
 target_link_libraries(${COMPONENT_LIB} PRIVATE libvorbisidec)
 

+ 5 - 7
components/codecs/component.mk

@@ -4,23 +4,21 @@
 # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
 COMPONENT_ADD_LDFLAGS=-l$(COMPONENT_NAME) 	\
 	$(COMPONENT_PATH)/lib/libmad.a 			\
-	$(COMPONENT_PATH)/lib/libesp-flac.a 	\
+	$(COMPONENT_PATH)/lib/libFLAC.a			\
 	$(COMPONENT_PATH)/lib/libhelix-aac.a 	\
 	$(COMPONENT_PATH)/lib/libvorbisidec.a	\
 	$(COMPONENT_PATH)/lib/libogg.a			\
 	$(COMPONENT_PATH)/lib/libalac.a			\
 	$(COMPONENT_PATH)/lib/libresample16.a	\
-	$(COMPONENT_PATH)/lib/libsoxr.a			\
 	$(COMPONENT_PATH)/lib/libopusfile.a		\
 	$(COMPONENT_PATH)/lib/libopus.a 		
-		
+	
+	#$(COMPONENT_PATH)/lib/libFLAC.a
+	#$(COMPONENT_PATH)/lib/libesp-flac.a
+	#$(COMPONENT_PATH)/lib/libsoxr.a		
 	#$(COMPONENT_PATH)/lib/libfaad.a 	
 	#$(COMPONENT_PATH)/lib/libvorbisidec.a
 	#$(COMPONENT_PATH)/lib/libesp-opus.a 
 	#$(COMPONENT_PATH)/lib/libogg.a
 	#$(COMPONENT_PATH)/lib/libesp-tremor.a
 	#$(COMPONENT_PATH)/lib/libesp-ogg-container.a
-	
-COMPONENT_ADD_INCLUDEDIRS := /inc
-	
-	

BIN
components/codecs/lib/libFLAC.a


BIN
components/codecs/lib/libesp-flac.a


BIN
components/codecs/lib/libesp-ogg-container.a


BIN
components/codecs/lib/libesp-tremor.a


BIN
components/codecs/lib/libesp_processing.a


BIN
components/codecs/lib/libfaad.a


+ 34 - 8
components/squeezelite/flac.c

@@ -36,6 +36,7 @@
 
 struct flac {
 	FLAC__StreamDecoder *decoder;
+	u8_t container;
 #if !LINKALL
 	// FLAC symbols to be dynamically loaded
 	const char **FLAC__StreamDecoderErrorStatusString;
@@ -55,6 +56,18 @@ struct flac {
 		FLAC__StreamDecoderErrorCallback error_callback,
 		void *client_data
 	);
+	FLAC__StreamDecoderInitStatus (* FLAC__stream_decoder_init_ogg_stream)(
+		FLAC__StreamDecoder *decoder,
+		FLAC__StreamDecoderReadCallback read_callback,
+		FLAC__StreamDecoderSeekCallback seek_callback,
+		FLAC__StreamDecoderTellCallback tell_callback,
+		FLAC__StreamDecoderLengthCallback length_callback,
+		FLAC__StreamDecoderEofCallback eof_callback,
+		FLAC__StreamDecoderWriteCallback write_callback,
+		FLAC__StreamDecoderMetadataCallback metadata_callback,
+		FLAC__StreamDecoderErrorCallback error_callback,
+		void *client_data
+	);
 	FLAC__bool (* FLAC__stream_decoder_process_single)(FLAC__StreamDecoder *decoder);
 	FLAC__StreamDecoderState (* FLAC__stream_decoder_get_state)(const FLAC__StreamDecoder *decoder);
 #endif
@@ -220,18 +233,30 @@ static void error_cb(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErro
 	LOG_INFO("flac error: %s", FLAC_A(f, StreamDecoderErrorStatusString)[status]);
 }
 
+static void flac_close(void) {
+	FLAC(f, stream_decoder_delete, f->decoder);
+	f->decoder = NULL;
+}
+
 static void flac_open(u8_t sample_size, u8_t sample_rate, u8_t channels, u8_t endianness) {
+	if ( f->decoder && f->container != sample_size ) {
+		flac_close();
+	}
+	
+	f->container = sample_size;
+	
 	if (f->decoder) {
 		FLAC(f, stream_decoder_reset, f->decoder);
 	} else {
 		f->decoder = FLAC(f, stream_decoder_new);
 	}
-	FLAC(f, stream_decoder_init_stream, f->decoder, &read_cb, NULL, NULL, NULL, NULL, &write_cb, NULL, &error_cb, NULL);
-}
-
-static void flac_close(void) {
-	FLAC(f, stream_decoder_delete, f->decoder);
-	f->decoder = NULL;
+	
+	if ( f->container == 'o' ) {
+		LOG_DEBUG("ogg/flac container - using init_ogg_stream");
+		FLAC(f, stream_decoder_init_ogg_stream, f->decoder, &read_cb, NULL, NULL, NULL, NULL, &write_cb, NULL, &error_cb, NULL);
+	} else {
+		FLAC(f, stream_decoder_init_stream, f->decoder, &read_cb, NULL, NULL, NULL, NULL, &write_cb, NULL, &error_cb, NULL);
+	}
 }
 
 static decode_state flac_decode(void) {
@@ -267,6 +292,7 @@ static bool load_flac() {
 	f->FLAC__stream_decoder_reset = dlsym(handle, "FLAC__stream_decoder_reset");
 	f->FLAC__stream_decoder_delete = dlsym(handle, "FLAC__stream_decoder_delete");
 	f->FLAC__stream_decoder_init_stream = dlsym(handle, "FLAC__stream_decoder_init_stream");
+	f->FLAC__stream_decoder_init_ogg_stream = dlsym(handle, "FLAC__stream_decoder_init_ogg_stream");
 	f->FLAC__stream_decoder_process_single = dlsym(handle, "FLAC__stream_decoder_process_single");
 	f->FLAC__stream_decoder_get_state = dlsym(handle, "FLAC__stream_decoder_get_state");
 
@@ -284,7 +310,7 @@ static bool load_flac() {
 struct codec *register_flac(void) {
 	static struct codec ret = { 
 		'f',          // id
-		"flc",        // types
+		"ogf,flc",        // types
 		16384,        // min read
 		204800,       // min space
 		flac_open,    // open
@@ -303,6 +329,6 @@ struct codec *register_flac(void) {
 		return NULL;
 	}
 
-	LOG_INFO("using flac to decode flc");
+	LOG_INFO("using flac to decode ogf,flc");
 	return &ret;
 }