mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	jack: filter formats
filter jack formats in enum_formats Fix some crashes and cleanups
This commit is contained in:
		
							parent
							
								
									be7a06f9b0
								
							
						
					
					
						commit
						914fe5c2b7
					
				
					 3 changed files with 16 additions and 10 deletions
				
			
		| 
						 | 
					@ -447,10 +447,9 @@ static void make_node(struct data *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct pw_properties *props;
 | 
						struct pw_properties *props;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	props = pw_properties_new(
 | 
						props = pw_properties_new("pipewire.autoconnect", "1", NULL);
 | 
				
			||||||
			"pipewire.target.node", data->path,
 | 
						if (data->path)
 | 
				
			||||||
			"pipewire.autoconnect", "1",
 | 
							pw_properties_set(props, "pipewire.target.node", data->path);
 | 
				
			||||||
			NULL);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	data->node = pw_node_new(data->core, NULL, NULL, "SDL-sink", props, 0);
 | 
						data->node = pw_node_new(data->core, NULL, NULL, "SDL-sink", props, 0);
 | 
				
			||||||
	data->impl_node = impl_node;
 | 
						data->impl_node = impl_node;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,8 +63,6 @@ static inline void init_type(struct type *type, struct spa_type_map *map)
 | 
				
			||||||
struct data {
 | 
					struct data {
 | 
				
			||||||
	struct type type;
 | 
						struct type type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char *path;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	SDL_Renderer *renderer;
 | 
						SDL_Renderer *renderer;
 | 
				
			||||||
	SDL_Window *window;
 | 
						SDL_Window *window;
 | 
				
			||||||
	SDL_Texture *texture;
 | 
						SDL_Texture *texture;
 | 
				
			||||||
| 
						 | 
					@ -464,7 +462,6 @@ int main(int argc, char *argv[])
 | 
				
			||||||
	data.running = true;
 | 
						data.running = true;
 | 
				
			||||||
	data.core = pw_core_new(data.loop, NULL);
 | 
						data.core = pw_core_new(data.loop, NULL);
 | 
				
			||||||
	data.t = pw_core_get_type(data.core);
 | 
						data.t = pw_core_get_type(data.core);
 | 
				
			||||||
	data.path = argc > 1 ? argv[1] : NULL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_module_load(data.core, "libpipewire-module-spa-node-factory", NULL);
 | 
						pw_module_load(data.core, "libpipewire-module-spa-node-factory", NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -379,14 +379,18 @@ static int port_enum_formats(struct spa_node *node, enum spa_direction direction
 | 
				
			||||||
	struct node_data *nd = SPA_CONTAINER_OF(node, struct node_data, node_impl);
 | 
						struct node_data *nd = SPA_CONTAINER_OF(node, struct node_data, node_impl);
 | 
				
			||||||
	struct port_data *pd = nd->port_data[direction][port_id];
 | 
						struct port_data *pd = nd->port_data[direction][port_id];
 | 
				
			||||||
	struct type *t = &pd->node->type;
 | 
						struct type *t = &pd->node->type;
 | 
				
			||||||
        struct spa_pod_builder b = { NULL, };
 | 
						struct spa_pod_builder b = { NULL, };
 | 
				
			||||||
 | 
						struct spa_format *fmt;
 | 
				
			||||||
 | 
						uint8_t buffer[4096];
 | 
				
			||||||
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        struct spa_pod_frame f[2];
 | 
					        struct spa_pod_frame f[2];
 | 
				
			||||||
	struct jack_engine_control *ctrl = pd->node->node.server->engine_control;
 | 
						struct jack_engine_control *ctrl = pd->node->node.server->engine_control;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (index > 0)
 | 
						if (index > 0)
 | 
				
			||||||
		return SPA_RESULT_ENUM_END;
 | 
							return SPA_RESULT_ENUM_END;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        spa_pod_builder_init(&b, pd->buffer, sizeof(pd->buffer));
 | 
					        spa_pod_builder_init(&b, buffer, sizeof(buffer));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (pd->port.jack_port) {
 | 
						if (pd->port.jack_port) {
 | 
				
			||||||
		if (pd->port.jack_port->type_id == 0) {
 | 
							if (pd->port.jack_port->type_id == 0) {
 | 
				
			||||||
| 
						 | 
					@ -410,7 +414,13 @@ static int port_enum_formats(struct spa_node *node, enum spa_direction direction
 | 
				
			||||||
                        PROP(&f[1], t->format_audio.rate, SPA_POD_TYPE_INT, ctrl->sample_rate),
 | 
					                        PROP(&f[1], t->format_audio.rate, SPA_POD_TYPE_INT, ctrl->sample_rate),
 | 
				
			||||||
                        PROP(&f[1], t->format_audio.channels, SPA_POD_TYPE_INT, 2));
 | 
					                        PROP(&f[1], t->format_audio.channels, SPA_POD_TYPE_INT, 2));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
        *format = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
 | 
						fmt = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        spa_pod_builder_init(&b, pd->buffer, sizeof(pd->buffer));
 | 
				
			||||||
 | 
					        if ((res = spa_format_filter(fmt, filter, &b)) < 0)
 | 
				
			||||||
 | 
					                return res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        *format = SPA_POD_BUILDER_DEREF(&b, 0, struct spa_format);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return SPA_RESULT_OK;
 | 
						return SPA_RESULT_OK;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue