Skip to content

Commit ee84894

Browse files
author
Mike Pichl
committed
Add a check whether the WebSocket buffer has space.
1 parent da0fa8c commit ee84894

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/app_httpd.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,23 +192,26 @@ String processor(const String& var) {
192192

193193

194194
int IRAM_ATTR CLAppHttpd::snapToStream(bool debug) {
195+
if (ws->availableForWriteAll()) {
196+
int res = AppCam.snapToBuffer();
195197

196-
int res = AppCam.snapToBuffer();
198+
if(!res) {
197199

198-
if(!res) {
200+
if(AppCam.isJPEGinBuffer()){
199201

200-
if(AppCam.isJPEGinBuffer()){
202+
ws->binaryAll( AppCam.getBuffer(), AppCam.getBufferSize());
201203

202-
ws->binaryAll( AppCam.getBuffer(), AppCam.getBufferSize());
204+
} else {
203205

204-
} else {
205-
206-
res = OS_FAIL;
206+
res = OS_FAIL;
207+
}
207208
}
209+
210+
AppCam.releaseBuffer();
211+
return res;
208212
}
209213

210-
AppCam.releaseBuffer();
211-
return res;
214+
return ESP_OK;
212215
}
213216

214217
StreamResponseEnum CLAppHttpd::startStream(uint32_t id, CaptureModeEnum streammode) {

0 commit comments

Comments
 (0)