Skip to content

Commit 772aefd

Browse files
authored
Fix cam_take going into infinite loop (#578)
- Check if we have remaining ticks before going for math and calling cam_take recursively
1 parent d1c9c2c commit 772aefd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

driver/cam_hal.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ esp_err_t cam_deinit(void)
435435
}
436436

437437
ll_cam_deinit(cam_obj);
438-
438+
439439
if (cam_obj->dma) {
440440
free(cam_obj->dma);
441441
}
@@ -484,7 +484,11 @@ camera_fb_t *cam_take(TickType_t timeout)
484484
} else {
485485
ESP_LOGW(TAG, "NO-EOI");
486486
cam_give(dma_buffer);
487-
return cam_take(timeout - (xTaskGetTickCount() - start));//recurse!!!!
487+
TickType_t ticks_spent = xTaskGetTickCount() - start;
488+
if (ticks_spent >= timeout) {
489+
return NULL; /* We are out of time */
490+
}
491+
return cam_take(timeout - ticks_spent);//recurse!!!!
488492
}
489493
} else if(cam_obj->psram_mode && cam_obj->in_bytes_per_pixel != cam_obj->fb_bytes_per_pixel){
490494
//currently this is used only for YUV to GRAYSCALE

0 commit comments

Comments
 (0)