@@ -165,10 +165,6 @@ Audio::Audio(uint8_t i2sPort) {
165165
166166 if (!psramFound ()) log_e (" audioI2S requires PSRAM!" );
167167
168- #ifdef AUDIO_LOG
169- m_f_Log = true ;
170- #endif
171-
172168 clientsecure.setInsecure ();
173169 m_i2s_num = i2sPort; // i2s port number
174170
@@ -834,7 +830,7 @@ bool Audio::connecttoFS(fs::FS& fs, const char* path, int32_t fileStartPos) {
834830 m_fileStartPos = fileStartPos;
835831 uint8_t codec = CODEC_NONE;
836832
837- if (!path) {printProcessLog (AUDIOLOG_PATH_IS_NULL ); goto exit;} // guard
833+ if (!path) {log_info ( " file path is not set " ); goto exit;} // guard
838834 dotPos = lastIndexOf (path, " ." );
839835 if (dotPos == -1 ) {log_info (" No file extension found" ); goto exit;} // guard
840836 setDefaults (); // free buffers an set defaults
@@ -850,11 +846,10 @@ bool Audio::connecttoFS(fs::FS& fs, const char* path, int32_t fileStartPos) {
850846 if (codec == CODEC_NONE) {log_info (" The %s format is not supported" , path + dotPos); goto exit;} // guard
851847
852848 audioPath = audio_calloc<char >(strlen (path) + 2 );
853- if (!audioPath){printProcessLog (AUDIOLOG_OUT_OF_MEMORY); goto exit;};
854849 if (path[0 ] != ' /' )audioPath[0 ] = ' /' ;
855850 strcat (audioPath.get (), path);
856851
857- if (!fs.exists (audioPath.get ())) {printProcessLog (AUDIOLOG_FILE_NOT_FOUND , audioPath.get ()); goto exit;}
852+ if (!fs.exists (audioPath.get ())) {log_info ( " file not found: %s " , audioPath.get ()); goto exit;}
858853 log_info (" Reading file: \" %s\" " , audioPath.get ());
859854 audiofile = fs.open (audioPath.get ());
860855 m_dataMode = AUDIO_LOCALFILE;
@@ -1740,11 +1735,11 @@ int Audio::read_ID3_Header(uint8_t* data, size_t len) {
17401735 ID3Hdr.remainingHeaderBytes --;
17411736 uint32_t decompsize = 0 ;
17421737 if (ID3Hdr.compressed ) {
1743- if (m_f_Log) log_i (" iscompressed" );
1738+ // log_i("iscompressed");
17441739 decompsize = bigEndian (data + 6 , 4 );
17451740 ID3Hdr.remainingHeaderBytes -= 4 ;
17461741 (void )decompsize;
1747- if (m_f_Log) log_i (" decompsize=%u" , decompsize);
1742+ // log_i("decompsize=%u", decompsize);
17481743 return 6 + 4 ;
17491744 }
17501745 return 6 ;
@@ -1874,15 +1869,15 @@ int Audio::read_ID3_Header(uint8_t* data, size_t len) {
18741869 if (m_dataMode == AUDIO_LOCALFILE) {
18751870 ID3Hdr.APIC_pos [ID3Hdr.numID3Header ] = ID3Hdr.id3Size - ID3Hdr.remainingHeaderBytes ;
18761871 ID3Hdr.APIC_size [ID3Hdr.numID3Header ] = ID3Hdr.universal_tmp ;
1877- if (m_f_Log) log_i (" Attached picture seen at pos %d length %d" , APIC_pos[0 ], APIC_size[0 ]);
1872+ // log_i("Attached picture seen at pos %d length %d", APIC_pos[0], APIC_size[0]);
18781873 }
18791874 }
18801875 else if (startsWith (ID3Hdr.tag , " SLT" )) { // lyrics embedded in header
18811876 if (m_dataMode == AUDIO_LOCALFILE) {
18821877 ID3Hdr.SYLT_seen = true ; // #460
18831878 ID3Hdr.SYLT_pos = ID3Hdr.id3Size - ID3Hdr.remainingHeaderBytes ;
18841879 ID3Hdr.SYLT_size = ID3Hdr.universal_tmp ;
1885- if (m_f_Log) log_i (" Attached lyrics seen at pos %d length %d" , SYLT_pos, SYLT_size);
1880+ // log_i("Attached lyrics seen at pos %d length %d", SYLT_pos, SYLT_size);
18861881 }
18871882 }
18881883 else { showID3Tag (ID3Hdr.tag , value);}
@@ -2045,7 +2040,7 @@ int Audio::read_M4A_Header(uint8_t* data, size_t len) {
20452040 atomName[3 ] = *(data + 3 );
20462041 atomName[4 ] = 0 ;
20472042
2048- if (m_f_Log) log_i (" atom %s found" , atomName);
2043+ // log_i("atom %s found", atomName);
20492044
20502045 retvalue = atomsize;
20512046 headerSize += atomsize;
@@ -2268,7 +2263,7 @@ size_t Audio::process_m3u8_ID3_Header(uint8_t* packet) {
22682263 (void )current_timestamp; // suppress -Wunused-variable
22692264
22702265 if (specialIndexOf (packet, " ID3" , 4 ) != 0 ) { // ID3 not found
2271- if (m_f_Log) log_i (" m3u8 file has no mp3 tag" );
2266+ // log_i("m3u8 file has no mp3 tag");
22722267 return 0 ; // error, no ID3 signature found
22732268 }
22742269 ID3version = *(packet + 3 );
@@ -2285,14 +2280,14 @@ size_t Audio::process_m3u8_ID3_Header(uint8_t* packet) {
22852280 };
22862281 id3Size = bigEndian (&packet[6 ], 4 , 7 ); // ID3v2 size 4 * %0xxxxxxx (shift left seven times!!)
22872282 id3Size += 10 ;
2288- if (m_f_Log) log_i (" ID3 framesSize: %i" , id3Size);
2289- if (m_f_Log) log_i (" ID3 version: 2.%i" , ID3version);
2283+ // log_i("ID3 framesSize: %i", id3Size);
2284+ // log_i("ID3 version: 2.%i", ID3version);
22902285
22912286 if (m_f_exthdr) {
22922287 log_e (" ID3 extended header in m3u8 files not supported" );
22932288 return 0 ;
22942289 }
2295- if (m_f_Log) log_i (" ID3 normal frames" );
2290+ // log_i("ID3 normal frames");
22962291
22972292 if (specialIndexOf (&packet[10 ], " PRIV" , 5 ) != 0 ) { // tag PRIV not found
22982293 log_e (" tag PRIV in m3u8 Id3 Header not found" );
@@ -2944,7 +2939,7 @@ ps_ptr<char> Audio::parsePlaylist_M3U8() {
29442939 m_playlistURL.pop_back ();
29452940 m_playlistURL.shrink_to_fit ();
29462941 }
2947- if (m_f_Log) log_i (" now playing %s" , m_playlistBuff);
2942+ // log_i("now playing %s", m_playlistBuff);
29482943 if (endsWith (m_playlistBuff.get (), " ts" )) m_f_ts = true ;
29492944 if (indexOf (m_playlistBuff.get (), " .ts?" ) > 0 ) m_f_ts = true ;
29502945 return m_playlistBuff;
@@ -2964,14 +2959,14 @@ ps_ptr<char> Audio::parsePlaylist_M3U8() {
29642959 else {
29652960 if (m_playlistContent.size () > 0 ) {
29662961 for (int j = 0 ; j < lines; j++) {
2967- if (m_f_Log) log_i (" lines %i, %s" , lines, m_playlistContent[j]);
2962+ // log_i("lines %i, %s", lines, m_playlistContent[j]);
29682963 }
29692964 }
29702965 else { ; }
29712966
29722967 if (m_playlistURL.size () > 0 ) {
29732968 for (int j = 0 ; j < m_playlistURL.size (); j++) {
2974- if (m_f_Log) log_i (" m_playlistURL lines %i, %s" , j, m_playlistURL[j]);
2969+ // log_i("m_playlistURL lines %i, %s", j, m_playlistURL[j]);
29752970 }
29762971 }
29772972 else { ; }
@@ -3782,9 +3777,9 @@ void Audio::processWebStreamHLS() {
37823777
37833778 if (InBuff.bufferFilled () > pwsHLS.maxFrameSize && !m_f_stream) { // waiting for buffer filled
37843779 m_f_stream = true ; // ready to play the audio data
3785- uint16_t filltime = millis () - m_t0;
3780+ // uint16_t filltime = millis() - m_t0;
37863781 log_info (" stream ready" );
3787- if (m_f_Log) log_info (" buffer filled in %u ms" , filltime);
3782+ // log_info("buffer filled in %u ms", filltime);
37883783 }
37893784 return ;
37903785}
@@ -3922,7 +3917,7 @@ bool Audio::parseHttpResponseHeader() { // this is the response to a GET / reque
39223917 }
39233918 if (pos == 510 ) {
39243919 rhl[pos] = ' \0 ' ;
3925- if (m_f_Log) log_i (" responseHeaderline overflow" );
3920+ log_w (" responseHeaderline overflow" );
39263921 }
39273922 } // inner while
39283923
@@ -4020,7 +4015,7 @@ bool Audio::parseHttpResponseHeader() { // this is the response to a GET / reque
40204015 char * c_icylogo = (rhl + 9 ); // Get logo URL
40214016 trim (c_icylogo);
40224017 if (strlen (c_icylogo) > 0 ) {
4023- if (m_f_Log) log_info (" icy-logo: %s" , c_icylogo);
4018+ // log_info("icy-logo: %s", c_icylogo);
40244019 if (audio_icylogo) audio_icylogo (c_icylogo);
40254020 }
40264021 }
@@ -4045,7 +4040,7 @@ bool Audio::parseHttpResponseHeader() { // this is the response to a GET / reque
40454040 char * c_icyname = (rhl + 9 ); // Get station name
40464041 trim (c_icyname);
40474042 if (strlen (c_icyname) > 0 ) {
4048- if (m_f_Log) log_info (" icy-name: %s" , c_icyname);
4043+ // log_info("icy-name: %s", c_icyname);
40494044 if (audio_showstation) audio_showstation (c_icyname);
40504045 }
40514046 }
@@ -4055,7 +4050,7 @@ bool Audio::parseHttpResponseHeader() { // this is the response to a GET / reque
40554050 int32_t i_cl = atoi (c_cl);
40564051 m_contentlength = i_cl;
40574052 m_streamType = ST_WEBFILE; // Stream comes from a fileserver
4058- if (m_f_Log) log_info (" content-length: %lu" , (long unsigned int )m_contentlength);
4053+ // log_info("content-length: %lu", (long unsigned int)m_contentlength);
40594054 }
40604055
40614056 else if (startsWith (rhl, " icy-description:" )) {
@@ -4119,12 +4114,12 @@ bool Audio::parseHttpResponseHeader() { // this is the response to a GET / reque
41194114 if (!(m_codec == CODEC_OGG)){
41204115 if (!initializeDecoder (m_codec)) return false ;
41214116 }
4122- if (m_f_Log) { log_i (" Switch to DATA, metaint is %d" , m_metaint); }
4117+ // { log_i("Switch to DATA, metaint is %d", m_metaint); }
41234118 if (m_playlistFormat != FORMAT_M3U8 && audio_lasthost) audio_lasthost (m_lastHost.get ());
41244119 }
41254120 else if (m_playlistFormat != FORMAT_NONE) {
41264121 m_dataMode = AUDIO_PLAYLISTINIT; // playlist expected
4127- if (m_f_Log) { log_i (" now parse playlist" ); }
4122+ // log_i("now parse playlist");
41284123 }
41294124 else {
41304125 log_info (" unknown content found at: %s" , m_lastHost.get ());
@@ -4272,24 +4267,24 @@ bool Audio::parseContentType(char* ct) {
42724267 switch (ct_val) {
42734268 case CT_MP3:
42744269 m_codec = CODEC_MP3;
4275- if (m_f_Log) { log_i (" ContentType %s, format is mp3" , ct); } // ok is likely mp3
4270+ // { log_i("ContentType %s, format is mp3", ct); } // ok is likely mp3
42764271 break ;
42774272 case CT_AAC:
42784273 m_codec = CODEC_AAC;
4279- if (m_f_Log) { log_i (" ContentType %s, format is aac" , ct); }
4274+ // { log_i("ContentType %s, format is aac", ct); }
42804275 break ;
42814276 case CT_M4A:
42824277 m_codec = CODEC_M4A;
4283- if (m_f_Log) { log_i (" ContentType %s, format is aac" , ct); }
4278+ // { log_i("ContentType %s, format is aac", ct); }
42844279 break ;
42854280 case CT_FLAC:
42864281 m_codec = CODEC_FLAC;
4287- if (m_f_Log) { log_i (" ContentType %s, format is flac" , ct); }
4282+ // { log_i("ContentType %s, format is flac", ct); }
42884283 break ;
42894284 case CT_OPUS:
42904285 m_codec = CODEC_OPUS;
42914286 m_f_ogg = true ; // opus is ogg
4292- if (m_f_Log) { log_i (" ContentType %s, format is opus" , ct); }
4287+ // { log_i("ContentType %s, format is opus", ct); }
42934288 break ;
42944289 case CT_VORBIS:
42954290 m_codec = CODEC_VORBIS;
@@ -4298,7 +4293,7 @@ bool Audio::parseContentType(char* ct) {
42984293 break ;
42994294 case CT_WAV:
43004295 m_codec = CODEC_WAV;
4301- if (m_f_Log) { log_i (" ContentType %s, format is wav" , ct); }
4296+ // { log_i("ContentType %s, format is wav", ct); }
43024297 break ;
43034298 case CT_OGG:
43044299 m_codec = CODEC_OGG; // determine in first OGG packet -OPUS, VORBIS, FLAC
@@ -4311,28 +4306,28 @@ bool Audio::parseContentType(char* ct) {
43114306 case CT_TXT: // overwrite text/plain
43124307 if (m_expectedCodec == CODEC_AAC) {
43134308 m_codec = CODEC_AAC;
4314- if (m_f_Log) log_i (" set ct from M3U8 to AAC" );
4309+ // log_i("set ct from M3U8 to AAC");
43154310 }
43164311 if (m_expectedCodec == CODEC_MP3) {
43174312 m_codec = CODEC_MP3;
4318- if (m_f_Log) log_i (" set ct from M3U8 to MP3" );
4313+ // log_i("set ct from M3U8 to MP3");
43194314 }
43204315
43214316 if (m_expectedPlsFmt == FORMAT_ASX) {
43224317 m_playlistFormat = FORMAT_ASX;
4323- if (m_f_Log) log_i (" set playlist format to ASX" );
4318+ // log_i("set playlist format to ASX");
43244319 }
43254320 if (m_expectedPlsFmt == FORMAT_M3U) {
43264321 m_playlistFormat = FORMAT_M3U;
4327- if (m_f_Log) log_i (" set playlist format to M3U" );
4322+ // log_i("set playlist format to M3U");
43284323 }
43294324 if (m_expectedPlsFmt == FORMAT_M3U8) {
43304325 m_playlistFormat = FORMAT_M3U8;
4331- if (m_f_Log) log_i (" set playlist format to M3U8" );
4326+ // log_i("set playlist format to M3U8");
43324327 }
43334328 if (m_expectedPlsFmt == FORMAT_PLS) {
43344329 m_playlistFormat = FORMAT_PLS;
4335- if (m_f_Log) log_i (" set playlist format to PLS" );
4330+ // log_i("set playlist format to PLS");
43364331 }
43374332 break ;
43384333 default :
@@ -4871,29 +4866,6 @@ void Audio::computeAudioTime(uint16_t bytesDecoderIn, uint16_t bytesDecoderOut)
48714866 m_haveNewFilePos = 0 ;
48724867 }
48734868}
4874- // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4875- void Audio::printProcessLog (int r, const char * s){
4876- const char * e;
4877- const char * f = " " ;
4878- uint8_t logLevel; // 1 Error, 2 Warn, 3 Info,
4879- switch (r) {
4880- case AUDIOLOG_PATH_IS_NULL: e = " The path ore file name is empty" ; logLevel = 1 ; break ;
4881- case AUDIOLOG_OUT_OF_MEMORY: e = " Out of memory" ; logLevel = 1 ; break ;
4882- case AUDIOLOG_FILE_NOT_FOUND: e = " File doesn't exist: " ; logLevel = 1 ; f = s; break ;
4883- case AUDIOLOG_FILE_READ_ERR: e = " Failed to open file for reading" ; logLevel = 1 ; break ;
4884- case AUDIOLOG_M4A_ATOM_NOT_FOUND: e= " m4a atom ilst not found: " ; logLevel = 3 ; f = s; break ;
4885-
4886- default : e = " UNKNOWN EVENT" ; logLevel = 3 ; break ;
4887- }
4888- if (audio_log){
4889- audio_log (logLevel, e, f);
4890- }
4891- else {
4892- if (logLevel == 1 ) {log_info (" ERROR: %s%s" , e, f);}
4893- else if (logLevel == 2 ) {log_info (" WARNING: %s%s" , e, f);}
4894- else {log_info (" INFO: %s%s" , e, f);}
4895- }
4896- }
48974869// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
48984870void Audio::printDecodeError (int r) {
48994871 const char * e;
@@ -6129,7 +6101,7 @@ void Audio::seek_m4a_ilst() { // ilist - item list atom, contains the metadat
61296101 const char atomName[] = " ilst" ;
61306102 uint32_t atomStart = find_m4a_atom (fileSize, atomName);
61316103 if (!atomStart) {
6132- printProcessLog (AUDIOLOG_M4A_ATOM_NOT_FOUND, " ilst" );
6104+ log_info ( " ma4 atom ilst not found " );
61336105 audiofile.seek (0 );
61346106 return ;
61356107 }
@@ -6252,7 +6224,7 @@ void Audio::seek_m4a_stsz() {
62526224 memcpy ((void *)&at, (void *)&tmp, sizeof (tmp));
62536225 found = true ;
62546226 }
6255- if (m_f_Log) log_i (" name %s pos %d, size %d" , tmp.name , tmp.pos , tmp.size );
6227+ // log_i("name %s pos %d, size %d", tmp.name, tmp.pos, tmp.size);
62566228 if (strcmp (tmp.name , " stsd" ) == 0 ) { // in stsd we can found mp4a atom that contains the audioitems
62576229 stsdPos = tmp.pos ;
62586230 stsdSize = tmp.size ;
@@ -6265,7 +6237,7 @@ void Audio::seek_m4a_stsz() {
62656237 audiofile.seek (seekpos);
62666238 audiofile.readBytes (noe, 4 ); // number of entries
62676239 m_stsz_numEntries = bigEndian ((uint8_t *)noe, 4 );
6268- if (m_f_Log) log_i (" number of entries in stsz: %d" , m_stsz_numEntries);
6240+ // log_i("number of entries in stsz: %d", m_stsz_numEntries);
62696241 m_stsz_position = seekpos + 4 ;
62706242 if (stsdSize) {
62716243 audiofile.seek (stsdPos);
0 commit comments