mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	device-restore: Fix the application of an entry to allow changing the name of devices.
This fixes a few bugs in the copy+pasted implementation of apply_entry()/get_name().
This commit is contained in:
		
							parent
							
								
									40e97eb698
								
							
						
					
					
						commit
						64979385e0
					
				
					 1 changed files with 30 additions and 38 deletions
				
			
		| 
						 | 
				
			
			@ -291,10 +291,10 @@ static pa_hook_result_t source_new_hook_callback(pa_core *c, pa_source_new_data
 | 
			
		|||
static char *get_name(const char *key, const char *prefix) {
 | 
			
		||||
    char *t;
 | 
			
		||||
 | 
			
		||||
  if (strncmp(key, prefix, sizeof(prefix)))
 | 
			
		||||
    if (strncmp(key, prefix, strlen(prefix)))
 | 
			
		||||
        return NULL;
 | 
			
		||||
 | 
			
		||||
  t = pa_xstrdup(key + sizeof(prefix));
 | 
			
		||||
    t = pa_xstrdup(key + strlen(prefix));
 | 
			
		||||
    return t;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -302,41 +302,33 @@ static void apply_entry(struct userdata *u, const char *name, struct entry *e) {
 | 
			
		|||
    pa_sink *sink;
 | 
			
		||||
    pa_source *source;
 | 
			
		||||
    uint32_t idx;
 | 
			
		||||
    char *n;
 | 
			
		||||
 | 
			
		||||
    pa_assert(u);
 | 
			
		||||
    pa_assert(name);
 | 
			
		||||
    pa_assert(e);
 | 
			
		||||
 | 
			
		||||
    if ((n = get_name(name, "sink:"))) {
 | 
			
		||||
        for (sink = pa_idxset_first(u->core->sinks, &idx); sink; sink = pa_idxset_next(u->core->sinks, &idx)) {
 | 
			
		||||
    char *n;
 | 
			
		||||
 | 
			
		||||
    if (!(n = get_name(name, "sink")))
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
            if (!pa_streq(sink->name, n)) {
 | 
			
		||||
      pa_xfree(n);
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
    pa_xfree(n);
 | 
			
		||||
 | 
			
		||||
    pa_log_info("Restoring description for sink %s.", sink->name);
 | 
			
		||||
    pa_proplist_sets(sink->proplist, PA_PROP_DEVICE_DESCRIPTION, e->description);
 | 
			
		||||
            pa_log_info("Setting description for sink %s.", sink->name);
 | 
			
		||||
            pa_sink_set_description(sink, e->description);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        pa_xfree(n);
 | 
			
		||||
    }
 | 
			
		||||
    else if ((n = get_name(name, "source:"))) {
 | 
			
		||||
        for (source = pa_idxset_first(u->core->sources, &idx); source; source = pa_idxset_next(u->core->sources, &idx)) {
 | 
			
		||||
    char *n;
 | 
			
		||||
 | 
			
		||||
    if (!(n = get_name(name, "source")))
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
            if (!pa_streq(source->name, n)) {
 | 
			
		||||
      pa_xfree(n);
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
    pa_xfree(n);
 | 
			
		||||
 | 
			
		||||
    pa_log_info("Restoring description for source %s.", source->name);
 | 
			
		||||
    pa_proplist_sets(source->proplist, PA_PROP_DEVICE_DESCRIPTION, e->description);
 | 
			
		||||
            pa_log_info("Setting description for source %s.", source->name);
 | 
			
		||||
            pa_source_set_description(source, e->description);
 | 
			
		||||
        }
 | 
			
		||||
        pa_xfree(n);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue