Skip to content

Commit

Permalink
ESP32-audioI2S crashes on arduino-esp32 v3.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
schreibfaul1 committed Oct 29, 2024
1 parent 3ad451a commit 98488c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
25 changes: 15 additions & 10 deletions src/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created on: Oct 28.2018
*
* Version 3.0.13h
* Version 3.0.13i
* Updated on: Oct 29.2024
* Author: Wolle (schreibfaul1)
*
Expand Down Expand Up @@ -168,15 +168,6 @@ Audio::Audio(bool internalDAC /* = false */, uint8_t channelEnabled /* = I2S_SLO
#endif
#define AUDIO_INFO(...) { snprintf(m_ibuff, m_ibuffSize, __VA_ARGS__); if(audio_info) audio_info(m_ibuff); }

m_f_psramFound = psramInit();
if(m_f_psramFound) m_chbufSize = 4096; else m_chbufSize = 512 + 64;
if(m_f_psramFound) m_ibuffSize = 4096; else m_ibuffSize = 512 + 64;
m_lastHost = (char*) x_ps_malloc(2048);
m_outBuff = (int16_t*)x_ps_malloc(m_outbuffSize * sizeof(int16_t));
m_chbuf = (char*) x_ps_malloc(m_chbufSize);
m_ibuff = (char*) x_ps_malloc(m_ibuffSize);
if(!m_chbuf || !m_lastHost || !m_outBuff || !m_ibuff) log_e("oom");

clientsecure.setInsecure();
m_f_channelEnabled = channelEnabled;
m_f_internalDAC = internalDAC;
Expand Down Expand Up @@ -4819,6 +4810,20 @@ void Audio::printDecodeError(int r) {
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool Audio::setPinout(uint8_t BCLK, uint8_t LRC, uint8_t DOUT, int8_t MCLK) {

m_f_psramFound = psramInit();
x_ps_free(m_chbuf);
x_ps_free(m_ibuff);
x_ps_free(m_outBuff);
x_ps_free(m_lastHost);
if(m_f_psramFound) m_chbufSize = 4096; else m_chbufSize = 512 + 64;
if(m_f_psramFound) m_ibuffSize = 4096; else m_ibuffSize = 512 + 64;
m_lastHost = (char*) x_ps_malloc(2048);
m_outBuff = (int16_t*)x_ps_malloc(m_outbuffSize * sizeof(int16_t));
m_chbuf = (char*) x_ps_malloc(m_chbufSize);
m_ibuff = (char*) x_ps_malloc(m_ibuffSize);
if(!m_chbuf || !m_lastHost || !m_outBuff || !m_ibuff) log_e("oom");

esp_err_t result = ESP_OK;

if(m_f_internalDAC) {
Expand Down
6 changes: 5 additions & 1 deletion src/Audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Created on: Oct 28,2018
*
* Version 3.0.13h
* Version 3.0.13i
* Updated on: Oct 29.2024
* Author: Wolle (schreibfaul1)
*/
Expand Down Expand Up @@ -482,6 +482,10 @@ uint64_t bigEndian(uint8_t* base, uint8_t numBytes, uint8_t shiftLeft = 8) {
strcpy(ps_str, str);
return ps_str;
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
void x_ps_free(void* b){
if(b){free(b); b = NULL;}
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
// Function to reverse the byte order of a 32-bit value (big-endian to little-endian)
uint32_t bswap32(uint32_t x) {
Expand Down

0 comments on commit 98488c5

Please sign in to comment.