mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: libcamera: manager: factor out hotplug event submission
The `impl::{add,remove}Camera` functions do the same thing except
for one value, the type of the hotplug event. Add a private method
to `impl` that implements the common parts.
This commit is contained in:
parent
e0e8bf083d
commit
a36b8a273d
1 changed files with 13 additions and 12 deletions
|
|
@ -75,6 +75,17 @@ struct impl {
|
|||
spa_assert(std::begin(devices) <= &d && &d < std::end(devices));
|
||||
return &d - std::begin(devices);
|
||||
}
|
||||
|
||||
private:
|
||||
void queue_hotplug_event(enum hotplug_event::type type, std::shared_ptr<libcamera::Camera>&& camera)
|
||||
{
|
||||
{
|
||||
std::lock_guard guard(hotplug_events_lock);
|
||||
hotplug_events.push({ type, std::move(camera) });
|
||||
}
|
||||
|
||||
spa_loop_utils_signal_event(loop_utils, hotplug_event_source);
|
||||
}
|
||||
};
|
||||
|
||||
struct device *add_device(struct impl *impl, std::shared_ptr<Camera> camera)
|
||||
|
|
@ -210,22 +221,12 @@ void on_hotplug_event(void *data, std::uint64_t)
|
|||
|
||||
void impl::addCamera(std::shared_ptr<Camera> camera)
|
||||
{
|
||||
{
|
||||
std::unique_lock guard(hotplug_events_lock);
|
||||
hotplug_events.push({ hotplug_event::type::add, std::move(camera) });
|
||||
}
|
||||
|
||||
spa_loop_utils_signal_event(loop_utils, hotplug_event_source);
|
||||
queue_hotplug_event(hotplug_event::type::add, std::move(camera));
|
||||
}
|
||||
|
||||
void impl::removeCamera(std::shared_ptr<Camera> camera)
|
||||
{
|
||||
{
|
||||
std::unique_lock guard(hotplug_events_lock);
|
||||
hotplug_events.push({ hotplug_event::type::remove, std::move(camera) });
|
||||
}
|
||||
|
||||
spa_loop_utils_signal_event(loop_utils, hotplug_event_source);
|
||||
queue_hotplug_event(hotplug_event::type::remove, std::move(camera));
|
||||
}
|
||||
|
||||
void start_monitor(struct impl *impl)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue