mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	loop: use simple hook emission
Add new simple hook emision without a cursor. The one with the cursor is not thread safe and is not needed for the loop.
This commit is contained in:
		
							parent
							
								
									0aca605bfb
								
							
						
					
					
						commit
						1b933e5b32
					
				
					 2 changed files with 14 additions and 2 deletions
				
			
		| 
						 | 
					@ -104,8 +104,8 @@ struct spa_loop_control_hooks {
 | 
				
			||||||
	void (*after) (void *data);
 | 
						void (*after) (void *data);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define spa_loop_control_hook_before(l) spa_hook_list_call(l, struct spa_loop_control_hooks, before, 0)
 | 
					#define spa_loop_control_hook_before(l) spa_hook_list_call_simple(l, struct spa_loop_control_hooks, before, 0)
 | 
				
			||||||
#define spa_loop_control_hook_after(l) spa_hook_list_call(l, struct spa_loop_control_hooks, after, 0)
 | 
					#define spa_loop_control_hook_after(l) spa_hook_list_call_simple(l, struct spa_loop_control_hooks, after, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Control an event loop
 | 
					 * Control an event loop
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -82,6 +82,18 @@ static inline void spa_hook_remove(struct spa_hook *hook)
 | 
				
			||||||
		hook->removed(hook);
 | 
							hook->removed(hook);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define spa_hook_list_call_simple(l,type,method,vers,...)			\
 | 
				
			||||||
 | 
					({										\
 | 
				
			||||||
 | 
						struct spa_hook_list *list = l;						\
 | 
				
			||||||
 | 
						struct spa_hook *ci;							\
 | 
				
			||||||
 | 
						spa_list_for_each(ci, &list->list, link) {				\
 | 
				
			||||||
 | 
							const type *cb = ci->funcs;					\
 | 
				
			||||||
 | 
							if (cb && cb->version >= vers && cb->method) {			\
 | 
				
			||||||
 | 
								cb->method(ci->data, ## __VA_ARGS__);			\
 | 
				
			||||||
 | 
							}								\
 | 
				
			||||||
 | 
						}									\
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Call all hooks in a list, starting from the given one and optionally stopping
 | 
					/** Call all hooks in a list, starting from the given one and optionally stopping
 | 
				
			||||||
 * after calling the first non-NULL function, returns the number of methods
 | 
					 * after calling the first non-NULL function, returns the number of methods
 | 
				
			||||||
 * called */
 | 
					 * called */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue