mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	loop: move to plugin
Move the loop implementation to a plugin. Organize the hooks in a list so that we can add many.
This commit is contained in:
		
							parent
							
								
									f55f1739e1
								
							
						
					
					
						commit
						4a219e81dd
					
				
					 14 changed files with 935 additions and 651 deletions
				
			
		| 
						 | 
				
			
			@ -20,23 +20,28 @@
 | 
			
		|||
#include <spa/plugin.h>
 | 
			
		||||
#include <spa/node.h>
 | 
			
		||||
 | 
			
		||||
extern const struct spa_handle_factory spa_logger_factory;
 | 
			
		||||
extern const struct spa_handle_factory spa_type_map_factory;
 | 
			
		||||
#define MAX_FACTORIES	16
 | 
			
		||||
 | 
			
		||||
static const struct spa_handle_factory *factories[MAX_FACTORIES];
 | 
			
		||||
static int n_factories;
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
spa_handle_factory_register(const struct spa_handle_factory *factory)
 | 
			
		||||
{
 | 
			
		||||
	if (n_factories < MAX_FACTORIES)
 | 
			
		||||
		factories[n_factories++] = factory;
 | 
			
		||||
	else
 | 
			
		||||
		fprintf(stderr, "too many factories\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
 | 
			
		||||
{
 | 
			
		||||
	spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
 | 
			
		||||
 | 
			
		||||
	switch (index) {
 | 
			
		||||
	case 0:
 | 
			
		||||
		*factory = &spa_type_map_factory;
 | 
			
		||||
		break;
 | 
			
		||||
	case 1:
 | 
			
		||||
		*factory = &spa_logger_factory;
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
	if (index >= n_factories)
 | 
			
		||||
		return SPA_RESULT_ENUM_END;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	*factory = factories[index];
 | 
			
		||||
	return SPA_RESULT_OK;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue