File tree Expand file tree Collapse file tree 2 files changed +14
-18
lines changed Expand file tree Collapse file tree 2 files changed +14
-18
lines changed Original file line number Diff line number Diff line change @@ -82,25 +82,20 @@ class ICYStreamDefault : public AbstractURLStream {
82
82
virtual size_t readBytes (uint8_t * buffer, size_t len) override {
83
83
size_t result = 0 ;
84
84
if (icy.hasMetaData ()){
85
- CHECK_MEMORY ();
86
- // wait for data
87
- while (url->available ()<len){
88
- delay (100 );
89
- }
90
-
91
- // access using state engine
92
- for (size_t j=0 ; j<len; j++){
93
- int ch = read ();
94
- if (ch==-1 ){
95
- break ;
85
+ // get data
86
+ int read = url->readBytes (buffer, len);
87
+ // remove metadata from data
88
+ int pos = 0 ;
89
+ for (int j=0 ; j<read; j++){
90
+ icy.processChar (buffer[j]);
91
+ if (icy.isData ()){
92
+ buffer[pos++] = buffer[j];
96
93
}
97
- result = j+1 ;
98
- buffer[j] = ch;
99
- }
100
- CHECK_MEMORY ();
94
+ }
95
+ result = pos;
101
96
} else {
102
- // fast access if there is no metadata
103
- result = url->readBytes (buffer, len);
97
+ // fast access if there is no metadata
98
+ result = url->readBytes (buffer, len);
104
99
}
105
100
LOGD (" %s: %zu -> %zu" , LOG_METHOD, len, result);
106
101
return result;
@@ -116,6 +111,7 @@ class ICYStreamDefault : public AbstractURLStream {
116
111
// Read character and processes using the MetaDataICY state engine
117
112
virtual int read () override {
118
113
int ch = -1 ;
114
+ if (url==nullptr ) return -1 ;
119
115
120
116
// get next data byte
121
117
do {
@@ -125,7 +121,6 @@ class ICYStreamDefault : public AbstractURLStream {
125
121
}
126
122
127
123
icy.processChar (ch);
128
- // yield();
129
124
} while (!icy.isData ());
130
125
return ch;
131
126
}
Original file line number Diff line number Diff line change @@ -202,6 +202,7 @@ class StreamCopyT {
202
202
203
203
// blocking write - until everything is processed
204
204
size_t write (size_t len, size_t &delayCount ){
205
+ if (buffer==nullptr ) return 0 ;
205
206
size_t total = 0 ;
206
207
int retry = 0 ;
207
208
while (total<len){
You can’t perform that action at this time.
0 commit comments