Skip to content

Commit 1f7a5f3

Browse files
committed
Add timeout handling for pending image capture requests
1 parent 8cab930 commit 1f7a5f3

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/libcameracamera.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,16 @@ void LibCameraWorker::captureImage()
212212
return;
213213
}
214214

215-
// Wait for pending requests to complete
216-
while (!mPendingRequests.empty()) {
215+
// Wait for pending requests to complete with timeout
216+
const auto deadline = std::chrono::steady_clock::now() + std::chrono::seconds(1);
217+
while (!mPendingRequests.empty() && std::chrono::steady_clock::now() < deadline) {
217218
std::this_thread::sleep_for(std::chrono::milliseconds(5));
218219
}
220+
221+
if (!mPendingRequests.empty()) {
222+
emit errorOccurred("libcamera: timeout waiting for pending preview image requests");
223+
return;
224+
}
219225

220226
mCaptureInProgress = true;
221227

0 commit comments

Comments
 (0)