Skip to content

Commit 26867c9

Browse files
committed
inline var in config
1 parent 7b99175 commit 26867c9

File tree

15 files changed

+56
-42
lines changed

15 files changed

+56
-42
lines changed

src/AudioCodecs/CodecWAV.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct WAVAudioInfo : AudioBaseInfo {
3131
uint32_t file_size=0;
3232
};
3333

34-
inline const char* wav_mime = "audio/wav";
34+
INLINE_VAR const char* wav_mime = "audio/wav";
3535

3636
/**
3737
* @brief Parser for Wav header data

src/AudioConfig.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,25 @@
3939
#define LOG_STREAM Serial
4040
#endif
4141

42-
#define CHECK_MEMORY()
43-
// #define CHECK_MEMORY() checkMemory(true)
4442
#define LOG_PRINTF_BUFFER_SIZE 256
4543
#define LOG_METHOD __PRETTY_FUNCTION__
4644

45+
// cheange USE_CHECK_MEMORY to 1 to activate memory checks
46+
#define USE_CHECK_MEMORY 0
47+
#if USE_CHECK_MEMORY
48+
# define CHECK_MEMORY()
49+
#else
50+
# define CHECK_MEMORY() checkMemory(true)
51+
#endif
52+
53+
// Change USE_INLINE_VARS to 0 if inline variables are not supported
54+
#define USE_INLINE_VARS 1
55+
#if USE_INLINE_VARS
56+
# define INLINE_VAR inline
57+
#else
58+
# define INLINE_VAR
59+
#endif
60+
4761
/**
4862
* -------------------------------------------------------------------------
4963
* @brief Common Default Settings that can usually be changed in the API

src/AudioHttp/HttpHeader.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ namespace audio_tools {
1313
// Class Configuration
1414

1515
// Define relevant header content
16-
inline const char* CONTENT_TYPE = "Content-Type";
17-
inline const char* CONTENT_LENGTH = "Content-Length";
18-
inline const char* CONNECTION = "Connection";
19-
inline const char* CON_CLOSE = "close";
20-
inline const char* CON_KEEP_ALIVE = "keep-alive";
21-
inline const char* TRANSFER_ENCODING = "Transfer-Encoding";
22-
inline const char* CHUNKED = "chunked";
23-
inline const char* ACCEPT = "Accept";
24-
inline const char* ACCEPT_ALL = "*/*";
25-
inline const char* SUCCESS = "Success";
26-
inline const char* USER_AGENT = "User-Agent";
27-
inline const char* DEFAULT_AGENT = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)";
28-
inline const char* HOST_C = "Host";
29-
inline const char* ACCEPT_ENCODING = "Accept-Encoding";
30-
inline const char* IDENTITY = "identity";
31-
inline const char* LOCATION = "Location";
16+
INLINE_VAR const char* CONTENT_TYPE = "Content-Type";
17+
INLINE_VAR const char* CONTENT_LENGTH = "Content-Length";
18+
INLINE_VAR const char* CONNECTION = "Connection";
19+
INLINE_VAR const char* CON_CLOSE = "close";
20+
INLINE_VAR const char* CON_KEEP_ALIVE = "keep-alive";
21+
INLINE_VAR const char* TRANSFER_ENCODING = "Transfer-Encoding";
22+
INLINE_VAR const char* CHUNKED = "chunked";
23+
INLINE_VAR const char* ACCEPT = "Accept";
24+
INLINE_VAR const char* ACCEPT_ALL = "*/*";
25+
INLINE_VAR const char* SUCCESS = "Success";
26+
INLINE_VAR const char* USER_AGENT = "User-Agent";
27+
INLINE_VAR const char* DEFAULT_AGENT = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)";
28+
INLINE_VAR const char* HOST_C = "Host";
29+
INLINE_VAR const char* ACCEPT_ENCODING = "Accept-Encoding";
30+
INLINE_VAR const char* IDENTITY = "identity";
31+
INLINE_VAR const char* LOCATION = "Location";
3232

3333

