pipewire/spa
Barnabás Pőcze c3fec9769c spa: libcamera: manager: fix id allocation
There is an issue in the id allocation mechanism which can result
in the different devices having the same id. Specifically, consider
the scenario where there are only two cameras, which have just been
added. In this case `impl::devices` looks like this:

   (0, camA) | (1, camB) | (?, nullptr) | ...

Now assume that `camA` is removed, after which the array appears
as follows:

  (1, camB) | (1, nullptr) | (?, nullptr) | ...

Then assume that a new camera appears. When `get_free_id()` runs,
when `i == 1`, it will observe that `devices[i].camera == nullptr`,
so it selects `1` as the id. Leading to the following:

  (1, camB) | (1, camC) | (?, nullptr) | ...

This is of course incorrect. The set of ids must be unique. When
wireplumber is faced with this situation it destroys the device
object for `camB` when `camC` is emitted.

Fix this by simply not moving elements in the `devices` array,
leaving everything where it is. In which case the array looks
like this:

  (nullptr) | (camB) | (nullptr) | ... // after `camA` removal
  (camC) | (camB) | (nullptr) | ... // after `camC` appearance

Note that `device::id` is removed, and the id is now derived from
the position in `impl::devices`.

(cherry picked from commit 2c2808fab1)
2025-09-26 09:58:10 +02:00
..
examples Port videotestsrc to LoopUtils 2024-07-01 15:28:14 +00:00
include meta: add SPA_META_SYNC_TIMELINE_UNSCHEDULED_RELEASE 2025-09-11 09:48:21 +02:00
include-private/spa-private spa: move dbus helpers out of bluez plugin 2024-02-05 13:03:20 +00:00
lib spa: remove some old includes 2024-11-26 13:30:58 +01:00
plugins spa: libcamera: manager: fix id allocation 2025-09-26 09:58:10 +02:00
tests Add GNU/Hurd support 2023-09-24 15:11:52 +00:00
tools spa: add spa_json_object_next 2024-09-16 09:50:36 +02:00
meson.build spa: fix ALSA UMP support detection in meson 2025-03-11 12:27:25 +01:00