[libcamera-devel,04/14] qcam: Pass camera manager to MainWindow class

Message ID 20190818011329.14499-5-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • Assorted fixes for Android camera HAL
Related show

Commit Message

Laurent Pinchart Aug. 18, 2019, 1:13 a.m. UTC
Pass the CameraManager instance from the main() function to the
MainWindow class instead of accessing it through
CameraManager::instance(). This prepares for the removal of the
CameraManager::instance() method.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/qcam/main.cpp        | 2 +-
 src/qcam/main_window.cpp | 7 +++----
 src/qcam/main_window.h   | 5 +++--
 3 files changed, 7 insertions(+), 7 deletions(-)

Comments

Jacopo Mondi Aug. 19, 2019, 8:59 a.m. UTC | #1
Hi Laurent,

   for this and the next patches working the way to remove the
instance()  method, I'll defer comments to when that discussion ends.

On Sun, Aug 18, 2019 at 04:13:19AM +0300, Laurent Pinchart wrote:
> Pass the CameraManager instance from the main() function to the
> MainWindow class instead of accessing it through
> CameraManager::instance(). This prepares for the removal of the
> CameraManager::instance() method.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/qcam/main.cpp        | 2 +-
>  src/qcam/main_window.cpp | 7 +++----
>  src/qcam/main_window.h   | 5 +++--
>  3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp
> index da942f3daed6..05d3b77e9edb 100644
> --- a/src/qcam/main.cpp
> +++ b/src/qcam/main.cpp
> @@ -73,7 +73,7 @@ int main(int argc, char **argv)
>  		return EXIT_FAILURE;
>  	}
>
> -	MainWindow *mainWindow = new MainWindow(options);
> +	MainWindow *mainWindow = new MainWindow(cm, options);
>  	mainWindow->show();
>  	ret = app.exec();
>  	delete mainWindow;
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index 33fde8b10fd8..ef4ad4a22dca 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -21,7 +21,7 @@
>
>  using namespace libcamera;
>
> -MainWindow::MainWindow(const OptionsParser::Options &options)
> +MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)
>  	: options_(options), isCapturing_(false)
>  {
>  	int ret;
> @@ -35,7 +35,7 @@ MainWindow::MainWindow(const OptionsParser::Options &options)
>  	viewfinder_->setFixedSize(500, 500);
>  	adjustSize();
>
> -	ret = openCamera();
> +	ret = openCamera(cm);
>  	if (!ret)
>  		ret = startCapture();
>
> @@ -66,9 +66,8 @@ void MainWindow::updateTitle()
>  	setWindowTitle(title_ + " : " + QString::number(fps, 'f', 2) + " fps");
>  }
>
> -int MainWindow::openCamera()
> +int MainWindow::openCamera(CameraManager *cm)
>  {
> -	CameraManager *cm = CameraManager::instance();
>  	std::string cameraName;
>
>  	if (!options_.isSet(OptCamera)) {
> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
> index b45cbca725fa..6873155aaa03 100644
> --- a/src/qcam/main_window.h
> +++ b/src/qcam/main_window.h
> @@ -16,6 +16,7 @@
>  #include <QTimer>
>
>  #include <libcamera/camera.h>
> +#include <libcamera/camera_manager.h>
>  #include <libcamera/stream.h>
>
>  #include "../cam/options.h"
> @@ -35,14 +36,14 @@ class MainWindow : public QMainWindow
>  	Q_OBJECT
>
>  public:
> -	MainWindow(const OptionsParser::Options &options);
> +	MainWindow(CameraManager *cm, const OptionsParser::Options &options);
>  	~MainWindow();
>
>  private Q_SLOTS:
>  	void updateTitle();
>
>  private:
> -	int openCamera();
> +	int openCamera(CameraManager *cm);
>
>  	int startCapture();
>  	void stopCapture();
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Jacopo Mondi Aug. 19, 2019, 4:06 p.m. UTC | #2
Hi Laurent,
   with the comment on 13/14 clarified, please add my tag to the two
patches that depends on that.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
   j

On Sun, Aug 18, 2019 at 04:13:19AM +0300, Laurent Pinchart wrote:
> Pass the CameraManager instance from the main() function to the
> MainWindow class instead of accessing it through
> CameraManager::instance(). This prepares for the removal of the
> CameraManager::instance() method.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/qcam/main.cpp        | 2 +-
>  src/qcam/main_window.cpp | 7 +++----
>  src/qcam/main_window.h   | 5 +++--
>  3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp
> index da942f3daed6..05d3b77e9edb 100644
> --- a/src/qcam/main.cpp
> +++ b/src/qcam/main.cpp
> @@ -73,7 +73,7 @@ int main(int argc, char **argv)
>  		return EXIT_FAILURE;
>  	}
>
> -	MainWindow *mainWindow = new MainWindow(options);
> +	MainWindow *mainWindow = new MainWindow(cm, options);
>  	mainWindow->show();
>  	ret = app.exec();
>  	delete mainWindow;
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index 33fde8b10fd8..ef4ad4a22dca 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -21,7 +21,7 @@
>
>  using namespace libcamera;
>
> -MainWindow::MainWindow(const OptionsParser::Options &options)
> +MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)
>  	: options_(options), isCapturing_(false)
>  {
>  	int ret;
> @@ -35,7 +35,7 @@ MainWindow::MainWindow(const OptionsParser::Options &options)
>  	viewfinder_->setFixedSize(500, 500);
>  	adjustSize();
>
> -	ret = openCamera();
> +	ret = openCamera(cm);
>  	if (!ret)
>  		ret = startCapture();
>
> @@ -66,9 +66,8 @@ void MainWindow::updateTitle()
>  	setWindowTitle(title_ + " : " + QString::number(fps, 'f', 2) + " fps");
>  }
>
> -int MainWindow::openCamera()
> +int MainWindow::openCamera(CameraManager *cm)
>  {
> -	CameraManager *cm = CameraManager::instance();
>  	std::string cameraName;
>
>  	if (!options_.isSet(OptCamera)) {
> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
> index b45cbca725fa..6873155aaa03 100644
> --- a/src/qcam/main_window.h
> +++ b/src/qcam/main_window.h
> @@ -16,6 +16,7 @@
>  #include <QTimer>
>
>  #include <libcamera/camera.h>
> +#include <libcamera/camera_manager.h>
>  #include <libcamera/stream.h>
>
>  #include "../cam/options.h"
> @@ -35,14 +36,14 @@ class MainWindow : public QMainWindow
>  	Q_OBJECT
>
>  public:
> -	MainWindow(const OptionsParser::Options &options);
> +	MainWindow(CameraManager *cm, const OptionsParser::Options &options);
>  	~MainWindow();
>
>  private Q_SLOTS:
>  	void updateTitle();
>
>  private:
> -	int openCamera();
> +	int openCamera(CameraManager *cm);
>
>  	int startCapture();
>  	void stopCapture();
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp
index da942f3daed6..05d3b77e9edb 100644
--- a/src/qcam/main.cpp
+++ b/src/qcam/main.cpp
@@ -73,7 +73,7 @@  int main(int argc, char **argv)
 		return EXIT_FAILURE;
 	}
 
-	MainWindow *mainWindow = new MainWindow(options);
+	MainWindow *mainWindow = new MainWindow(cm, options);
 	mainWindow->show();
 	ret = app.exec();
 	delete mainWindow;
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index 33fde8b10fd8..ef4ad4a22dca 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -21,7 +21,7 @@ 
 
 using namespace libcamera;
 
-MainWindow::MainWindow(const OptionsParser::Options &options)
+MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)
 	: options_(options), isCapturing_(false)
 {
 	int ret;
@@ -35,7 +35,7 @@  MainWindow::MainWindow(const OptionsParser::Options &options)
 	viewfinder_->setFixedSize(500, 500);
 	adjustSize();
 
-	ret = openCamera();
+	ret = openCamera(cm);
 	if (!ret)
 		ret = startCapture();
 
@@ -66,9 +66,8 @@  void MainWindow::updateTitle()
 	setWindowTitle(title_ + " : " + QString::number(fps, 'f', 2) + " fps");
 }
 
-int MainWindow::openCamera()
+int MainWindow::openCamera(CameraManager *cm)
 {
-	CameraManager *cm = CameraManager::instance();
 	std::string cameraName;
 
 	if (!options_.isSet(OptCamera)) {
diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
index b45cbca725fa..6873155aaa03 100644
--- a/src/qcam/main_window.h
+++ b/src/qcam/main_window.h
@@ -16,6 +16,7 @@ 
 #include <QTimer>
 
 #include <libcamera/camera.h>
+#include <libcamera/camera_manager.h>
 #include <libcamera/stream.h>
 
 #include "../cam/options.h"
@@ -35,14 +36,14 @@  class MainWindow : public QMainWindow
 	Q_OBJECT
 
 public:
-	MainWindow(const OptionsParser::Options &options);
+	MainWindow(CameraManager *cm, const OptionsParser::Options &options);
 	~MainWindow();
 
 private Q_SLOTS:
 	void updateTitle();
 
 private:
-	int openCamera();
+	int openCamera(CameraManager *cm);
 
 	int startCapture();
 	void stopCapture();