3434
// Http methods
35-
inline const char* methods[] = {"?","GET","HEAD","POST","PUT","DELETE","TRACE","OPTIONS","CONNECT","PATCH",nullptr};
35+
INLINE_VAR const char* methods[] = {"?","GET","HEAD","POST","PUT","DELETE","TRACE","OPTIONS","CONNECT","PATCH",nullptr};
3636

3737
/**
3838
* @brief A individual key - value header line

src/AudioI2S/I2SConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ enum I2SSignalType {
2121
PDM
2222
};
2323

24-
inline const char* i2s_formats[] = {"I2S_STD_FORMAT","I2S_LSB_FORMAT","I2S_MSB_FORMAT","I2S_PHILIPS_FORMAT","I2S_RIGHT_JUSTIFIED_FORMAT","I2S_LEFT_JUSTIFIED_FORMAT","I2S_PCM_LONG","I2S_PCM_SHORT"};
24+
INLINE_VAR const char* i2s_formats[] = {"I2S_STD_FORMAT","I2S_LSB_FORMAT","I2S_MSB_FORMAT","I2S_PHILIPS_FORMAT","I2S_RIGHT_JUSTIFIED_FORMAT","I2S_LEFT_JUSTIFIED_FORMAT","I2S_PCM_LONG","I2S_PCM_SHORT"};
2525

2626

2727
/**

src/AudioI2S/I2SNanoSenseBLE.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
namespace audio_tools {
1212

13-
inline const int i2s_buffer_size = 1024;
14-
inline NBuffer<uint8_t> i2s_buffer(i2s_buffer_size, 5);
13+
INLINE_VAR const int i2s_buffer_size = 1024;
14+
INLINE_VAR NBuffer<uint8_t> i2s_buffer(i2s_buffer_size, 5);
1515

1616
/**
1717
* @brief Mapping Frequency constants to available frequencies
@@ -21,7 +21,7 @@ struct Nano_BLE_freq_info {
2121
double freq; // in mhz
2222
};
2323

24-
inline const Nano_BLE_freq_info freq_table[] = {
24+
INLINE_VAR const Nano_BLE_freq_info freq_table[] = {
2525
{ I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV8, 32.0 / 8 },
2626
{ I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV10, 32 / 10 },
2727
{ I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV11, 32.0 / 11 },
@@ -45,7 +45,7 @@ struct Nano_BLE_ratio_info {
4545
double ratio;
4646
};
4747

48-
inline const Nano_BLE_ratio_info ratio_table[] = {
48+
INLINE_VAR const Nano_BLE_ratio_info ratio_table[] = {
4949
{ I2S_CONFIG_RATIO_RATIO_32X, 32.0 },
5050
{ I2S_CONFIG_RATIO_RATIO_48X, 48.0 },
5151
{ I2S_CONFIG_RATIO_RATIO_64X, 64.0 },
@@ -61,7 +61,7 @@ inline const Nano_BLE_ratio_info ratio_table[] = {
6161
* I2S Event handler
6262
*/
6363

