mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	pactl: add get_default_sink command
				
					
				
			Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/430>
This commit is contained in:
		
							parent
							
								
									d9db47bdb5
								
							
						
					
					
						commit
						0e4a92ca69
					
				
					 2 changed files with 26 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -121,6 +121,7 @@ static enum {
 | 
			
		|||
    SUSPEND_SOURCE,
 | 
			
		||||
    SET_CARD_PROFILE,
 | 
			
		||||
    SET_SINK_PORT,
 | 
			
		||||
    GET_DEFAULT_SINK,
 | 
			
		||||
    SET_DEFAULT_SINK,
 | 
			
		||||
    SET_SOURCE_PORT,
 | 
			
		||||
    SET_DEFAULT_SOURCE,
 | 
			
		||||
| 
						 | 
				
			
			@ -189,6 +190,18 @@ static void stat_callback(pa_context *c, const pa_stat_info *i, void *userdata)
 | 
			
		|||
    complete_action();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void get_default_sink(pa_context *c, const pa_server_info *i, void *userdata) {
 | 
			
		||||
    if (!i) {
 | 
			
		||||
        pa_log(_("Failed to get server information: %s"), pa_strerror(pa_context_errno(c)));
 | 
			
		||||
        quit(1);
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    printf(_("%s\n"), i->default_sink_name);
 | 
			
		||||
 | 
			
		||||
    complete_action();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void get_server_info_callback(pa_context *c, const pa_server_info *i, void *useerdata) {
 | 
			
		||||
    char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1481,6 +1494,10 @@ static void context_state_callback(pa_context *c, void *userdata) {
 | 
			
		|||
                    o = pa_context_set_sink_port_by_name(c, sink_name, port_name, simple_callback, NULL);
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case GET_DEFAULT_SINK:
 | 
			
		||||
                    o = pa_context_get_server_info(c, get_default_sink, NULL);
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case SET_DEFAULT_SINK:
 | 
			
		||||
                    o = pa_context_set_default_sink(c, sink_name, simple_callback, NULL);
 | 
			
		||||
                    break;
 | 
			
		||||
| 
						 | 
				
			
			@ -1717,6 +1734,7 @@ static void help(const char *argv0) {
 | 
			
		|||
    printf("%s %s %s %s\n", argv0, _("[options]"), "move-(sink-input|source-output)", _("#N SINK|SOURCE"));
 | 
			
		||||
    printf("%s %s %s %s\n", argv0, _("[options]"), "suspend-(sink|source)", _("NAME|#N 1|0"));
 | 
			
		||||
    printf("%s %s %s %s\n", argv0, _("[options]"), "set-card-profile ", _("CARD PROFILE"));
 | 
			
		||||
    printf("%s %s %s %s\n", argv0, _("[options]"), "get-default-(sink|source)", _("NAME"));
 | 
			
		||||
    printf("%s %s %s %s\n", argv0, _("[options]"), "set-default-(sink|source)", _("NAME"));
 | 
			
		||||
    printf("%s %s %s %s\n", argv0, _("[options]"), "set-(sink|source)-port", _("NAME|#N PORT"));
 | 
			
		||||
    printf("%s %s %s %s\n", argv0, _("[options]"), "set-(sink|source)-volume", _("NAME|#N VOLUME [VOLUME ...]"));
 | 
			
		||||
| 
						 | 
				
			
			@ -2017,6 +2035,9 @@ int main(int argc, char *argv[]) {
 | 
			
		|||
 | 
			
		||||
            sink_name = pa_xstrdup(argv[optind+1]);
 | 
			
		||||
 | 
			
		||||
        } else if (pa_streq(argv[optind], "get-default-sink")) {
 | 
			
		||||
            action = GET_DEFAULT_SINK;
 | 
			
		||||
 | 
			
		||||
        } else if (pa_streq(argv[optind], "set-source-port")) {
 | 
			
		||||
            action = SET_SOURCE_PORT;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue