Skip to content

Commit

Permalink
Fix cam_take going into infinite loop (#578)
Browse files Browse the repository at this point in the history
- Check if we have remaining ticks before going for math and calling cam_take recursively
  • Loading branch information
vikramdattu committed Oct 11, 2023
1 parent d1c9c2c commit 772aefd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions driver/cam_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ esp_err_t cam_deinit(void)
}

ll_cam_deinit(cam_obj);

if (cam_obj->dma) {
free(cam_obj->dma);
}
Expand Down Expand Up @@ -484,7 +484,11 @@ camera_fb_t *cam_take(TickType_t timeout)
} else {
ESP_LOGW(TAG, "NO-EOI");
cam_give(dma_buffer);
return cam_take(timeout - (xTaskGetTickCount() - start));//recurse!!!!
TickType_t ticks_spent = xTaskGetTickCount() - start;
if (ticks_spent >= timeout) {
return NULL; /* We are out of time */
}
return cam_take(timeout - ticks_spent);//recurse!!!!
}
} else if(cam_obj->psram_mode && cam_obj->in_bytes_per_pixel != cam_obj->fb_bytes_per_pixel){
//currently this is used only for YUV to GRAYSCALE
Expand Down

0 comments on commit 772aefd

Please sign in to comment.