64-
extern "C" inline void I2S_IRQHandler(void) {
64+
extern "C" INLINE_VAR void I2S_IRQHandler(void) {
6565
if(NRF_I2S->EVENTS_TXPTRUPD != 0) {
6666
// reading from buffer to pins
6767
NRF_I2S->TXD.PTR = (uint32_t) i2s_buffer.readEnd().address(); // last buffer was processed

src/AudioI2S/I2SRP2040.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace audio_tools {
1111

1212
#if !defined(ARDUINO_ARCH_MBED_RP2040)
13-
inline ::I2S I2S;
13+
INLINE_VAR ::I2S I2S;
1414
#endif
1515

1616

src/AudioI2S/I2SSTM32.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ class I2SBase {
143143
protected:
144144
I2SConfig cfg;
145145
I2SSettingsSTM32 i2s_stm32;
146-
inline static NBuffer<uint8_t> *p_tx_buffer=nullptr;
147-
inline static NBuffer<uint8_t> *p_rx_buffer=nullptr;
146+
INLINE_VAR static NBuffer<uint8_t> *p_tx_buffer=nullptr;
147+
INLINE_VAR static NBuffer<uint8_t> *p_rx_buffer=nullptr;
148148

149149
void deleteBuffers() {
150150
if (p_rx_buffer!=nullptr) {

src/AudioMetaData/AbstractMetaData.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ enum ID3TypeSelection { SELECT_ID3V1=0b001, SELECT_ID3V2=0b010, SELECT_ID3=0b011
1010
enum MetaDataType { Title, Artist, Album, Genre, Name, Description };
1111

1212
/// Test Description for meta info
13-
inline const char* MetaDataTypeStr[] = {"Title", "Artist", "Album", "Genre","Name", "Description"};
13+
INLINE_VAR const char* MetaDataTypeStr[] = {"Title", "Artist", "Album", "Genre","Name", "Description"};
1414

1515
/// Converts the MetaDataType to a string
16-
inline const char *toStr(MetaDataType t){
16+
INLINE_VAR const char *toStr(MetaDataType t){
1717
return MetaDataTypeStr[t];
1818
}
1919

src/AudioMetaData/MetaDataID3.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace audio_tools {
1515

1616
/// String array with genres
17-
inline const char *genres[] = { "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "Alternative Rock", "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno-Insdustiral", "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle", "Native US", "Cabaret", "New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", "Easy Listening", "Acoustic","Humour", "Speech", "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore", "Ballad", "Power Ballad", "Rhytmic Soul", "Freestyle", "Duet", "Punk Rock", "Drum Solo", "Acapella", "Euro-House", "Dance Hall", "Goa", "Drum & Bass", "Club-House", "Hardcore", "Terror", "Indie", "BritPop", "Negerpunk", "Polsk Punk", "Beat", "Christian Gangsta", "Heavy Metal", "Black Metal", "Crossover", "Contemporary C", "Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime", "JPop", "SynthPop" };
17+
INLINE_VAR const char *genres[] = { "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "Alternative Rock", "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno-Insdustiral", "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle", "Native US", "Cabaret", "New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", "Easy Listening", "Acoustic","Humour", "Speech", "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore", "Ballad", "Power Ballad", "Rhytmic Soul", "Freestyle", "Duet", "Punk Rock", "Drum Solo", "Acapella", "Euro-House", "Dance Hall", "Goa", "Drum & Bass", "Club-House", "Hardcore", "Terror", "Indie", "BritPop", "Negerpunk", "Polsk Punk", "Beat", "Christian Gangsta", "Heavy Metal", "Black Metal", "Crossover", "Contemporary C", "Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime", "JPop", "SynthPop" };
1818

1919
/// current status of the parsing
2020
enum ParseStatus { TagNotFound, PartialTagAtTail, TagFoundPartial, TagFoundComplete, TagProcessed};
@@ -266,7 +266,7 @@ class MetaDataID3V1 : public MetaDataID3Base {
266266
#define ExperimentalIndicatorFlag 0x10
267267

268268
/// Relevant v2 Tags
269-
inline const char* id3_v2_tags[] = {"TALB", "TOPE", "TIT2", "TCON"};
269+
INLINE_VAR const char* id3_v2_tags[] = {"TALB", "TOPE", "TIT2", "TCON"};
270270

271271

272272
/// ID3 verion 2 TAG Header (10 bytes)
@@ -306,7 +306,7 @@ struct ID3v2FrameString {
306306
uint8_t encoding; // encoding byte for strings
307307
};
308308

309-
inline const int ID3FrameSize = 11;
309+
INLINE_VAR const int ID3FrameSize = 11;
310310

311311
/**
312312
* @brief Simple ID3 Meta Data API which supports ID3 V2: We only support the "TALB", "TOPE", "TIT2", "TCON" tags

src/AudioPWM/PWMAudioBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct PWMConfig : public AudioBaseInfo {
9090
Pins pins_data;
9191

9292

93-
} inline default_config;
93+
} INLINE_VAR default_config;
9494

9595

9696
/**

0 commit comments

Comments
 (0)