Merge remote-tracking branch 'origin/master-cmake' into master-cmake

This commit is contained in:
Sebastien
2021-04-21 13:27:36 -04:00
4 changed files with 21 additions and 10 deletions

View File

@@ -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);

View File

@@ -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;
}