fix: dashcamd OMX crash on restart, add dashcam status indicator
prebuilt / build prebuilt (push) Has been cancelled
badges / create badges (push) Has been cancelled

- Reset OMX subsystem (Deinit/Init) on dashcamd startup to clear stale
  encoder state from previous unclean exits
- Validate OMX output buffers before memcpy to prevent segfault
- Validate VisionBuf frame data before encoding
- Add dashcam row to status window showing recording state and disk usage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-16 00:44:13 -05:00
parent 3cbb81f9f1
commit 9ac334b7cf
5 changed files with 39 additions and 0 deletions
+14
View File
@@ -118,6 +118,10 @@ static std::string srt_time(int seconds) {
int main(int argc, char *argv[]) {
setpriority(PRIO_PROCESS, 0, -10);
// Reset OMX subsystem — clears any stale encoder state from previous unclean exit
OMX_Deinit();
OMX_Init();
// Ensure base output directory exists
mkdir(VIDEOS_BASE.c_str(), 0755);
@@ -341,6 +345,16 @@ int main(int argc, char *argv[]) {
uint64_t ts = nanos_since_boot() - segment_start_ts;
// Validate buffer before encoding
if (buf->y == nullptr || buf->uv == nullptr || buf->width == 0 || buf->height == 0) {
LOGE("dashcamd: invalid frame buf y=%p uv=%p %zux%zu, skipping", buf->y, buf->uv, buf->width, buf->height);
continue;
}
if (frame_count == 0) {
LOGW("dashcamd: first encode w=%d h=%d stride=%d buf_y=%p buf_uv=%p", width, height, y_stride, buf->y, buf->uv);
}
// Feed NV12 frame directly to OMX encoder
encoder->encode_frame_nv12(buf->y, y_stride, buf->uv, uv_stride, width, height, ts);
frame_count++;