mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	* introduce new functions pa_sink_set_description() and pa_source_set_description() for changing the description of a sink/source
* allow sinks without monitor sources attached git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1203 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									0aebc03d1a
								
							
						
					
					
						commit
						c90dd53268
					
				
					 4 changed files with 69 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -118,12 +118,19 @@ pa_sink* pa_sink_new(
 | 
			
		|||
    pa_sample_spec_snprint(st, sizeof(st), spec);
 | 
			
		||||
    pa_log_info(__FILE__": created %u \"%s\" with sample spec \"%s\"", s->index, s->name, st);
 | 
			
		||||
 | 
			
		||||
    n = pa_sprintf_malloc("%s_monitor", name);
 | 
			
		||||
    s->monitor_source = pa_source_new(core, driver, n, 0, spec, map);
 | 
			
		||||
    assert(s->monitor_source);
 | 
			
		||||
    pa_xfree(n);
 | 
			
		||||
    n = pa_sprintf_malloc("%s.monitor", name);
 | 
			
		||||
    
 | 
			
		||||
    if (!(s->monitor_source = pa_source_new(core, driver, n, 0, spec, map)))
 | 
			
		||||
        pa_log_warn(__FILE__": failed to create monitor source.");
 | 
			
		||||
    else {
 | 
			
		||||
        char *d;
 | 
			
		||||
        s->monitor_source->monitor_of = s;
 | 
			
		||||
    s->monitor_source->description = pa_sprintf_malloc("Monitor source of sink '%s'", s->name);
 | 
			
		||||
        d = pa_sprintf_malloc("Monitor Source of %s", s->name);
 | 
			
		||||
        pa_source_set_description(s->monitor_source, d);
 | 
			
		||||
        pa_xfree(d);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pa_xfree(n);
 | 
			
		||||
    
 | 
			
		||||
    pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_NEW, s->index);
 | 
			
		||||
    
 | 
			
		||||
| 
						 | 
				
			
			@ -144,6 +151,7 @@ void pa_sink_disconnect(pa_sink* s) {
 | 
			
		|||
        j = i;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (s->monitor_source)
 | 
			
		||||
        pa_source_disconnect(s->monitor_source);
 | 
			
		||||
 | 
			
		||||
    pa_idxset_remove_by_data(s->core->sinks, s, NULL);
 | 
			
		||||
| 
						 | 
				
			
			@ -168,8 +176,10 @@ static void sink_free(pa_sink *s) {
 | 
			
		|||
 | 
			
		||||
    pa_log_info(__FILE__": freed %u \"%s\"", s->index, s->name); 
 | 
			
		||||
 | 
			
		||||
    if (s->monitor_source) {
 | 
			
		||||
        pa_source_unref(s->monitor_source);
 | 
			
		||||
        s->monitor_source = NULL;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    pa_idxset_free(s->inputs, NULL, NULL);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -304,6 +314,8 @@ int pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    inputs_drop(s, info, n, result->length);
 | 
			
		||||
 | 
			
		||||
    if (s->monitor_source)
 | 
			
		||||
        pa_source_post(s->monitor_source, result);
 | 
			
		||||
 | 
			
		||||
    r = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -358,6 +370,8 @@ int pa_sink_render_into(pa_sink*s, pa_memchunk *target) {
 | 
			
		|||
                                s->sw_muted);
 | 
			
		||||
    
 | 
			
		||||
    inputs_drop(s, info, n, target->length);
 | 
			
		||||
 | 
			
		||||
    if (s->monitor_source)
 | 
			
		||||
        pa_source_post(s->monitor_source, target);
 | 
			
		||||
 | 
			
		||||
    r = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -513,3 +527,27 @@ int pa_sink_get_mute(pa_sink *s, pa_mixer_t m) {
 | 
			
		|||
    } else
 | 
			
		||||
        return s->sw_muted;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void pa_sink_set_description(pa_sink *s, const char *description) {
 | 
			
		||||
    assert(s);
 | 
			
		||||
    assert(s->ref >= 1);
 | 
			
		||||
 | 
			
		||||
    if (!description && !s->description)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    if (description && s->description && !strcmp(description, s->description))
 | 
			
		||||
        return;
 | 
			
		||||
    
 | 
			
		||||
    pa_xfree(s->description);
 | 
			
		||||
    s->description = pa_xstrdup(description);
 | 
			
		||||
 | 
			
		||||
    if (s->monitor_source) {
 | 
			
		||||
        char *n;
 | 
			
		||||
    
 | 
			
		||||
        n = pa_sprintf_malloc("Monitor Source of %s", s->description? s->description : s->name);
 | 
			
		||||
        pa_source_set_description(s->monitor_source, n);
 | 
			
		||||
        pa_xfree(n);
 | 
			
		||||
    }
 | 
			
		||||
        
 | 
			
		||||
    pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -100,4 +100,6 @@ const pa_cvolume *pa_sink_get_volume(pa_sink *sink, pa_mixer_t m);
 | 
			
		|||
void pa_sink_set_mute(pa_sink *sink, pa_mixer_t m, int mute);
 | 
			
		||||
int pa_sink_get_mute(pa_sink *sink, pa_mixer_t m);
 | 
			
		||||
 | 
			
		||||
void pa_sink_set_description(pa_sink *s, const char *description);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -313,3 +313,19 @@ int pa_source_get_mute(pa_source *s, pa_mixer_t m) {
 | 
			
		|||
    } else
 | 
			
		||||
        return s->sw_muted;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void pa_source_set_description(pa_source *s, const char *description) {
 | 
			
		||||
    assert(s);
 | 
			
		||||
    assert(s->ref >= 1);
 | 
			
		||||
 | 
			
		||||
    if (!description && !s->description)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    if (description && s->description && !strcmp(description, s->description))
 | 
			
		||||
        return;
 | 
			
		||||
    
 | 
			
		||||
    pa_xfree(s->description);
 | 
			
		||||
    s->description = pa_xstrdup(description);
 | 
			
		||||
 | 
			
		||||
    pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -100,4 +100,7 @@ const pa_cvolume *pa_source_get_volume(pa_source *source, pa_mixer_t m);
 | 
			
		|||
void pa_source_set_mute(pa_source *source, pa_mixer_t m, int mute);
 | 
			
		||||
int pa_source_get_mute(pa_source *source, pa_mixer_t m);
 | 
			
		||||
 | 
			
		||||
void pa_source_set_description(pa_source *s, const char *description);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue