Skip to content

Commit f5b5f7c

Browse files
committed
copyAll to return the copied size
1 parent f81da69 commit f5b5f7c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/AudioTools/AudioCopy.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,25 +181,28 @@ class StreamCopyT {
181181
}
182182

183183
/// copies all data - returns true if we copied anything
184-
bool copyAll(int retryCount=2, int retryWaitMs=2000){
184+
size_t copyAll(int retryCount=2, int retryWaitMs=2000){
185185
LOGD(LOG_METHOD);
186-
bool result = false;
186+
size_t result = 0;
187+
int retry = 0;
188+
187189
if (from==nullptr || to == nullptr)
188190
return result;
189191

190-
int retry = 0;
191-
// copy whily source has data available
192+
// copy while source has data available
193+
int count=0;
192194
while (true){
193-
int count = copy();
195+
count = copy();
196+
result += count;
194197
if (count==0){
195198
// wait for more data
196199
retry++;
197200
delay(retryWaitMs);
198201
} else {
199202
result = true; // we have some data
200-
retry = 0;
203+
retry = 0; // after we got new data we restart the counting
201204
}
202-
// stop the processing
205+
// stop the processing if we passed the retry limit
203206
if (retry>retryCount){
204207
break;
205208
}

0 commit comments

Comments
 (0)