mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	acp: strip UCM alibpref from mapping
Strip the alibpref from the device string in the mapping name. This name is used to generate the node name eventually and we don't want this random identifier in it. Fixes #1362
This commit is contained in:
		
							parent
							
								
									d1c6114423
								
							
						
					
					
						commit
						ae89ae093e
					
				
					 3 changed files with 21 additions and 11 deletions
				
			
		| 
						 | 
					@ -242,24 +242,18 @@ static void init_device(pa_card *impl, pa_alsa_device *dev, pa_alsa_direction_t
 | 
				
			||||||
	dev->ports = pa_hashmap_new(pa_idxset_string_hash_func,
 | 
						dev->ports = pa_hashmap_new(pa_idxset_string_hash_func,
 | 
				
			||||||
			pa_idxset_string_compare_func);
 | 
								pa_idxset_string_compare_func);
 | 
				
			||||||
	if (m->ucm_context.ucm) {
 | 
						if (m->ucm_context.ucm) {
 | 
				
			||||||
		const char *alibpref = NULL;
 | 
					 | 
				
			||||||
		dev->ucm_context = &m->ucm_context;
 | 
							dev->ucm_context = &m->ucm_context;
 | 
				
			||||||
		if ((snd_use_case_get(impl->ucm.ucm_mgr, "_alibpref", &alibpref) != 0))
 | 
							if (impl->ucm.alibpref != NULL) {
 | 
				
			||||||
			alibpref = NULL;
 | 
					 | 
				
			||||||
		if (alibpref == NULL)
 | 
					 | 
				
			||||||
			alibpref = strdup("_ucm");
 | 
					 | 
				
			||||||
		if (alibpref != NULL) {
 | 
					 | 
				
			||||||
			char **d;
 | 
								char **d;
 | 
				
			||||||
			for (d = m->device_strings; *d; d++) {
 | 
								for (d = m->device_strings; *d; d++) {
 | 
				
			||||||
				if (pa_startswith(*d, alibpref)) {
 | 
									if (pa_startswith(*d, impl->ucm.alibpref)) {
 | 
				
			||||||
					size_t plen = strlen(alibpref);
 | 
										size_t plen = strlen(impl->ucm.alibpref);
 | 
				
			||||||
					size_t len = strlen(*d);
 | 
										size_t len = strlen(*d);
 | 
				
			||||||
					memmove(*d, (*d) + plen, len - plen + 1);
 | 
										memmove(*d, (*d) + plen, len - plen + 1);
 | 
				
			||||||
					dev->device.flags |= ACP_DEVICE_UCM_DEVICE;
 | 
										dev->device.flags |= ACP_DEVICE_UCM_DEVICE;
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			free((void*)alibpref);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pa_dynarray_init(&dev->port_array, NULL);
 | 
						pa_dynarray_init(&dev->port_array, NULL);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -806,12 +806,16 @@ int pa_alsa_ucm_query_profiles(pa_alsa_ucm_config *ucm, int card_index) {
 | 
				
			||||||
        err = -PA_ALSA_ERR_UCM_NO_VERB;
 | 
					        err = -PA_ALSA_ERR_UCM_NO_VERB;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    snd_use_case_get(ucm->ucm_mgr, "_alibpref", (const char**)&ucm->alibpref);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    snd_use_case_free_list(verb_list, num_verbs);
 | 
					    snd_use_case_free_list(verb_list, num_verbs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ucm_verb_fail:
 | 
					ucm_verb_fail:
 | 
				
			||||||
    if (err < 0) {
 | 
					    if (err < 0) {
 | 
				
			||||||
        snd_use_case_mgr_close(ucm->ucm_mgr);
 | 
					        snd_use_case_mgr_close(ucm->ucm_mgr);
 | 
				
			||||||
        ucm->ucm_mgr = NULL;
 | 
					        ucm->ucm_mgr = NULL;
 | 
				
			||||||
 | 
					        free(ucm->alibpref);
 | 
				
			||||||
 | 
					        ucm->alibpref = NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ucm_mgr_fail:
 | 
					ucm_mgr_fail:
 | 
				
			||||||
| 
						 | 
					@ -1521,6 +1525,12 @@ static void alsa_mapping_add_ucm_modifier(pa_alsa_mapping *m, pa_alsa_ucm_modifi
 | 
				
			||||||
        pa_channel_map_init(&m->channel_map);
 | 
					        pa_channel_map_init(&m->channel_map);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char *ucm_strip(pa_alsa_ucm_config *ucm, const char *dev) {
 | 
				
			||||||
 | 
					    if (ucm->alibpref != NULL && pa_startswith(dev, ucm->alibpref))
 | 
				
			||||||
 | 
						    return dev + strlen(ucm->alibpref);
 | 
				
			||||||
 | 
					    return dev;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int ucm_create_mapping_direction(
 | 
					static int ucm_create_mapping_direction(
 | 
				
			||||||
        pa_alsa_ucm_config *ucm,
 | 
					        pa_alsa_ucm_config *ucm,
 | 
				
			||||||
        pa_alsa_profile_set *ps,
 | 
					        pa_alsa_profile_set *ps,
 | 
				
			||||||
| 
						 | 
					@ -1535,7 +1545,8 @@ static int ucm_create_mapping_direction(
 | 
				
			||||||
    char *mapping_name;
 | 
					    char *mapping_name;
 | 
				
			||||||
    unsigned priority, rate, channels;
 | 
					    unsigned priority, rate, channels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mapping_name = pa_sprintf_malloc("Mapping %s: %s: %s", verb_name, device_str, is_sink ? "sink" : "source");
 | 
					    mapping_name = pa_sprintf_malloc("Mapping %s: %s: %s", verb_name,
 | 
				
			||||||
 | 
							    ucm_strip(ucm, device_str), is_sink ? "sink" : "source");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m = pa_alsa_mapping_get(ps, mapping_name);
 | 
					    m = pa_alsa_mapping_get(ps, mapping_name);
 | 
				
			||||||
    if (!m) {
 | 
					    if (!m) {
 | 
				
			||||||
| 
						 | 
					@ -1591,7 +1602,8 @@ static int ucm_create_mapping_for_modifier(
 | 
				
			||||||
    pa_alsa_mapping *m;
 | 
					    pa_alsa_mapping *m;
 | 
				
			||||||
    char *mapping_name;
 | 
					    char *mapping_name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mapping_name = pa_sprintf_malloc("Mapping %s: %s: %s", verb_name, device_str, is_sink ? "sink" : "source");
 | 
					    mapping_name = pa_sprintf_malloc("Mapping %s: %s: %s", verb_name,
 | 
				
			||||||
 | 
							    ucm_strip(ucm, device_str), is_sink ? "sink" : "source");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m = pa_alsa_mapping_get(ps, mapping_name);
 | 
					    m = pa_alsa_mapping_get(ps, mapping_name);
 | 
				
			||||||
    if (!m) {
 | 
					    if (!m) {
 | 
				
			||||||
| 
						 | 
					@ -2122,6 +2134,8 @@ void pa_alsa_ucm_free(pa_alsa_ucm_config *ucm) {
 | 
				
			||||||
        snd_use_case_mgr_close(ucm->ucm_mgr);
 | 
					        snd_use_case_mgr_close(ucm->ucm_mgr);
 | 
				
			||||||
        ucm->ucm_mgr = NULL;
 | 
					        ucm->ucm_mgr = NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    free(ucm->alibpref);
 | 
				
			||||||
 | 
					    ucm->alibpref = NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void pa_alsa_ucm_mapping_context_free(pa_alsa_ucm_mapping_context *context) {
 | 
					void pa_alsa_ucm_mapping_context_free(pa_alsa_ucm_mapping_context *context) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -263,6 +263,8 @@ struct pa_alsa_ucm_config {
 | 
				
			||||||
    pa_hashmap *mixers;
 | 
					    pa_hashmap *mixers;
 | 
				
			||||||
    PA_LLIST_HEAD(pa_alsa_ucm_verb, verbs);
 | 
					    PA_LLIST_HEAD(pa_alsa_ucm_verb, verbs);
 | 
				
			||||||
    PA_LLIST_HEAD(pa_alsa_jack, jacks);
 | 
					    PA_LLIST_HEAD(pa_alsa_jack, jacks);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    char *alibpref;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct pa_alsa_ucm_mapping_context {
 | 
					struct pa_alsa_ucm_mapping_context {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue