fix #24
This commit is contained in:
@@ -1,2 +1,11 @@
|
||||
|
||||
if(CONFIG_SNAPCLIENT_ENABLE_ETHERNET)
|
||||
|
||||
idf_component_register(SRCS "eth_interface.c"
|
||||
INCLUDE_DIRS "include")
|
||||
|
||||
else()
|
||||
|
||||
idf_component_register()
|
||||
|
||||
endif()
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define USE_SAMPLE_INSERTION 0 // TODO: doesn't work as intended
|
||||
|
||||
#define SYNC_TASK_PRIORITY (configMAX_PRIORITIES - 1)
|
||||
#define SYNC_TASK_CORE_ID 1 // tskNO_AFFINITY
|
||||
|
||||
@@ -115,6 +117,11 @@ static esp_err_t player_setup_i2s(i2s_port_t i2sNum,
|
||||
i2sDmaBufCnt = __dmaBufCnt * CHNK_CTRL_CNT;
|
||||
i2sDmaBufMaxLen = __dmaBufLen;
|
||||
|
||||
#if USE_SAMPLE_INSERTION
|
||||
i2sDmaBufCnt = 128;
|
||||
i2sDmaBufMaxLen = 9;
|
||||
#endif
|
||||
|
||||
fi2s_clk = setting->sr * setting->ch * setting->bits * m_scale;
|
||||
|
||||
apll_normal_predefine[0] = setting->bits;
|
||||
@@ -170,7 +177,11 @@ static esp_err_t player_setup_i2s(i2s_port_t i2sNum,
|
||||
i2s_custom_driver_install(i2sNum, &i2s_config0, 0, NULL);
|
||||
i2s_custom_set_pin(i2sNum, &pin_config0);
|
||||
|
||||
#if CONFIG_AUDIO_BOARD_CUSTOM
|
||||
i2s_mclk_gpio_select(i2sNum, CONFIG_MASTER_I2S_MCLK_PIN);
|
||||
#else
|
||||
i2s_mclk_gpio_select(i2sNum, GPIO_NUM_0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1001,6 +1012,7 @@ static void player_task(void *pvParameters) {
|
||||
int initialSync = 0;
|
||||
int64_t avg = 0;
|
||||
int dir = 0;
|
||||
uint32_t dir_insert_sample = 0;
|
||||
int64_t buf_us = 0;
|
||||
pcm_chunk_fragment_t *fragment = NULL;
|
||||
size_t written;
|
||||
@@ -1379,6 +1391,18 @@ static void player_task(void *pvParameters) {
|
||||
continue;
|
||||
}
|
||||
|
||||
#if USE_SAMPLE_INSERTION // WIP: insert samples to adjust sync
|
||||
if ((enableControlLoop == true) &&
|
||||
(MEDIANFILTER_isFull(&shortMedianFilter))) {
|
||||
if (avg < -miniOffset) { // we are early
|
||||
dir = -1;
|
||||
dir_insert_sample = -1;
|
||||
} else if (avg > miniOffset) { // we are late
|
||||
dir = 1;
|
||||
dir_insert_sample = 1;
|
||||
}
|
||||
}
|
||||
#else // use APLL to adjust sync
|
||||
if ((enableControlLoop == true) &&
|
||||
(MEDIANFILTER_isFull(&shortMedianFilter))) {
|
||||
if ((shortMedian < -shortOffset) && (miniMedian < -miniOffset) &&
|
||||
@@ -1391,6 +1415,7 @@ static void player_task(void *pvParameters) {
|
||||
|
||||
adjust_apll(dir);
|
||||
}
|
||||
#endif
|
||||
|
||||
const uint32_t tmpCntInit = 1; // 250 // every 6s
|
||||
static uint32_t tmpcnt = 1;
|
||||
@@ -1406,9 +1431,10 @@ static void player_task(void *pvParameters) {
|
||||
|
||||
// ESP_LOGI (TAG, "%d, %lldus, %lldus %llds, %lld.%lldms",
|
||||
// dir, age, avg, sec, msec, usec);
|
||||
// ESP_LOGI(TAG, "%d, %lldus, %lldus, %lldus, q:%d", dir,
|
||||
// avg, shortMedian, miniMedian,
|
||||
// uxQueueMessagesWaiting(pcmChkQHdl)); ESP_LOGI( TAG, "8b f
|
||||
// ESP_LOGI(TAG, "%d, %lldus, %lldus, %lldus, q:%d", dir,
|
||||
// avg, shortMedian, miniMedian,
|
||||
// uxQueueMessagesWaiting(pcmChkQHdl));
|
||||
// ESP_LOGI( TAG, "8b f
|
||||
// %d b %d", heap_caps_get_free_size(MALLOC_CAP_8BIT |
|
||||
// MALLOC_CAP_INTERNAL),
|
||||
// heap_caps_get_largest_free_block(MALLOC_CAP_8BIT |
|
||||
@@ -1427,10 +1453,28 @@ static void player_task(void *pvParameters) {
|
||||
if (p_payload != NULL) {
|
||||
do {
|
||||
written = 0;
|
||||
|
||||
#if USE_SAMPLE_INSERTION
|
||||
uint32_t sampleSizeInBytes = 4 * 3;
|
||||
|
||||
if (dir_insert_sample == -1) {
|
||||
if (i2s_custom_write(I2S_NUM_0, p_payload,
|
||||
(size_t)sampleSizeInBytes, &written,
|
||||
portMAX_DELAY) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "i2s_playback_task: I2S write error %d", 1);
|
||||
}
|
||||
} else if (dir_insert_sample == 1) {
|
||||
size -= sampleSizeInBytes;
|
||||
}
|
||||
|
||||
dir_insert_sample = 0;
|
||||
#endif
|
||||
|
||||
if (i2s_custom_write(I2S_NUM_0, p_payload, (size_t)size, &written,
|
||||
portMAX_DELAY) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "i2s_playback_task: I2S write error %d", size);
|
||||
}
|
||||
|
||||
if (written < size) {
|
||||
ESP_LOGE(TAG, "i2s_playback_task: I2S didn't write all data");
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_wifi.h"
|
||||
#if CONFIG_SNAPCLIENT_ENABLE_ETHERNET
|
||||
#include "eth_interface.h"
|
||||
#endif
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include "freertos/task.h"
|
||||
@@ -2681,6 +2683,7 @@ void app_main(void) {
|
||||
gpio_config(&cfg);
|
||||
#endif
|
||||
|
||||
#if CONFIG_AUDIO_BOARD_CUSTOM
|
||||
// some codecs need i2s mclk for initialization
|
||||
i2s_config_t i2s_config0 = {
|
||||
.mode = I2S_MODE_MASTER | I2S_MODE_TX, // Only TX
|
||||
@@ -2701,7 +2704,9 @@ void app_main(void) {
|
||||
i2s_custom_driver_uninstall(I2S_NUM_0);
|
||||
i2s_custom_driver_install(I2S_NUM_0, &i2s_config0, 0, NULL);
|
||||
i2s_custom_set_pin(I2S_NUM_0, &pin_config0);
|
||||
|
||||
i2s_mclk_gpio_select(I2S_NUM_0, CONFIG_MASTER_I2S_MCLK_PIN);
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "Start codec chip");
|
||||
board_handle = audio_board_init();
|
||||
|
||||
@@ -194,9 +194,9 @@ CONFIG_SNAPCLIENT_ENABLE_ETHERNET=y
|
||||
CONFIG_SNAPCLIENT_USE_INTERNAL_ETHERNET=y
|
||||
# CONFIG_SNAPCLIENT_USE_DM9051 is not set
|
||||
# CONFIG_SNAPCLIENT_USE_W5500 is not set
|
||||
# CONFIG_SNAPCLIENT_ETH_PHY_IP101 is not set
|
||||
CONFIG_SNAPCLIENT_ETH_PHY_IP101=y
|
||||
# CONFIG_SNAPCLIENT_ETH_PHY_RTL8201 is not set
|
||||
CONFIG_SNAPCLIENT_ETH_PHY_LAN8720=y
|
||||
# CONFIG_SNAPCLIENT_ETH_PHY_LAN8720 is not set
|
||||
# CONFIG_SNAPCLIENT_ETH_PHY_DP83848 is not set
|
||||
# CONFIG_SNAPCLIENT_ETH_PHY_KSZ8041 is not set
|
||||
CONFIG_SNAPCLIENT_ETH_MDC_GPIO=23
|
||||
@@ -828,8 +828,8 @@ CONFIG_LWIP_TCP_MSS=1460
|
||||
CONFIG_LWIP_TCP_TMR_INTERVAL=250
|
||||
CONFIG_LWIP_TCP_MSL=60000
|
||||
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=11680
|
||||
CONFIG_LWIP_TCP_WND_DEFAULT=42340
|
||||
CONFIG_LWIP_TCP_RECVMBOX_SIZE=31
|
||||
CONFIG_LWIP_TCP_WND_DEFAULT=11680
|
||||
CONFIG_LWIP_TCP_RECVMBOX_SIZE=10
|
||||
CONFIG_LWIP_TCP_QUEUE_OOSEQ=y
|
||||
CONFIG_LWIP_TCP_SACK_OUT=y
|
||||
# CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set
|
||||
@@ -1388,8 +1388,8 @@ CONFIG_TCP_SYNMAXRTX=12
|
||||
CONFIG_TCP_MSS=1460
|
||||
CONFIG_TCP_MSL=60000
|
||||
CONFIG_TCP_SND_BUF_DEFAULT=11680
|
||||
CONFIG_TCP_WND_DEFAULT=42340
|
||||
CONFIG_TCP_RECVMBOX_SIZE=31
|
||||
CONFIG_TCP_WND_DEFAULT=11680
|
||||
CONFIG_TCP_RECVMBOX_SIZE=10
|
||||
CONFIG_TCP_QUEUE_OOSEQ=y
|
||||
# CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set
|
||||
CONFIG_TCP_OVERSIZE_MSS=y
|
||||
|
||||
1420
sdkconfig_adau1961
Normal file
1420
sdkconfig_adau1961
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user