Skip to content

Commit 03d7175

Browse files
Use the flac patches from vlsi (#89)
* Use the flac patches from vlsi * Less branching
1 parent 4f9689e commit 03d7175

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

src/ESP32_VS1053_Stream.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,12 @@ bool ESP32_VS1053_Stream::startDecoder(const uint8_t CS, const uint8_t DCS, cons
147147
_vs1053->begin();
148148
_vs1053->switchToMp3Mode();
149149
if (_vs1053->getChipVersion() == 4)
150-
_vs1053->loadDefaultVs1053Patches();
150+
{
151+
log_i("Patching vs1053 firmware");
152+
_vs1053->loadUserCode(PATCHES_FLAC, PATCHES_FLAC_SIZE);
153+
}
151154
setVolume(_volume);
152-
if (!_ringbuffer_handle)
153-
_allocateRingbuffer();
155+
_allocateRingbuffer();
154156
return true;
155157
}
156158

@@ -966,6 +968,10 @@ void ESP32_VS1053_Stream::_readBitRate()
966968
_codec = CODEC_OGG;
967969
break;
968970

971+
case 0x664C:
972+
_codec = CODEC_FLAC;
973+
break;
974+
969975
default:
970976
if ((hdat1 & 0xFFE0) == 0xFFE0)
971977
_codec = CODEC_MP3;
@@ -997,7 +1003,7 @@ void ESP32_VS1053_Stream::_readBitRate()
9971003
bitrate = bitrateTable[version == 3 ? 0 : 1][brIndex];
9981004
}
9991005
else
1000-
bitrate = (hdat0 * 8) / 1000;
1006+
bitrate = (_codec == CODEC_FLAC) ? 0 : (hdat0 * 8) / 1000;
10011007

10021008
if (bitrate != _bitrate)
10031009
{
@@ -1008,11 +1014,9 @@ void ESP32_VS1053_Stream::_readBitRate()
10081014

10091015
const char *ESP32_VS1053_Stream::_codecName(uint8_t codec)
10101016
{
1011-
const char *_names[9] = {"UNKNOWN", "ADTS", "ADIF", "MP4", "WAV", "WMA", "MIDI", "MP3", "OGG"};
1017+
const char *name[] = {"UNKNOWN", "ADTS", "ADIF", "MP4", "WAV", "WMA", "MIDI", "MP3", "OGG", "FLAC"};
10121018

1013-
if (codec >= sizeof(_names) / sizeof(_names[0]))
1014-
return _names[0];
1015-
return _names[codec];
1019+
return name[(codec >= sizeof(name) / sizeof(name[0])) ? 0 : codec];
10161020
}
10171021

10181022
void ESP32_VS1053_Stream::setCodecCB(codec_callback_t cb)

src/ESP32_VS1053_Stream.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class ESP32_VS1053_Stream
143143
CODEC_MIDI,
144144
CODEC_MP3,
145145
CODEC_OGG,
146+
CODEC_FLAC
146147
};
147148

148149
uint8_t _codec = CODEC_UNKNOWN;

vs1053.pdf

859 KB
Binary file not shown.

vs1053b-patches.pdf

202 KB
Binary file not shown.

0 commit comments

Comments
 (0)