mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	module-zeroconf-discover: factor out pw_properties_from_avahi_string
This allows to get rid of the empty if block in comparison to
channel_map, and makes it clear that the comparison is useless. So in
the next commit we will remove it.
Fixes an LGTM warning:
    Empty block without comment
			
			
This commit is contained in:
		
							parent
							
								
									dea1a0bee2
								
							
						
					
					
						commit
						6f39e13f11
					
				
					 1 changed files with 34 additions and 29 deletions
				
			
		| 
						 | 
					@ -192,6 +192,39 @@ static const struct pw_impl_module_events module_events = {
 | 
				
			||||||
	.destroy = module_destroy,
 | 
						.destroy = module_destroy,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void pw_properties_from_avahi_string(const char *key, const char *value, struct pw_properties *props) {
 | 
				
			||||||
 | 
						if (spa_streq(key, "device")) {
 | 
				
			||||||
 | 
							pw_properties_set(props, PW_KEY_NODE_TARGET, value);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (spa_streq(key, "rate")) {
 | 
				
			||||||
 | 
							pw_properties_setf(props, PW_KEY_AUDIO_RATE, "%u", atoi(value));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (spa_streq(key, "channels")) {
 | 
				
			||||||
 | 
							pw_properties_setf(props, PW_KEY_AUDIO_CHANNELS, "%u", atoi(value));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (spa_streq(key, "format")) {
 | 
				
			||||||
 | 
							pw_properties_set(props, PW_KEY_AUDIO_FORMAT, value);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (spa_streq(key, "icon-name")) {
 | 
				
			||||||
 | 
							pw_properties_set(props, PW_KEY_DEVICE_ICON_NAME, value);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (spa_streq(key, "channel_map")) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (spa_streq(key, "product-name")) {
 | 
				
			||||||
 | 
							pw_properties_set(props, PW_KEY_DEVICE_PRODUCT_NAME, value);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (spa_streq(key, "description")) {
 | 
				
			||||||
 | 
							pw_properties_set(props, "tunnel.remote.description", value);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (spa_streq(key, "fqdn")) {
 | 
				
			||||||
 | 
							pw_properties_set(props, "tunnel.remote.fqdn", value);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (spa_streq(key, "user-name")) {
 | 
				
			||||||
 | 
							pw_properties_set(props, "tunnel.remote.user", value);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void resolver_cb(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiProtocol protocol,
 | 
					static void resolver_cb(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiProtocol protocol,
 | 
				
			||||||
	AvahiResolverEvent event, const char *name, const char *type, const char *domain,
 | 
						AvahiResolverEvent event, const char *name, const char *type, const char *domain,
 | 
				
			||||||
	const char *host_name, const AvahiAddress *a, uint16_t port, AvahiStringList *txt,
 | 
						const char *host_name, const AvahiAddress *a, uint16_t port, AvahiStringList *txt,
 | 
				
			||||||
| 
						 | 
					@ -233,35 +266,7 @@ static void resolver_cb(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiPr
 | 
				
			||||||
		if (avahi_string_list_get_pair(l, &key, &value, NULL) != 0)
 | 
							if (avahi_string_list_get_pair(l, &key, &value, NULL) != 0)
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (spa_streq(key, "device")) {
 | 
							pw_properties_from_avahi_string(key, value, props);
 | 
				
			||||||
			pw_properties_set(props, PW_KEY_NODE_TARGET, value);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else if (spa_streq(key, "rate")) {
 | 
					 | 
				
			||||||
			pw_properties_setf(props, PW_KEY_AUDIO_RATE, "%u", atoi(value));
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else if (spa_streq(key, "channels")) {
 | 
					 | 
				
			||||||
			pw_properties_setf(props, PW_KEY_AUDIO_CHANNELS, "%u", atoi(value));
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else if (spa_streq(key, "format")) {
 | 
					 | 
				
			||||||
			pw_properties_set(props, PW_KEY_AUDIO_FORMAT, value);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else if (spa_streq(key, "icon-name")) {
 | 
					 | 
				
			||||||
			pw_properties_set(props, PW_KEY_DEVICE_ICON_NAME, value);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else if (spa_streq(key, "channel_map")) {
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else if (spa_streq(key, "product-name")) {
 | 
					 | 
				
			||||||
			pw_properties_set(props, PW_KEY_DEVICE_PRODUCT_NAME, value);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else if (spa_streq(key, "description")) {
 | 
					 | 
				
			||||||
			pw_properties_set(props, "tunnel.remote.description", value);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else if (spa_streq(key, "fqdn")) {
 | 
					 | 
				
			||||||
			pw_properties_set(props, "tunnel.remote.fqdn", value);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else if (spa_streq(key, "user-name")) {
 | 
					 | 
				
			||||||
			pw_properties_set(props, "tunnel.remote.user", value);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		avahi_free(key);
 | 
							avahi_free(key);
 | 
				
			||||||
		avahi_free(value);
 | 
							avahi_free(value);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue