mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pulse-server: support NULL set-default-sink/source
It is allowed to set a NULL value for the default source/sink, which then simply clears any configured value.
This commit is contained in:
		
							parent
							
								
									e42261c6d2
								
							
						
					
					
						commit
						dbebbe2f33
					
				
					 1 changed files with 14 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -4847,13 +4847,20 @@ static int do_set_default(struct client *client, uint32_t command, uint32_t tag,
 | 
			
		|||
	pw_log_info(NAME" %p: [%s] %s tag:%u name:%s", impl, client->name,
 | 
			
		||||
			commands[command].name, tag, name);
 | 
			
		||||
 | 
			
		||||
	if ((o = find_device(client, SPA_ID_INVALID, name, sink)) == NULL)
 | 
			
		||||
		return -ENOENT;
 | 
			
		||||
 | 
			
		||||
	if ((res = pw_manager_set_metadata(manager, client->metadata_default,
 | 
			
		||||
			PW_ID_CORE,
 | 
			
		||||
			sink ? METADATA_CONFIG_DEFAULT_SINK : METADATA_CONFIG_DEFAULT_SOURCE,
 | 
			
		||||
			"Spa:String:JSON", "{ \"name\": \"%s\" }", name)) < 0)
 | 
			
		||||
	if (name != NULL) {
 | 
			
		||||
		if ((o = find_device(client, SPA_ID_INVALID, name, sink)) == NULL)
 | 
			
		||||
			return -ENOENT;
 | 
			
		||||
		res = pw_manager_set_metadata(manager, client->metadata_default,
 | 
			
		||||
				PW_ID_CORE,
 | 
			
		||||
				sink ? METADATA_CONFIG_DEFAULT_SINK : METADATA_CONFIG_DEFAULT_SOURCE,
 | 
			
		||||
				"Spa:String:JSON", "{ \"name\": \"%s\" }", name);
 | 
			
		||||
	} else {
 | 
			
		||||
		res = pw_manager_set_metadata(manager, client->metadata_default,
 | 
			
		||||
				PW_ID_CORE,
 | 
			
		||||
				sink ? METADATA_CONFIG_DEFAULT_SINK : METADATA_CONFIG_DEFAULT_SOURCE,
 | 
			
		||||
				NULL, NULL);
 | 
			
		||||
	}
 | 
			
		||||
	if (res < 0)
 | 
			
		||||
		return res;
 | 
			
		||||
 | 
			
		||||
	return reply_simple_ack(client, tag);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue