diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f8ac656..4f76468 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: - uses: pguyot/arm-runner-action@v2 with: - base_image: https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2023-12-11/2023-12-11-raspios-bookworm-arm64-lite.img.xz + base_image: https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-03-15/2024-03-15-raspios-bookworm-arm64-lite.img.xz cpu: cortex-a7 image_additional_mb: 1500 bind_mount_repository: true diff --git a/include/camera_grabber.h b/include/camera_grabber.h index 49a0717..f0b5962 100644 --- a/include/camera_grabber.h +++ b/include/camera_grabber.h @@ -55,7 +55,7 @@ class CameraGrabber { // Note: these 3 functions must be protected by mutual exclusion. // Failure to do so will result in UB. - void startAndQueue(); + bool startAndQueue(); void stop(); void requeueRequest(libcamera::Request *request); diff --git a/include/camera_runner.h b/include/camera_runner.h index 947540c..b22d79f 100644 --- a/include/camera_runner.h +++ b/include/camera_runner.h @@ -64,7 +64,7 @@ class CameraRunner { // Note: start and stop are not reenterant. Starting and stopping a camera // repeatedly should work, but has not been thoroughly tested. - void start(); + bool start(); void stop(); // Note: this is public but is a footgun. Destructing this class while a diff --git a/src/camera_grabber.cpp b/src/camera_grabber.cpp index 0aeec78..f57a0db 100644 --- a/src/camera_grabber.cpp +++ b/src/camera_grabber.cpp @@ -206,19 +206,20 @@ void CameraGrabber::setControls(libcamera::Request *request) { } } -void CameraGrabber::startAndQueue() { +bool CameraGrabber::startAndQueue() { running = true; if (m_camera->start()) { - throw std::runtime_error("failed to start camera"); + return false;// failed to start camera } // TODO: HANDLE THIS BETTER for (auto &request : m_requests) { setControls(request.get()); if (m_camera->queueRequest(request.get()) < 0) { - throw std::runtime_error("failed to queue request"); + return false; // failed to queue request } } + return true; } void CameraGrabber::stop() { diff --git a/src/camera_runner.cpp b/src/camera_runner.cpp index 0283ab3..180276f 100644 --- a/src/camera_runner.cpp +++ b/src/camera_runner.cpp @@ -75,7 +75,7 @@ void CameraRunner::setCopyOptions(bool copyIn, bool copyOut) { m_copyOutput = copyOut; } -void CameraRunner::start() { +bool CameraRunner::start() { unsigned int stride = grabber.streamConfiguration().stride; latch start_frame_grabber{2}; @@ -242,7 +242,7 @@ void CameraRunner::start() { { std::lock_guard lock{camera_stop_mutex}; - grabber.startAndQueue(); + return grabber.startAndQueue(); } } diff --git a/src/libcamera_jni.cpp b/src/libcamera_jni.cpp index 4984dfb..c6ee239 100644 --- a/src/libcamera_jni.cpp +++ b/src/libcamera_jni.cpp @@ -159,8 +159,8 @@ Java_org_photonvision_raspi_LibCameraJNI_startCamera { CameraRunner *runner = reinterpret_cast(runner_); - runner->start(); - return true; + + return runner->start(); } /*