Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ESP32-audioI2S
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ESP32-audioI2S
Commits
e2e4df30
Commit
e2e4df30
authored
Apr 22, 2024
by
schreibfaul1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent maindata underflow at start
and remove some unnecessary code
parent
59784c56
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
19 deletions
+21
-19
src/Audio.cpp
src/Audio.cpp
+14
-18
src/mp3_decoder/mp3_decoder.cpp
src/mp3_decoder/mp3_decoder.cpp
+7
-1
No files found.
src/Audio.cpp
View file @
e2e4df30
...
...
@@ -3,7 +3,7 @@
*
* Created on: Oct 26.2018
*
* Version 3.0.9
h
* Version 3.0.9
i
* Updated on: Apr 22.2024
* Author: Wolle (schreibfaul1)
*
...
...
@@ -4426,25 +4426,21 @@ int Audio::sendBytes(uint8_t* data, size_t len) {
// < 0: there has been an error
if
(
m_decodeError
<
0
)
{
// Error, skip the frame...
// i2s_zero_dma_buffer((i2s_port_t)m_i2s_num);
if
(
m_codec
==
CODEC_MP3
&&
(
m_decodeError
==
-
2
))
{
;
// at the beginning this doesn't have to be a mistake, suppress errorcode MAINDATA_UNDERFLOW
printDecodeError
(
m_decodeError
);
m_f_playing
=
false
;
// seek for new syncword
if
(
m_codec
==
CODEC_FLAC
)
{
// if(m_decodeError == ERR_FLAC_BITS_PER_SAMPLE_TOO_BIG) stopSong();
// if(m_decodeError == ERR_FLAC_RESERVED_CHANNEL_ASSIGNMENT) stopSong();
}
else
{
printDecodeError
(
m_decodeError
);
m_f_playing
=
false
;
// seek for new syncword
if
(
m_codec
==
CODEC_FLAC
)
{
// if(m_decodeError == ERR_FLAC_BITS_PER_SAMPLE_TOO_BIG) stopSong();
// if(m_decodeError == ERR_FLAC_RESERVED_CHANNEL_ASSIGNMENT) stopSong();
}
if
(
m_codec
==
CODEC_OPUS
)
{
if
(
m_decodeError
==
ERR_OPUS_HYBRID_MODE_UNSUPPORTED
)
stopSong
();
if
(
m_decodeError
==
ERR_OPUS_SILK_MODE_UNSUPPORTED
)
stopSong
();
if
(
m_decodeError
==
ERR_OPUS_NARROW_BAND_UNSUPPORTED
)
stopSong
();
if
(
m_decodeError
==
ERR_OPUS_WIDE_BAND_UNSUPPORTED
)
stopSong
();
if
(
m_decodeError
==
ERR_OPUS_SUPER_WIDE_BAND_UNSUPPORTED
)
stopSong
();
}
if
(
m_codec
==
CODEC_OPUS
)
{
if
(
m_decodeError
==
ERR_OPUS_HYBRID_MODE_UNSUPPORTED
)
stopSong
();
if
(
m_decodeError
==
ERR_OPUS_SILK_MODE_UNSUPPORTED
)
stopSong
();
if
(
m_decodeError
==
ERR_OPUS_NARROW_BAND_UNSUPPORTED
)
stopSong
();
if
(
m_decodeError
==
ERR_OPUS_WIDE_BAND_UNSUPPORTED
)
stopSong
();
if
(
m_decodeError
==
ERR_OPUS_SUPER_WIDE_BAND_UNSUPPORTED
)
stopSong
();
}
return
1
;
// skip one byte and seek for the next sync word
}
bytesDecoded
=
len
-
bytesLeft
;
...
...
src/mp3_decoder/mp3_decoder.cpp
View file @
e2e4df30
...
...
@@ -3,7 +3,7 @@
* libhelix_HMP3DECODER
*
* Created on: 26.10.2018
* Updated on: 2
9.03
.2023
* Updated on: 2
2.04
.2023
*/
#include "mp3_decoder.h"
/* clip to range [-2^n, 2^n - 1] */
...
...
@@ -1382,6 +1382,7 @@ int MP3Decode( unsigned char *inbuf, int *bytesLeft, short *outbuf, int useSize)
int
offset
,
bitOffset
,
mainBits
,
gr
,
ch
,
fhBytes
,
siBytes
,
freeFrameBytes
;
int
prevBitOffset
,
sfBlockBits
,
huffBlockBits
;
unsigned
char
*
mainPtr
;
static
uint8_t
underflowCounter
=
0
;
// http://macslons-irish-pub-radio.stream.laut.fm/macslons-irish-pub-radio
/* unpack frame header */
fhBytes
=
UnpackFrameHeader
(
inbuf
);
...
...
@@ -1444,6 +1445,7 @@ int MP3Decode( unsigned char *inbuf, int *bytesLeft, short *outbuf, int useSize)
/* fill main data buffer with enough new data for this frame */
if
(
m_MP3DecInfo
->
mainDataBytes
>=
m_MP3DecInfo
->
mainDataBegin
)
{
/* adequate "old" main data available (i.e. bit reservoir) */
underflowCounter
=
0
;
memmove
(
m_MP3DecInfo
->
mainBuf
,
m_MP3DecInfo
->
mainBuf
+
m_MP3DecInfo
->
mainDataBytes
-
m_MP3DecInfo
->
mainDataBegin
,
m_MP3DecInfo
->
mainDataBegin
);
...
...
@@ -1456,10 +1458,14 @@ int MP3Decode( unsigned char *inbuf, int *bytesLeft, short *outbuf, int useSize)
mainPtr
=
m_MP3DecInfo
->
mainBuf
;
}
else
{
/* not enough data in bit reservoir from previous frames (perhaps starting in middle of file) */
underflowCounter
++
;
memcpy
(
m_MP3DecInfo
->
mainBuf
+
m_MP3DecInfo
->
mainDataBytes
,
inbuf
,
m_MP3DecInfo
->
nSlots
);
m_MP3DecInfo
->
mainDataBytes
+=
m_MP3DecInfo
->
nSlots
;
inbuf
+=
m_MP3DecInfo
->
nSlots
;
*
bytesLeft
-=
(
m_MP3DecInfo
->
nSlots
);
if
(
underflowCounter
<
4
){
return
ERR_MP3_NONE
;
}
MP3ClearBadFrame
(
outbuf
);
return
ERR_MP3_MAINDATA_UNDERFLOW
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment