diff --git a/src/Audio.cpp b/src/Audio.cpp index 2a3e7b6d..835787c3 100644 --- a/src/Audio.cpp +++ b/src/Audio.cpp @@ -3,7 +3,7 @@ * * Created on: Oct 27.2018 * - * Version 3.0.12m + * Version 3.0.12n * Updated on: Sep 09.2024 * Author: Wolle (schreibfaul1) * @@ -2243,27 +2243,28 @@ size_t Audio::process_m3u8_ID3_Header(uint8_t* packet) { } //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ uint32_t Audio::stopSong() { - uint32_t pos = 0; - if(m_f_running) { - m_f_running = false; - if(m_dataMode == AUDIO_LOCALFILE) { - m_streamType = ST_NONE; - pos = getFilePos() - inBufferFilled(); + m_f_lockInBuffer = true; // wait for the decoding to finish + while(m_f_audioTaskIsDecoding) vTaskDelay(1); + uint32_t pos = 0; + if(m_f_running) { + m_f_running = false; + if(m_dataMode == AUDIO_LOCALFILE) { + m_streamType = ST_NONE; + pos = getFilePos() - inBufferFilled(); + } + if(_client->connected()) _client->stop(); } - if(_client->connected()) _client->stop(); - } - if(audiofile) { - // added this before putting 'm_f_localfile = false' in stopSong(); shoulf never occur.... - AUDIO_INFO("Closing audio file \"%s\"", audiofile.name()); - audiofile.close(); - } - memset(m_outBuff, 0, m_outbuffSize); // Clear OutputBuffer - memset(m_filterBuff, 0, sizeof(m_filterBuff)); // Clear FilterBuffer - m_validSamples = 0; - m_audioCurrentTime = 0; - m_audioFileDuration = 0; - m_codec = CODEC_NONE; - + if(audiofile) { + // added this before putting 'm_f_localfile = false' in stopSong(); shoulf never occur.... + AUDIO_INFO("Closing audio file \"%s\"", audiofile.name()); + audiofile.close(); + } + memset(m_filterBuff, 0, sizeof(m_filterBuff)); // Clear FilterBuffer + m_validSamples = 0; + m_audioCurrentTime = 0; + m_audioFileDuration = 0; + m_codec = CODEC_NONE; + m_f_lockInBuffer = false; return pos; } //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -4409,7 +4410,7 @@ void Audio::setDecoderItems() { } //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ int Audio::sendBytes(uint8_t* data, size_t len) { - + if(!m_f_running) return 0; // guard int32_t bytesLeft; static bool f_setDecodeParamsOnce = true; int nextSync = 0; diff --git a/src/Audio.h b/src/Audio.h index 69c503c0..527a35a6 100644 --- a/src/Audio.h +++ b/src/Audio.h @@ -3,7 +3,7 @@ * * Created on: Oct 28,2018 * - * Version 3.0.12m + * Version 3.0.12n * Updated on: Sep 09.2024 * Author: Wolle (schreibfaul1) */ diff --git a/src/aac_decoder/libfaad/neaacdec.cpp b/src/aac_decoder/libfaad/neaacdec.cpp index e22e7ead..3c3409ac 100644 --- a/src/aac_decoder/libfaad/neaacdec.cpp +++ b/src/aac_decoder/libfaad/neaacdec.cpp @@ -9918,6 +9918,7 @@ uint8_t window_grouping_info(NeAACDecStruct_t* hDecoder, ic_stream_t* ics) { if(hDecoder->object_type == LD) { if(hDecoder->frameLength == 512) { for(i = 0; i < ics->num_swb; i++) { +log_e("i %i", i); ics->sect_sfb_offset[0][i] = swb_offset_512_window[sf_index][i]; ics->swb_offset[i] = swb_offset_512_window[sf_index][i]; }