mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	alsa-mixer: improve check for the empty path set for sink/source
The unused mixer instances are created without this code. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
		
							parent
							
								
									8837c90b7f
								
							
						
					
					
						commit
						d7dbd0cbe3
					
				
					 4 changed files with 26 additions and 9 deletions
				
			
		| 
						 | 
					@ -741,6 +741,12 @@ void pa_alsa_path_set_free(pa_alsa_path_set *ps) {
 | 
				
			||||||
    pa_xfree(ps);
 | 
					    pa_xfree(ps);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int pa_alsa_path_set_is_empty(pa_alsa_path_set *ps) {
 | 
				
			||||||
 | 
					    if (ps && !pa_hashmap_isempty(ps->paths))
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static long to_alsa_dB(pa_volume_t v) {
 | 
					static long to_alsa_dB(pa_volume_t v) {
 | 
				
			||||||
    return lround(pa_sw_volume_to_dB(v) * 100.0);
 | 
					    return lround(pa_sw_volume_to_dB(v) * 100.0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -272,6 +272,7 @@ pa_alsa_path_set *pa_alsa_path_set_new(pa_alsa_mapping *m, pa_alsa_direction_t d
 | 
				
			||||||
void pa_alsa_path_set_dump(pa_alsa_path_set *s);
 | 
					void pa_alsa_path_set_dump(pa_alsa_path_set *s);
 | 
				
			||||||
void pa_alsa_path_set_set_callback(pa_alsa_path_set *ps, snd_mixer_t *m, snd_mixer_elem_callback_t cb, void *userdata);
 | 
					void pa_alsa_path_set_set_callback(pa_alsa_path_set *ps, snd_mixer_t *m, snd_mixer_elem_callback_t cb, void *userdata);
 | 
				
			||||||
void pa_alsa_path_set_free(pa_alsa_path_set *s);
 | 
					void pa_alsa_path_set_free(pa_alsa_path_set *s);
 | 
				
			||||||
 | 
					int pa_alsa_path_set_is_empty(pa_alsa_path_set *s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct pa_alsa_mapping {
 | 
					struct pa_alsa_mapping {
 | 
				
			||||||
    pa_alsa_profile_set *profile_set;
 | 
					    pa_alsa_profile_set *profile_set;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1651,7 +1651,6 @@ static int sink_set_port_ucm_cb(pa_sink *s, pa_device_port *p) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_assert(u);
 | 
					    pa_assert(u);
 | 
				
			||||||
    pa_assert(p);
 | 
					    pa_assert(p);
 | 
				
			||||||
    pa_assert(u->mixer_handle);
 | 
					 | 
				
			||||||
    pa_assert(u->ucm_context);
 | 
					    pa_assert(u->ucm_context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    data = PA_DEVICE_PORT_DATA(p);
 | 
					    data = PA_DEVICE_PORT_DATA(p);
 | 
				
			||||||
| 
						 | 
					@ -2089,6 +2088,9 @@ static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char
 | 
				
			||||||
    if (!mapping && !element)
 | 
					    if (!mapping && !element)
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!element && mapping && pa_alsa_path_set_is_empty(mapping->output_path_set))
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    u->mixers = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func,
 | 
					    u->mixers = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func,
 | 
				
			||||||
                                    NULL, (pa_free_cb_t) pa_alsa_mixer_free);
 | 
					                                    NULL, (pa_free_cb_t) pa_alsa_mixer_free);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2113,8 +2115,9 @@ static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pa_log_debug("Probed mixer path %s:", u->mixer_path->name);
 | 
					        pa_log_debug("Probed mixer path %s:", u->mixer_path->name);
 | 
				
			||||||
        pa_alsa_path_dump(u->mixer_path);
 | 
					        pa_alsa_path_dump(u->mixer_path);
 | 
				
			||||||
    } else if (!(u->mixer_path_set = mapping->output_path_set))
 | 
					    } else {
 | 
				
			||||||
        goto fail;
 | 
					        u->mixer_path_set = mapping->output_path_set;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2559,10 +2562,14 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
 | 
				
			||||||
        goto fail;
 | 
					        goto fail;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (u->ucm_context)
 | 
					    if (u->ucm_context) {
 | 
				
			||||||
        pa_alsa_ucm_add_ports(&data.ports, data.proplist, u->ucm_context, true, card, u->pcm_handle, ignore_dB);
 | 
					        pa_alsa_ucm_add_ports(&data.ports, data.proplist, u->ucm_context, true, card, u->pcm_handle, ignore_dB);
 | 
				
			||||||
    else if (u->mixer_path_set)
 | 
					        find_mixer(u, mapping, pa_modargs_get_value(ma, "control", NULL), ignore_dB);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        find_mixer(u, mapping, pa_modargs_get_value(ma, "control", NULL), ignore_dB);
 | 
				
			||||||
 | 
					        if (u->mixer_path_set)
 | 
				
			||||||
            pa_alsa_add_ports(&data, u->mixer_path_set, card);
 | 
					            pa_alsa_add_ports(&data, u->mixer_path_set, card);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    u->sink = pa_sink_new(m->core, &data, PA_SINK_HARDWARE | PA_SINK_LATENCY | (u->use_tsched ? PA_SINK_DYNAMIC_LATENCY : 0) |
 | 
					    u->sink = pa_sink_new(m->core, &data, PA_SINK_HARDWARE | PA_SINK_LATENCY | (u->use_tsched ? PA_SINK_DYNAMIC_LATENCY : 0) |
 | 
				
			||||||
                          (set_formats ? PA_SINK_SET_FORMATS : 0));
 | 
					                          (set_formats ? PA_SINK_SET_FORMATS : 0));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1522,7 +1522,6 @@ static int source_set_port_ucm_cb(pa_source *s, pa_device_port *p) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_assert(u);
 | 
					    pa_assert(u);
 | 
				
			||||||
    pa_assert(p);
 | 
					    pa_assert(p);
 | 
				
			||||||
    pa_assert(u->mixer_handle);
 | 
					 | 
				
			||||||
    pa_assert(u->ucm_context);
 | 
					    pa_assert(u->ucm_context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    data = PA_DEVICE_PORT_DATA(p);
 | 
					    data = PA_DEVICE_PORT_DATA(p);
 | 
				
			||||||
| 
						 | 
					@ -1795,6 +1794,9 @@ static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char
 | 
				
			||||||
    if (!mapping && !element)
 | 
					    if (!mapping && !element)
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!element && mapping && pa_alsa_path_set_is_empty(mapping->input_path_set))
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    u->mixers = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func,
 | 
					    u->mixers = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func,
 | 
				
			||||||
                                    NULL, (pa_free_cb_t) pa_alsa_mixer_free);
 | 
					                                    NULL, (pa_free_cb_t) pa_alsa_mixer_free);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1819,8 +1821,9 @@ static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pa_log_debug("Probed mixer path %s:", u->mixer_path->name);
 | 
					        pa_log_debug("Probed mixer path %s:", u->mixer_path->name);
 | 
				
			||||||
        pa_alsa_path_dump(u->mixer_path);
 | 
					        pa_alsa_path_dump(u->mixer_path);
 | 
				
			||||||
    } else if (!(u->mixer_path_set = mapping->input_path_set))
 | 
					    } else {
 | 
				
			||||||
        goto fail;
 | 
					        u->mixer_path_set = mapping->input_path_set;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue