camera_capture: disable timer callback on stop

Otherwise the capture_trampoline is called while g_camera_capture is a
nullptr, which leads to a hardfault since the this pointer is invalid.
This commit is contained in:
Niklas Hauser
2023-09-13 14:15:23 +02:00
committed by Daniel Agar
parent 016db84d69
commit 98a35971af
@@ -226,7 +226,9 @@ void
CameraCapture::capture_trampoline(void *context, uint32_t chan_index, hrt_abstime edge_time, uint32_t edge_state,
uint32_t overflow)
{
camera_capture::g_camera_capture->capture_callback(chan_index, edge_time, edge_state, overflow);
if (camera_capture::g_camera_capture) {
camera_capture::g_camera_capture->capture_callback(chan_index, edge_time, edge_state, overflow);
}
}
void
@@ -359,6 +361,11 @@ CameraCapture::stop()
work_cancel(HPWORK, &_work_publisher);
if (_capture_channel >= 0) {
up_input_capture_set(_capture_channel, Disabled, 0, nullptr, nullptr);
}
if (camera_capture::g_camera_capture != nullptr) {
delete (camera_capture::g_camera_capture);
}