Skip to content

Commit cc1a493

Browse files
authored
works now with podcasts
1 parent ab189c2 commit cc1a493

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

src/Audio.cpp

+36-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Audio.cpp
33
*
44
* Created on: Oct 26,2018
5-
* Updated on: Jan 15,2019
5+
* Updated on: Apr 03,2019
66
* Author: Wolle
77
*
88
* This library plays mp3 files from SD card or icy-webstream via I2S
@@ -1287,8 +1287,42 @@ int Audio::sendBytes(uint8_t *data, size_t len) {
12871287
static int lastret=0, count=0;
12881288
if(!m_f_playing){
12891289

1290+
if ((data[0] == 'I') && (data[1] == 'D') && (data[2] == '3')){
1291+
// it is not a usual radio stream, it is a podcast
1292+
log_i("Podcast found!");
1293+
m_id3Size = data[6]; m_id3Size = m_id3Size << 7;
1294+
m_id3Size |= data[7]; m_id3Size = m_id3Size << 7;
1295+
m_id3Size |= data[8]; m_id3Size = m_id3Size << 7;
1296+
m_id3Size |= data[9];
1297+
1298+
m_rev = data[3];
1299+
switch (m_rev) {
1300+
case 2:
1301+
m_f_unsync = (data[5] & 0x80);
1302+
m_f_exthdr = false;
1303+
break;
1304+
case 3:
1305+
case 4:
1306+
m_f_unsync = (data[5] & 0x80); // bit7
1307+
m_f_exthdr = (data[5] & 0x40); // bit6 extended header
1308+
break;
1309+
};
1310+
sprintf(chbuf, "ID3 version=%i", m_rev);
1311+
if(audio_info) audio_info(chbuf);
1312+
sprintf(chbuf,"ID3 framesSize=%i", m_id3Size);
1313+
if(audio_info) audio_info(chbuf);
1314+
}
1315+
// skip ID3
1316+
if(m_id3Size>1000){
1317+
m_id3Size-=1000;
1318+
return 1000;
1319+
}
1320+
if(m_id3Size>0){
1321+
int tmp=m_id3Size;
1322+
m_id3Size=0;
1323+
return tmp;
1324+
}
12901325

1291-
// mad_stream_buffer(stream, data, len);
12921326
if(m_f_mp3) m_nextSync = mp3decoder.MP3FindSyncWord(data, len);
12931327
if(m_nextSync==-1) {
12941328
if(audio_info) audio_info("syncword not found");

src/Audio.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Audio.h
33
*
44
* Created on: Oct 26,2018
5-
* Updated on: Jan 15,2019
5+
* Updated on: Apr 03,2019
66
* Author: Wolle (schreibfaul1)
77
*/
88

0 commit comments

Comments
 (0)