mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-20 19:05:05 +03:00
qcam: Move requestCompleted signal mapping
The MainWindow connects a handler to the Camera requestCompleted signal when the camera is opened, but never disconnects it. Move the connection to the startCapture() function, and ensure that it is disconnected again when the stream is stopped. This ensures that we can successfully tear down the stream, and restart with a new camera. Introducing the error_disconnect cleanup path in start_capture identified that we left the camera in the start state, thus we also add a call to camera->stop() when disconnecting the signal connection. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
1bf5173076
commit
de584a58f7
1 changed files with 9 additions and 3 deletions
|
@ -113,8 +113,6 @@ int MainWindow::openCamera(CameraManager *cm)
|
||||||
|
|
||||||
std::cout << "Using camera " << camera_->name() << std::endl;
|
std::cout << "Using camera " << camera_->name() << std::endl;
|
||||||
|
|
||||||
camera_->requestCompleted.connect(this, &MainWindow::requestComplete);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,17 +210,23 @@ int MainWindow::startCapture()
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
camera_->requestCompleted.connect(this, &MainWindow::requestComplete);
|
||||||
|
|
||||||
for (Request *request : requests) {
|
for (Request *request : requests) {
|
||||||
ret = camera_->queueRequest(request);
|
ret = camera_->queueRequest(request);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
std::cerr << "Can't queue request" << std::endl;
|
std::cerr << "Can't queue request" << std::endl;
|
||||||
goto error;
|
goto error_disconnect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isCapturing_ = true;
|
isCapturing_ = true;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
error_disconnect:
|
||||||
|
camera_->requestCompleted.disconnect(this, &MainWindow::requestComplete);
|
||||||
|
camera_->stop();
|
||||||
|
|
||||||
error:
|
error:
|
||||||
for (Request *request : requests)
|
for (Request *request : requests)
|
||||||
delete request;
|
delete request;
|
||||||
|
@ -249,6 +253,8 @@ void MainWindow::stopCapture()
|
||||||
if (ret)
|
if (ret)
|
||||||
std::cout << "Failed to stop capture" << std::endl;
|
std::cout << "Failed to stop capture" << std::endl;
|
||||||
|
|
||||||
|
camera_->requestCompleted.disconnect(this, &MainWindow::requestComplete);
|
||||||
|
|
||||||
for (auto &iter : mappedBuffers_) {
|
for (auto &iter : mappedBuffers_) {
|
||||||
void *memory = iter.second.first;
|
void *memory = iter.second.first;
|
||||||
unsigned int length = iter.second.second;
|
unsigned int length = iter.second.second;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue