Unverified Commit 691a12fa authored by Wolle's avatar Wolle Committed by GitHub

fix #215 CORRUPT HEAP error when destructor called

parent b77c5b99
......@@ -198,22 +198,21 @@ Audio::Audio(bool internalDAC /* = false */, i2s_dac_mode_t channelEnabled /* =
}
//---------------------------------------------------------------------------------------------------------------------
void Audio::initInBuff() {
static bool f_already_done = false;
if(!f_already_done) {
if(!m_f_initInbuffOnce) {
size_t size = InBuff.init();
if(size == m_buffSizeRAM - m_resBuffSizeRAM) {
sprintf(chbuf, "PSRAM not found, inputBufferSize: %u bytes", size - 1);
if(audio_info)
audio_info(chbuf);
m_f_psram = false;
f_already_done = true;
m_f_initInbuffOnce = true;
}
if(size == m_buffSizePSRAM - m_resBuffSizePSRAM) {
sprintf(chbuf, "PSRAM found, inputBufferSize: %u bytes", size - 1);
if(audio_info)
audio_info(chbuf);
m_f_psram = true;
f_already_done = true;
m_f_initInbuffOnce = true;
}
}
changeMaxBlockSize(1600); // default size mp3 or aac
......@@ -254,8 +253,11 @@ esp_err_t Audio::i2s_mclk_pin_select(const uint8_t pin) {
}
//---------------------------------------------------------------------------------------------------------------------
Audio::~Audio() {
I2Sstop(m_i2s_num);
InBuff.~AudioBuffer();
//I2Sstop(m_i2s_num);
//InBuff.~AudioBuffer(); #215 the AudioBuffer is automatically destroyed by the destructor
m_f_initInbuffOnce = false;
setDefaults();
if(m_playlistBuff) {free(m_playlistBuff); m_playlistBuff = NULL;}
}
//---------------------------------------------------------------------------------------------------------------------
void Audio::setDefaults() {
......@@ -629,11 +631,8 @@ bool Audio::connecttoSD(const char* path) {
bool Audio::connecttoFS(fs::FS &fs, const char* path) {
if(strlen(path)>255) return false;
char audioName[256];
setDefaults(); // free buffers an set defaults
memcpy(audioName, path, strlen(path)+1);
if(audioName[0] != '/'){
for(int i = 255; i > 0; i--){
......
......@@ -2,7 +2,7 @@
* Audio.h
*
* Created on: Oct 26,2018
* Updated on: Oct 5,2021
* Updated on: Oct 27,2021
* Author: Wolle (schreibfaul1)
*/
......@@ -418,6 +418,7 @@ private:
bool m_f_m3u8data = false; // used in processM3U8entries
bool m_f_Log = true; // if m3u8: log is cancelled
bool m_f_continue = false; // next m3u8 chunk is available
bool m_f_initInbuffOnce = false; // init InBuff only once
i2s_dac_mode_t m_f_channelEnabled = I2S_DAC_CHANNEL_LEFT_EN; // internal DAC on GPIO26 for M5StickC/Plus
uint32_t m_audioFileDuration = 0;
float m_audioCurrentTime = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment