Commit a0747df0 authored by schreibfaul1's avatar schreibfaul1

localFile: allow (flac).ogg, (opus).ogg and *.oga

parent 74b7c4d8
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
* *
* Created on: Oct 26.2018 * Created on: Oct 26.2018
* *
* Version 3.0.3b * Version 3.0.4
* Updated on: Jul 20.2023 * Updated on: Jul 23.2023
* Author: Wolle (schreibfaul1) * Author: Wolle (schreibfaul1)
* *
*/ */
...@@ -764,7 +764,8 @@ bool Audio::connecttoFS(fs::FS &fs, const char* path, int32_t resumeFilePos) { ...@@ -764,7 +764,8 @@ bool Audio::connecttoFS(fs::FS &fs, const char* path, int32_t resumeFilePos) {
if(endsWith(afn, ".wav")) m_codec = CODEC_WAV; if(endsWith(afn, ".wav")) m_codec = CODEC_WAV;
if(endsWith(afn, ".flac")) m_codec = CODEC_FLAC; if(endsWith(afn, ".flac")) m_codec = CODEC_FLAC;
if(endsWith(afn, ".opus")) m_codec = CODEC_OPUS; if(endsWith(afn, ".opus")) m_codec = CODEC_OPUS;
if(endsWith(afn, ".ogg")) m_codec = CODEC_VORBIS; if(endsWith(afn, ".ogg")) m_codec = CODEC_OGG;
if(endsWith(afn, ".oga")) m_codec = CODEC_OGG;
if(m_codec == CODEC_NONE) AUDIO_INFO("The %s format is not supported", afn + dotPos); if(m_codec == CODEC_NONE) AUDIO_INFO("The %s format is not supported", afn + dotPos);
...@@ -2808,6 +2809,14 @@ void Audio::processLocalFile() { ...@@ -2808,6 +2809,14 @@ void Audio::processLocalFile() {
InBuff.bytesWritten(bytesAddedToBuffer); InBuff.bytesWritten(bytesAddedToBuffer);
} }
if(!f_stream){ if(!f_stream){
if(m_codec == CODEC_OGG){ // log_i("determine correct codec here");
uint8_t codec = determineOggCodec(InBuff.getReadPtr(), maxFrameSize);
if(codec == CODEC_FLAC) {m_codec = CODEC_FLAC; initializeDecoder(); return;}
if(codec == CODEC_OPUS) {m_codec = CODEC_OPUS; initializeDecoder(); return;}
if(codec == CODEC_VORBIS) {m_codec = CODEC_VORBIS; initializeDecoder(); return;}
stopSong();
return;
}
if(m_controlCounter != 100) { if(m_controlCounter != 100) {
if((millis() - ctime) > timeout) { if((millis() - ctime) > timeout) {
log_e("audioHeader reading timeout"); log_e("audioHeader reading timeout");
...@@ -3047,14 +3056,7 @@ void Audio::processWebFile() { ...@@ -3047,14 +3056,7 @@ void Audio::processWebFile() {
return; return;
} }
if(m_codec == CODEC_OGG){ // log_i("determine correct codec here");
uint8_t codec = determineOggCodec(InBuff.getReadPtr(), maxFrameSize);
if(codec == CODEC_FLAC) {m_codec = CODEC_FLAC; initializeDecoder(); return;}
if(codec == CODEC_OPUS) {m_codec = CODEC_OPUS; initializeDecoder(); return;}
if(codec == CODEC_VORBIS) {m_codec = CODEC_VORBIS; initializeDecoder(); return;}
stopSong();
return;
}
// we have a webfile, read the file header first - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // we have a webfile, read the file header first - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(m_controlCounter != 100){ if(m_controlCounter != 100){
...@@ -3065,6 +3067,15 @@ void Audio::processWebFile() { ...@@ -3065,6 +3067,15 @@ void Audio::processWebFile() {
return; return;
} }
if(m_codec == CODEC_OGG){ // log_i("determine correct codec here");
uint8_t codec = determineOggCodec(InBuff.getReadPtr(), maxFrameSize);
if(codec == CODEC_FLAC) {m_codec = CODEC_FLAC; initializeDecoder(); return;}
if(codec == CODEC_OPUS) {m_codec = CODEC_OPUS; initializeDecoder(); return;}
if(codec == CODEC_VORBIS) {m_codec = CODEC_VORBIS; initializeDecoder(); return;}
stopSong();
return;
}
// end of webfile reached? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // end of webfile reached? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(f_webFileDataComplete && InBuff.bufferFilled() < InBuff.getMaxBlockSize()){ if(f_webFileDataComplete && InBuff.bufferFilled() < InBuff.getMaxBlockSize()){
if(InBuff.bufferFilled()){ if(InBuff.bufferFilled()){
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* adapted to ESP32 * adapted to ESP32
* *
* Created on: Jul 03,2020 * Created on: Jul 03,2020
* Updated on: Apr 10,2023 * Updated on: Jul 23,2023
* *
* Author: Wolle * Author: Wolle
* *
...@@ -405,7 +405,9 @@ int8_t flacDecodeFrame(uint8_t *inbuf, int *bytesLeft){ ...@@ -405,7 +405,9 @@ int8_t flacDecodeFrame(uint8_t *inbuf, int *bytesLeft){
else{ else{
return ERR_FLAC_RESERVED_BLOCKSIZE_UNSUPPORTED; return ERR_FLAC_RESERVED_BLOCKSIZE_UNSUPPORTED;
} }
if(m_blockSize > 8192){ uint16_t maxBS = 8192;
if(psramFound()) maxBS = 8192 * 4;
if(m_blockSize > maxBS){
log_e("Error: blockSize too big ,%i bytes", m_blockSize); log_e("Error: blockSize too big ,%i bytes", m_blockSize);
return ERR_FLAC_BLOCKSIZE_TOO_BIG; return ERR_FLAC_BLOCKSIZE_TOO_BIG;
} }
......
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