diff --git a/README.md b/README.md index dc420670..a97e2f08 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,7 @@ The NVS parameter "i2c_config" set the i2c's gpio used for generic purpose (e.g. ``` sda=,scl=[,port=0|1][,speed=] ``` +Please note that you can not use the same GPIO or port as the DAC ### SPI The NVS parameter "spi_config" set the spi's gpio used for generic purpose (e.g. display). Leave it blank to disable SPI usage. The DC parameter is needed for displays. Syntax is ``` @@ -144,6 +145,8 @@ The parameter "dac_controlset" allows definition of simple commands to be sent o This is standard JSON notation, so if you are not familiar with it, Google is your best friend. Be aware that the '...' means you can have as many entries as you want, it's not part of the syntax. Every section is optional, but it does not make sense to set i2c in the 'dac_config' parameter and not setting anything here. The parameter 'mode' allows to *or* the register with the value or to *and* it. Don't set 'mode' if you simply want to write. **Note that all values must be decimal**. You can use a validator like [this](https://jsonlint.com) to verify your syntax NB: For well-known configuration, this is ignored + +Please note that you can not use the same GPIO or port as the I2C ### SPDIF The NVS parameter "spdif_config" sets the i2s's gpio needed for SPDIF. diff --git a/components/squeezelite/external/dac_external.c b/components/squeezelite/external/dac_external.c index 0694ab51..e955dd21 100644 --- a/components/squeezelite/external/dac_external.c +++ b/components/squeezelite/external/dac_external.c @@ -39,7 +39,7 @@ static bool init(char *config, int i2c_port_num, i2s_config_t *i2s_config) { char *p; i2c_addr = adac_init(config, i2c_port_num); - if (!i2c_addr) return false; + if (!i2c_addr) return true; ESP_LOGI(TAG, "DAC on I2C @%d", i2c_addr); diff --git a/components/squeezelite/helix-aac.c b/components/squeezelite/helix-aac.c index f2a48287..5ad72cd9 100644 --- a/components/squeezelite/helix-aac.c +++ b/components/squeezelite/helix-aac.c @@ -152,20 +152,28 @@ static int read_mp4_header(unsigned long *samplerate_p, unsigned char *channels_ return -1; } int desc_len = mp4_desc_length(&ptr); - info.profile = *ptr >> 3; + int AOT = *ptr >> 3; + info.profile = AAC_PROFILE_LC; info.sampRateCore = (*ptr++ & 0x07) << 1; info.sampRateCore |= (*ptr >> 7) & 0x01; info.sampRateCore = rates[info.sampRateCore]; - info.nChans = (*ptr++ & 0x7f) >> 3; - *channels_p = info.nChans; - if (desc_len > 2 && ((ptr[0] << 3) | (ptr[1] >> 5)) == 0x2b7 && (ptr[1] & 0x1f) == 0x05 && (ptr[2] & 0x80)) { - *samplerate_p = rates[(ptr[2] & 0x78) >> 3]; - LOG_WARN("AAC SBR mode activated => high CPU consumption expected, please use LMS proxy to mitigate"); - } else { + info.nChans = (*ptr & 0x7f) >> 3; + *channels_p = info.nChans; + // Note that 24 bits frequencies are not handled + if (AOT == 5 || AOT == 29) { + *samplerate_p = rates[((ptr[0] & 0x03) << 1) | (ptr[1] >> 7)]; + LOG_WARN("AAC stream with SBR => high CPU required (use LMS proxied mode)"); + } else if (desc_len > 2 && ((ptr[1] << 3) | (ptr[2] >> 5)) == 0x2b7 && (ptr[2] & 0x1f) == 0x05 && (ptr[3] & 0x80)) { + *samplerate_p = rates[(ptr[3] & 0x78) >> 3]; + LOG_WARN("AAC stream with extended SBR => high CPU required (use LMS proxied mode)"); + } else if (AOT == 2) { *samplerate_p = info.sampRateCore; + } else { + *samplerate_p = 44100; + LOG_ERROR("AAC audio object type %d not handled", AOT); } HAAC(a, SetRawBlockParams, a->hAac, 0, &info); - LOG_DEBUG("playable aac track: %u (p:%x, r:%d, c:%d)", trak, info.profile, info.sampRateCore, info.nChans); + LOG_DEBUG("playable aac track: %u (p:%x, r:%d, c:%d, desc_len:%d)", trak, AOT, info.sampRateCore, info.nChans, desc_len); play = trak; } diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 8e817488..732ee2d3 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -87,7 +87,7 @@ menu "Squeezelite-ESP32" default "TWATCH" if TWATCH2020 default "I2S-4MFlash" if !A1S && !SQUEEZEAMP && !DAC32 && !TWATCH2020 # AGGREGATES - begin - # these parameters are "aggregates" that take precedence. The must have a default value + # these parameters are "aggregates" that take precedence. They must have a default value config DAC_CONFIG string default "model=TAS57xx,bck=33,ws=25,do=32,sda=27,scl=26,mute=14:0" if SQUEEZEAMP