mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: add spa_atob() to convert a string to a boolean
This replaces the manual check for "true" and some (inconsistent) return value of atoi. All those instances now require either "true" or "1" to parse as true, any other value (including NULL) is boolean false.
This commit is contained in:
		
							parent
							
								
									4e70799922
								
							
						
					
					
						commit
						cdfd50e166
					
				
					 18 changed files with 58 additions and 34 deletions
				
			
		| 
						 | 
				
			
			@ -266,11 +266,11 @@ impl_init(const struct spa_handle_factory *factory,
 | 
			
		|||
	}
 | 
			
		||||
	if (info) {
 | 
			
		||||
		if ((str = spa_dict_lookup(info, SPA_KEY_LOG_TIMESTAMP)) != NULL)
 | 
			
		||||
			this->timestamp = (spa_streq(str, "true") || atoi(str) == 1);
 | 
			
		||||
			this->timestamp = spa_atob(str);
 | 
			
		||||
		if ((str = spa_dict_lookup(info, SPA_KEY_LOG_LINE)) != NULL)
 | 
			
		||||
			this->line = (spa_streq(str, "true") || atoi(str) == 1);
 | 
			
		||||
			this->line = spa_atob(str);
 | 
			
		||||
		if ((str = spa_dict_lookup(info, SPA_KEY_LOG_COLORS)) != NULL)
 | 
			
		||||
			this->colors = (spa_streq(str, "true") || atoi(str) == 1);
 | 
			
		||||
			this->colors = spa_atob(str);
 | 
			
		||||
		if ((str = spa_dict_lookup(info, SPA_KEY_LOG_LEVEL)) != NULL)
 | 
			
		||||
			this->log.level = atoi(str);
 | 
			
		||||
		if ((str = spa_dict_lookup(info, SPA_KEY_LOG_FILE)) != NULL) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -360,7 +360,7 @@ impl_init(const struct spa_handle_factory *factory,
 | 
			
		|||
 | 
			
		||||
	if (info) {
 | 
			
		||||
		if ((str = spa_dict_lookup(info, "node.freewheel")) != NULL)
 | 
			
		||||
			this->props.freewheel = (spa_streq(str, "true") || atoi(str) == 1);
 | 
			
		||||
			this->props.freewheel = spa_atob(str);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	spa_loop_add_source(this->data_loop, &this->timer_source);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue