Skip to content

Commit 93f3617

Browse files
authored
Avoid task WDT invoked when the stream is temporarily stopped (#2238)
1 parent bab756c commit 93f3617

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/AudioTools/Communication/HTTP/URLStreamBufferedT.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ class BufferedTaskStream : public AudioStream {
124124
if (*(this->p_stream) && available_to_write > 0) {
125125
size_t to_read = min(available_to_write, (size_t)512);
126126
uint8_t buffer[to_read];
127+
while (this->p_stream->available() == 0)
128+
delay(3); // to avoid task WDT invoked while blocking read
127129
size_t avail_read = this->p_stream->readBytes((uint8_t *)buffer, to_read);
128130
size_t written = this->buffers.writeArray(buffer, avail_read);
129131

src/AudioTools/Concurrency/RTOS/SynchronizedNBufferRTOS.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include "AudioToolsConfig.h"
33
#include "QueueRTOS.h"
44

5+
#define DEFAULT_BUFFER_WAIT 1000
6+
57
namespace audio_tools {
68

79
/**
@@ -14,7 +16,7 @@ namespace audio_tools {
1416
template <typename T>
1517
class SynchronizedNBufferRTOST : public NBuffer<T> {
1618
public:
17-
SynchronizedNBufferRTOST(int bufferSize, int bufferCount, int writeMaxWait=portMAX_DELAY, int readMaxWait=portMAX_DELAY) {
19+
SynchronizedNBufferRTOST(int bufferSize, int bufferCount, int writeMaxWait=DEFAULT_BUFFER_WAIT, int readMaxWait=DEFAULT_BUFFER_WAIT) {
1820
TRACED();
1921
read_max_wait = readMaxWait;
2022
write_max_wait = writeMaxWait;
@@ -77,8 +79,8 @@ class SynchronizedNBufferRTOST : public NBuffer<T> {
7779
}
7880

7981
protected:
80-
QueueRTOS<BaseBuffer<T>*> available_buffers{0,portMAX_DELAY,0};
81-
QueueRTOS<BaseBuffer<T>*> filled_buffers{0,portMAX_DELAY,0};
82+
QueueRTOS<BaseBuffer<T>*> available_buffers{0,DEFAULT_BUFFER_WAIT,0};
83+
QueueRTOS<BaseBuffer<T>*> filled_buffers{0,DEFAULT_BUFFER_WAIT,0};
8284
size_t max_size;
8385
size_t read_max_wait, write_max_wait;
8486
int buffer_size = 0, buffer_count = 0;

0 commit comments

Comments
 (0)