mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	filter-graph: pass dict to activate functions
This makes it possible to expand it more later.
This commit is contained in:
		
							parent
							
								
									591c40eed4
								
							
						
					
					
						commit
						c5ae456b9e
					
				
					 3 changed files with 12 additions and 6 deletions
				
			
		| 
						 | 
					@ -81,7 +81,7 @@ struct spa_filter_graph_methods {
 | 
				
			||||||
	int (*get_props) (void *object, struct spa_pod_builder *b, const struct spa_pod **props);
 | 
						int (*get_props) (void *object, struct spa_pod_builder *b, const struct spa_pod **props);
 | 
				
			||||||
	int (*set_props) (void *object, enum spa_direction direction, const struct spa_pod *props);
 | 
						int (*set_props) (void *object, enum spa_direction direction, const struct spa_pod *props);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int (*activate) (void *object, const struct spa_fraction *rate);
 | 
						int (*activate) (void *object, const struct spa_dict *props);
 | 
				
			||||||
	int (*deactivate) (void *object);
 | 
						int (*deactivate) (void *object);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int (*reset) (void *object);
 | 
						int (*reset) (void *object);
 | 
				
			||||||
| 
						 | 
					@ -120,10 +120,10 @@ SPA_API_FILTER_GRAPH int spa_filter_graph_set_props(struct spa_filter_graph *obj
 | 
				
			||||||
			spa_filter_graph, &object->iface, set_props, 0, direction, props);
 | 
								spa_filter_graph, &object->iface, set_props, 0, direction, props);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SPA_API_FILTER_GRAPH int spa_filter_graph_activate(struct spa_filter_graph *object, const struct spa_fraction *rate)
 | 
					SPA_API_FILTER_GRAPH int spa_filter_graph_activate(struct spa_filter_graph *object, const struct spa_dict *props)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return spa_api_method_r(int, -ENOTSUP,
 | 
						return spa_api_method_r(int, -ENOTSUP,
 | 
				
			||||||
			spa_filter_graph, &object->iface, activate, 0, rate);
 | 
								spa_filter_graph, &object->iface, activate, 0, props);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
SPA_API_FILTER_GRAPH int spa_filter_graph_deactivate(struct spa_filter_graph *object)
 | 
					SPA_API_FILTER_GRAPH int spa_filter_graph_deactivate(struct spa_filter_graph *object)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1422,7 +1422,7 @@ static int impl_deactivate(void *object)
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int impl_activate(void *object, const struct spa_fraction *rate)
 | 
					static int impl_activate(void *object, const struct spa_dict *props)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct impl *impl = object;
 | 
						struct impl *impl = object;
 | 
				
			||||||
	struct graph *graph = &impl->graph;
 | 
						struct graph *graph = &impl->graph;
 | 
				
			||||||
| 
						 | 
					@ -1435,13 +1435,15 @@ static int impl_activate(void *object, const struct spa_fraction *rate)
 | 
				
			||||||
	uint32_t i, j, max_samples = impl->quantum_limit;
 | 
						uint32_t i, j, max_samples = impl->quantum_limit;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
	float *sd, *dd;
 | 
						float *sd, *dd;
 | 
				
			||||||
 | 
						const char *rate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (graph->activated)
 | 
						if (graph->activated)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	graph->activated = true;
 | 
						graph->activated = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	impl->rate = rate->denom;
 | 
						rate = spa_dict_lookup(props, SPA_KEY_AUDIO_RATE);
 | 
				
			||||||
 | 
						impl->rate = rate ? atoi(rate) : DEFAULT_RATE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* first make instances */
 | 
						/* first make instances */
 | 
				
			||||||
	spa_list_for_each(node, &graph->node_list, link) {
 | 
						spa_list_for_each(node, &graph->node_list, link) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1001,9 +1001,13 @@ static void state_changed(void *data, enum pw_stream_state old,
 | 
				
			||||||
			goto error;
 | 
								goto error;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (impl->rate != target) {
 | 
							if (impl->rate != target) {
 | 
				
			||||||
 | 
								char rate[64];
 | 
				
			||||||
			impl->rate = target;
 | 
								impl->rate = target;
 | 
				
			||||||
 | 
								snprintf(rate, sizeof(rate), "%lu", impl->rate);
 | 
				
			||||||
			spa_filter_graph_deactivate(graph);
 | 
								spa_filter_graph_deactivate(graph);
 | 
				
			||||||
			if ((res = spa_filter_graph_activate(graph, &SPA_FRACTION(1, impl->rate))) < 0)
 | 
								if ((res = spa_filter_graph_activate(graph,
 | 
				
			||||||
 | 
										&SPA_DICT_ITEMS(
 | 
				
			||||||
 | 
											SPA_DICT_ITEM(SPA_KEY_AUDIO_RATE, rate)))) < 0)
 | 
				
			||||||
				goto error;
 | 
									goto error;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue