Skip to content

Commit 974fa46

Browse files
authored
reduce maxFrameSize for wav
1 parent ed1edd2 commit 974fa46

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/Audio.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*
44
* Created on: Oct 26.2018
55
*
6-
* Version 2.0.6r
7-
* Updated on: Nov 18.2022
6+
* Version 2.0.6s
7+
* Updated on: Nov 21.2022
88
* Author: Wolle (schreibfaul1)
99
*
1010
*/
@@ -2865,16 +2865,11 @@ void Audio::processLocalFile() {
28652865
byteCounter = 0;
28662866
pos_stsz = 0;
28672867
if(m_codec == CODEC_M4A) pos_stsz = seek_m4a_stsz(&stszEntries); // returns the pos of atom stsz
2868-
log_i("pos_stsz %x, stszEntries %d", pos_stsz, stszEntries);
28692868
return;
28702869
}
28712870
(void) pos_stsz;
28722871

2873-
#ifdef CONFIG_IDF_TARGET_ESP32S3
2874-
availableBytes = maxFrameSize * 4;
2875-
#else // Audiobuffer throttle - - -
2876-
availableBytes = maxFrameSize; // reduce blocksize because PSRAM is too slow
2877-
#endif
2872+
availableBytes = 16 * 1024;
28782873

28792874
availableBytes = min(availableBytes, InBuff.writeSpace());
28802875
availableBytes = min(availableBytes, audiofile.size() - byteCounter);
@@ -2891,14 +2886,16 @@ void Audio::processLocalFile() {
28912886
byteCounter += bytesAddedToBuffer; // Pull request #42
28922887
InBuff.bytesWritten(bytesAddedToBuffer);
28932888
}
2894-
28952889
if(!f_stream){
28962890
if(m_controlCounter != 100) {
2897-
if(InBuff.bufferFilled() > maxFrameSize){ // read the file header first
2891+
if(InBuff.bufferFilled() > maxFrameSize){ // read the file header first
28982892
InBuff.bytesWasRead(readAudioHeader(InBuff.bufferFilled()));
28992893
}
29002894
return;
29012895
}
2896+
# ifndef CONFIG_IDF_TARGET_ESP32S
2897+
if((InBuff.freeSpace() > maxFrameSize) && (m_file_size - byteCounter) > maxFrameSize) return;
2898+
# endif
29022899
else{
29032900
f_stream = true;
29042901
AUDIO_INFO("stream ready");
@@ -2966,11 +2963,10 @@ void Audio::processLocalFile() {
29662963
static uint8_t cnt = 0;
29672964
uint8_t compression;
29682965
if(m_codec == CODEC_WAV) compression = 1;
2969-
if(m_codec == CODEC_FLAC) compression = 2;
2970-
compression = 6;
2966+
else if(m_codec == CODEC_FLAC) compression = 2;
2967+
else compression = 3;
29712968
cnt++;
29722969
if(cnt == compression){playAudioData(); cnt = 0;}
2973-
playAudioData();
29742970
}
29752971
return;
29762972
}

src/Audio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Audio.h
33
*
44
* Created on: Oct 28,2018
5-
* Updated on: Nov 18,2022
5+
* Updated on: Nov 21,2022
66
* Author: Wolle (schreibfaul1)
77
*/
88

@@ -469,7 +469,7 @@ class Audio : private AudioBuffer{
469469
std::vector<char*> m_playlistURL; // m3u8 streamURLs buffer
470470
std::vector<uint32_t> m_hashQueue;
471471

472-
const size_t m_frameSizeWav = 1024 * 8;
472+
const size_t m_frameSizeWav = 1024;
473473
const size_t m_frameSizeMP3 = 1600;
474474
const size_t m_frameSizeAAC = 1600;
475475
const size_t m_frameSizeFLAC = 4096 * 4;

0 commit comments

Comments
 (0)