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
2b8ee60f
Unverified
Commit
2b8ee60f
authored
Nov 17, 2022
by
Wolle
Committed by
GitHub
Nov 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new lostStreamDetection()
parent
77fcdd3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
30 deletions
+22
-30
src/Audio.cpp
src/Audio.cpp
+20
-29
src/Audio.h
src/Audio.h
+2
-1
No files found.
src/Audio.cpp
View file @
2b8ee60f
...
...
@@ -3,8 +3,8 @@
*
* Created on: Oct 26.2018
*
* Version 2.0.6
o
* Updated on: Nov 1
6
.2022
* Version 2.0.6
p
* Updated on: Nov 1
7
.2022
* Author: Wolle (schreibfaul1)
*
*/
...
...
@@ -2972,21 +2972,14 @@ void Audio::processLocalFile() {
void
Audio
::
processWebStream
()
{
const
uint16_t
maxFrameSize
=
InBuff
.
getMaxBlockSize
();
// every mp3/aac frame is not bigger
static
bool
f_tmr_1s
;
static
bool
f_stream
;
// first audio data received
static
uint8_t
cnt_slow
;
static
uint32_t
chunkSize
;
// chunkcount read from stream
static
uint32_t
tmr_1s
;
// timer 1 sec
static
uint32_t
loopCnt
;
// count loops if clientbuffer is empty
// first call, set some values to default - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
(
m_f_firstCall
)
{
// runs only ont time per connection, prepare for start
m_f_firstCall
=
false
;
f_stream
=
false
;
cnt_slow
=
0
;
chunkSize
=
0
;
loopCnt
=
0
;
tmr_1s
=
millis
();
m_metacount
=
m_metaint
;
readMetadata
(
0
,
true
);
// reset all static vars
}
...
...
@@ -3004,26 +2997,10 @@ void Audio::processWebStream() {
if
(
m_metacount
==
0
)
{
chunkSize
-=
readMetadata
(
availableBytes
);
return
;}
availableBytes
=
min
(
availableBytes
,
m_metacount
);
}
// timer, triggers every second - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
((
tmr_1s
+
1000
)
<
millis
())
{
f_tmr_1s
=
true
;
// flag will be set every second for one loop only
tmr_1s
=
millis
();
}
// if the buffer is often almost empty issue a warning - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
(
InBuff
.
bufferFilled
()
>
maxFrameSize
)
{
f_tmr_1s
=
false
;
cnt_slow
=
0
;
loopCnt
=
0
;}
if
(
f_tmr_1s
){
cnt_slow
++
;
if
(
cnt_slow
>
50
){
cnt_slow
=
0
;
AUDIO_INFO
(
"slow stream, dropouts are possible"
);}
}
// if the buffer can't filled for several seconds try a new connection - - - - - - - - - - - - - - - - - - - - - - -
if
(
f_stream
&&
!
availableBytes
){
loopCnt
++
;
if
(
loopCnt
>
200000
)
{
// wait several seconds
AUDIO_INFO
(
"Stream lost -> try new connection"
);
connecttohost
(
m_lastHost
);
return
;
}
}
slowStreamDetection
(
InBuff
.
bufferFilled
(),
maxFrameSize
);
if
(
f_stream
)
lostStreamDetection
(
availableBytes
);
// buffer fill routine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
(
availableBytes
)
{
availableBytes
=
min
(
availableBytes
,
InBuff
.
writeSpace
());
...
...
@@ -5119,3 +5096,17 @@ void Audio::slowStreamDetection(uint32_t inBuffFilled, uint32_t maxFrameSize){
}
else
cnt_slow
=
0
;
}
//----------------------------------------------------------------------------------------------------------------------
void
Audio
::
lostStreamDetection
(
uint32_t
bytesAvail
){
static
uint32_t
loopCnt
=
0
;
if
(
!
bytesAvail
){
loopCnt
++
;
if
(
loopCnt
>
200000
)
{
// wait several seconds
loopCnt
=
0
;
AUDIO_INFO
(
"Stream lost -> try new connection"
);
connecttohost
(
m_lastHost
);
return
;
}
}
else
loopCnt
=
0
;
}
src/Audio.h
View file @
2b8ee60f
...
...
@@ -2,7 +2,7 @@
* Audio.h
*
* Created on: Oct 28,2018
* Updated on: Nov 1
6
,2022
* Updated on: Nov 1
7
,2022
* Author: Wolle (schreibfaul1)
*/
...
...
@@ -274,6 +274,7 @@ private:
size_t
chunkedDataTransfer
(
uint8_t
*
bytes
);
bool
readID3V1Tag
();
void
slowStreamDetection
(
uint32_t
inBuffFilled
,
uint32_t
maxFrameSize
);
void
lostStreamDetection
(
uint32_t
bytesAvail
);
//++++ implement several function with respect to the index of string ++++
void
trim
(
char
*
s
)
{
...
...
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