mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	media-session: check metadata before using it
The session manager might be configured without metadata support so check this before attempting to use the metadata. It's not really a problem because the default sink/source can only be changed with the pulseaudio API, which activates metadata.
This commit is contained in:
		
							parent
							
								
									93002ecd11
								
							
						
					
					
						commit
						b40397d986
					
				
					 2 changed files with 14 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -227,12 +227,14 @@ static void session_create(void *data, struct sm_object *object)
 | 
			
		|||
			if (def->key == NULL)
 | 
			
		||||
				continue;
 | 
			
		||||
 | 
			
		||||
			char val[16];
 | 
			
		||||
			snprintf(val, sizeof(val), "%u", d.id);
 | 
			
		||||
			pw_log_info("found %s with id:%s restore as %s",
 | 
			
		||||
					name, val, item->key);
 | 
			
		||||
			pw_metadata_set_property(impl->session->metadata,
 | 
			
		||||
				PW_ID_CORE, item->key, SPA_TYPE_INFO_BASE"Id", val);
 | 
			
		||||
			if (impl->session->metadata != NULL) {
 | 
			
		||||
				char val[16];
 | 
			
		||||
				snprintf(val, sizeof(val), "%u", d.id);
 | 
			
		||||
				pw_log_info("found %s with id:%s restore as %s",
 | 
			
		||||
						name, val, item->key);
 | 
			
		||||
				pw_metadata_set_property(impl->session->metadata,
 | 
			
		||||
					PW_ID_CORE, item->key, SPA_TYPE_INFO_BASE"Id", val);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -248,7 +250,10 @@ static void session_remove(void *data, struct sm_object *object)
 | 
			
		|||
	for (def = impl->defaults; def->key != NULL; ++def) {
 | 
			
		||||
		if (def->value == object->id) {
 | 
			
		||||
			def->value = SPA_ID_INVALID;
 | 
			
		||||
			pw_metadata_set_property(impl->session->metadata, PW_ID_CORE, def->key, NULL, NULL);
 | 
			
		||||
			if (impl->session->metadata != NULL) {
 | 
			
		||||
				pw_metadata_set_property(impl->session->metadata,
 | 
			
		||||
						PW_ID_CORE, def->key, NULL, NULL);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -217,7 +217,8 @@ static void sync_metadata(struct impl *impl)
 | 
			
		|||
 | 
			
		||||
	impl->sync = true;
 | 
			
		||||
	spa_dict_for_each(it, &impl->props->dict)
 | 
			
		||||
		pw_metadata_set_property(impl->metadata, 0, it->key, "Spa:String:JSON", it->value);
 | 
			
		||||
		pw_metadata_set_property(impl->metadata,
 | 
			
		||||
				PW_ID_CORE, it->key, "Spa:String:JSON", it->value);
 | 
			
		||||
	impl->sync = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue