mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	alsa: Use card description in default sink/source prefix when available
When given an explicit device.description in card_properties, prefer this information over other default prefixes (e.g. 'Built-in Audio') when constructing sink/source descriptions. For example, if I manually configure the card description to be "FooBar", I then expect that the sinks and created by the card also have "FooBar" in their description instead of generic "Built-in Audio".
This commit is contained in:
		
							parent
							
								
									efec98280f
								
							
						
					
					
						commit
						fe6e41d7d2
					
				
					 9 changed files with 19 additions and 14 deletions
				
			
		| 
						 | 
					@ -2278,7 +2278,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
 | 
				
			||||||
            pa_proplist_sets(data.proplist, key, pa_proplist_gets(mapping->proplist, key));
 | 
					            pa_proplist_sets(data.proplist, key, pa_proplist_gets(mapping->proplist, key));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_alsa_init_description(data.proplist);
 | 
					    pa_alsa_init_description(data.proplist, card);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (u->control_device)
 | 
					    if (u->control_device)
 | 
				
			||||||
        pa_alsa_init_proplist_ctl(data.proplist, u->control_device);
 | 
					        pa_alsa_init_proplist_ctl(data.proplist, u->control_device);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1984,7 +1984,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
 | 
				
			||||||
            pa_proplist_sets(data.proplist, key, pa_proplist_gets(mapping->proplist, key));
 | 
					            pa_proplist_sets(data.proplist, key, pa_proplist_gets(mapping->proplist, key));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_alsa_init_description(data.proplist);
 | 
					    pa_alsa_init_description(data.proplist, card);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (u->control_device)
 | 
					    if (u->control_device)
 | 
				
			||||||
        pa_alsa_init_proplist_ctl(data.proplist, u->control_device);
 | 
					        pa_alsa_init_proplist_ctl(data.proplist, u->control_device);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -868,11 +868,11 @@ void pa_alsa_refcnt_dec(void) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool pa_alsa_init_description(pa_proplist *p) {
 | 
					bool pa_alsa_init_description(pa_proplist *p, pa_card *card) {
 | 
				
			||||||
    const char *d, *k;
 | 
					    const char *d, *k;
 | 
				
			||||||
    pa_assert(p);
 | 
					    pa_assert(p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pa_device_init_description(p))
 | 
					    if (pa_device_init_description(p, card))
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!(d = pa_proplist_gets(p, "alsa.card_name")))
 | 
					    if (!(d = pa_proplist_gets(p, "alsa.card_name")))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -118,7 +118,7 @@ void pa_alsa_init_proplist_pcm_info(pa_core *c, pa_proplist *p, snd_pcm_info_t *
 | 
				
			||||||
void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card);
 | 
					void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card);
 | 
				
			||||||
void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm);
 | 
					void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm);
 | 
				
			||||||
void pa_alsa_init_proplist_ctl(pa_proplist *p, const char *name);
 | 
					void pa_alsa_init_proplist_ctl(pa_proplist *p, const char *name);
 | 
				
			||||||
bool pa_alsa_init_description(pa_proplist *p);
 | 
					bool pa_alsa_init_description(pa_proplist *p, pa_card *card);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents);
 | 
					int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -704,7 +704,7 @@ int pa__init(pa_module *m) {
 | 
				
			||||||
    pa_alsa_init_proplist_card(m->core, data.proplist, u->alsa_card_index);
 | 
					    pa_alsa_init_proplist_card(m->core, data.proplist, u->alsa_card_index);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->device_id);
 | 
					    pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->device_id);
 | 
				
			||||||
    pa_alsa_init_description(data.proplist);
 | 
					    pa_alsa_init_description(data.proplist, NULL);
 | 
				
			||||||
    set_card_name(&data, u->modargs, u->device_id);
 | 
					    set_card_name(&data, u->modargs, u->device_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* We need to give pa_modargs_get_value_boolean() a pointer to a local
 | 
					    /* We need to give pa_modargs_get_value_boolean() a pointer to a local
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -201,7 +201,7 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
 | 
				
			||||||
    c->userdata = NULL;
 | 
					    c->userdata = NULL;
 | 
				
			||||||
    c->set_profile = NULL;
 | 
					    c->set_profile = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_device_init_description(c->proplist);
 | 
					    pa_device_init_description(c->proplist, c);
 | 
				
			||||||
    pa_device_init_icon(c->proplist, true);
 | 
					    pa_device_init_icon(c->proplist, true);
 | 
				
			||||||
    pa_device_init_intended_roles(c->proplist);
 | 
					    pa_device_init_intended_roles(c->proplist);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -231,7 +231,7 @@ pa_sink* pa_sink_new(
 | 
				
			||||||
    if (data->card)
 | 
					    if (data->card)
 | 
				
			||||||
        pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->card->proplist);
 | 
					        pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->card->proplist);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_device_init_description(data->proplist);
 | 
					    pa_device_init_description(data->proplist, data->card);
 | 
				
			||||||
    pa_device_init_icon(data->proplist, true);
 | 
					    pa_device_init_icon(data->proplist, true);
 | 
				
			||||||
    pa_device_init_intended_roles(data->proplist);
 | 
					    pa_device_init_intended_roles(data->proplist);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3441,13 +3441,18 @@ bool pa_device_init_icon(pa_proplist *p, bool is_sink) {
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool pa_device_init_description(pa_proplist *p) {
 | 
					bool pa_device_init_description(pa_proplist *p, pa_card *card) {
 | 
				
			||||||
    const char *s, *d = NULL, *k;
 | 
					    const char *s, *d = NULL, *k;
 | 
				
			||||||
    pa_assert(p);
 | 
					    pa_assert(p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pa_proplist_contains(p, PA_PROP_DEVICE_DESCRIPTION))
 | 
					    if (pa_proplist_contains(p, PA_PROP_DEVICE_DESCRIPTION))
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (card)
 | 
				
			||||||
 | 
					        if ((s = pa_proplist_gets(card->proplist, PA_PROP_DEVICE_DESCRIPTION)))
 | 
				
			||||||
 | 
					            d = s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!d)
 | 
				
			||||||
        if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_FORM_FACTOR)))
 | 
					        if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_FORM_FACTOR)))
 | 
				
			||||||
            if (pa_streq(s, "internal"))
 | 
					            if (pa_streq(s, "internal"))
 | 
				
			||||||
                d = _("Built-in Audio");
 | 
					                d = _("Built-in Audio");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -399,7 +399,7 @@ void pa_sink_mute_changed(pa_sink *s, bool new_muted);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void pa_sink_update_flags(pa_sink *s, pa_sink_flags_t mask, pa_sink_flags_t value);
 | 
					void pa_sink_update_flags(pa_sink *s, pa_sink_flags_t mask, pa_sink_flags_t value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool pa_device_init_description(pa_proplist *p);
 | 
					bool pa_device_init_description(pa_proplist *p, pa_card *card);
 | 
				
			||||||
bool pa_device_init_icon(pa_proplist *p, bool is_sink);
 | 
					bool pa_device_init_icon(pa_proplist *p, bool is_sink);
 | 
				
			||||||
bool pa_device_init_intended_roles(pa_proplist *p);
 | 
					bool pa_device_init_intended_roles(pa_proplist *p);
 | 
				
			||||||
unsigned pa_device_init_priority(pa_proplist *p);
 | 
					unsigned pa_device_init_priority(pa_proplist *p);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -218,7 +218,7 @@ pa_source* pa_source_new(
 | 
				
			||||||
    if (data->card)
 | 
					    if (data->card)
 | 
				
			||||||
        pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->card->proplist);
 | 
					        pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->card->proplist);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_device_init_description(data->proplist);
 | 
					    pa_device_init_description(data->proplist, data->card);
 | 
				
			||||||
    pa_device_init_icon(data->proplist, false);
 | 
					    pa_device_init_icon(data->proplist, false);
 | 
				
			||||||
    pa_device_init_intended_roles(data->proplist);
 | 
					    pa_device_init_intended_roles(data->proplist);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue