When initializing cards, three kind of objects need to be created: ports, device prototypes and card profiles. So far they have been created in an "interleaved" fashion: first create a profile, then device prototypes and ports belonging to that profile, then do the same for the remaining profiles. This patch set changes things so that the objects are created in three phases: first all ports, then all device prototypes and finally all card profiles. The initial motivation for this refactoring was that I wanted to ban certain kind of profiles from being added to cards (not included in this patch set), so the "add profile" operation had to become failable, and that possible failure turned out to be hard to handle when all the different kinds of objects were created in an interleaved manner. Creating the objects in separate phases turned out to have other benefits too: it became possible to move parts of the card initialization logic to the core. The card implementations don't need to care about adding profiles to ports or adding ports to sinks and sources any more. This patch set also fixes a bug in the pa_alsa_path struct: previously it had only a single port pointer, even though there might be multiple ports created from the path. Now pa_alsa_path has an array of port pointers. Tanu Kaskinen (17): alsa: Add a ports array to pa_alsa_path dynarray: Add PA_DYNARRAY_FOREACH alsa: Fix jack state reporting alsa: Remove pa_alsa_path.port alsa: Fix boolean style (int->bool) alsa: Remove an unused function parameter alsa: Move the port name and description logic alsa: Move the port priority logic alsa: Add pa_alsa_profile_set_create_ports() alsa: Add a ports array to pa_alsa_ucm_mapping_context alsa: Create UCM ports in pa_alsa_profile_set_create_ports() bluetooth: Store port pointers instead of port names in userdata Create device prototypes before profiles card: Add ports hashmap to pa_device_prototype card: Add the profiles to ports in pa_card_new_data_add_profile() alsa: Separate intended role initialization from adding ports sink, source: Add ports in pa_sink/source_set_prototype() src/modules/alsa/alsa-mixer.c | 221 ++++++++------- src/modules/alsa/alsa-mixer.h | 8 +- src/modules/alsa/alsa-sink.c | 4 +- src/modules/alsa/alsa-source.c | 4 +- src/modules/alsa/alsa-ucm.c | 351 ++++++++++-------------- src/modules/alsa/alsa-ucm.h | 17 +- src/modules/alsa/module-alsa-card.c | 65 +++-- src/modules/bluetooth/module-bluetooth-device.c | 114 +++----- src/pulsecore/card.c | 35 ++- src/pulsecore/card.h | 15 +- src/pulsecore/dynarray.c | 4 +- src/pulsecore/dynarray.h | 5 + src/pulsecore/sink.c | 8 + src/pulsecore/source.c | 8 + src/pulsecore/tokenizer.c | 3 - 15 files changed, 416 insertions(+), 446 deletions(-) -- 1.8.3.1