From bac58c2d5e45d838e32bc1d5cc0b12a19365c569 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 May 2019 18:46:36 +0200 Subject: video: fallback to first available camera --- video/camera.cpp | 17 +++++++++++++++-- video/camera.hpp | 4 ++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/video/camera.cpp b/video/camera.cpp index c33ab13a..b5cf3120 100644 --- a/video/camera.cpp +++ b/video/camera.cpp @@ -37,14 +37,27 @@ bool show_dialog(const QString& camera_name) return false; } -std::unique_ptr make_camera(const QString& name) +std::unique_ptr make_camera_(const QString& name) { QMutexLocker l(&mtx); for (auto& camera : metadata) for (const QString& name_ : camera->camera_names()) if (name_ == name) - return camera->make_camera(name); + return camera->make_camera(name_); + + return nullptr; +} + +std::unique_ptr make_camera(const QString& name) +{ + if (auto ret = make_camera_(name)) + return ret; + + for (auto& camera : metadata) + for (const QString& name_ : camera->camera_names()) + if (auto ret = camera->make_camera(name_); ret) + return ret; return nullptr; } diff --git a/video/camera.hpp b/video/camera.hpp index 9ff2821b..250bad36 100644 --- a/video/camera.hpp +++ b/video/camera.hpp @@ -85,8 +85,8 @@ namespace video { using camera_impl = impl::camera; -OTR_VIDEO_EXPORT -std::unique_ptr make_camera(const QString& name); +OTR_VIDEO_EXPORT std::unique_ptr make_camera(const QString& name); +OTR_VIDEO_EXPORT std::unique_ptr make_camera_(const QString& name); OTR_VIDEO_EXPORT std::vector camera_names(); -- cgit v1.2.3