mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-06-30 13:14:16 -04:00
spa: libcamera: move CameraManager acquisition
Now that there is a "libcamera.cpp", move `libcamera_manager_acquire()` into that file since it is a common function used by all three factories.
This commit is contained in:
parent
390a4ce432
commit
6dc55d2cb4
6 changed files with 30 additions and 31 deletions
|
|
@ -26,7 +26,6 @@ using namespace libcamera;
|
|||
#include <spa/monitor/utils.h>
|
||||
|
||||
#include "libcamera.hpp"
|
||||
#include "libcamera-manager.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
@ -388,22 +387,3 @@ const struct spa_handle_factory spa_libcamera_manager_factory = {
|
|||
impl_enum_interface_info,
|
||||
};
|
||||
}
|
||||
|
||||
std::shared_ptr<CameraManager> libcamera_manager_acquire(int& res)
|
||||
{
|
||||
static std::weak_ptr<CameraManager> global_manager;
|
||||
static std::mutex lock;
|
||||
|
||||
std::lock_guard guard(lock);
|
||||
|
||||
if (auto manager = global_manager.lock())
|
||||
return manager;
|
||||
|
||||
auto manager = std::make_shared<CameraManager>();
|
||||
if ((res = manager->start()) < 0)
|
||||
return {};
|
||||
|
||||
global_manager = manager;
|
||||
|
||||
return manager;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue