mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	loop: return number of dispatched fds and update docs
This commit is contained in:
		
							parent
							
								
									6f5a2701f3
								
							
						
					
					
						commit
						1bfb1d9228
					
				
					 2 changed files with 31 additions and 4 deletions
				
			
		| 
						 | 
					@ -105,9 +105,11 @@ struct spa_loop {
 | 
				
			||||||
struct spa_loop_control_hooks {
 | 
					struct spa_loop_control_hooks {
 | 
				
			||||||
#define SPA_VERSION_LOOP_CONTROL_HOOKS	0
 | 
					#define SPA_VERSION_LOOP_CONTROL_HOOKS	0
 | 
				
			||||||
	uint32_t version;
 | 
						uint32_t version;
 | 
				
			||||||
	/** Executed right before waiting for events */
 | 
						/** Executed right before waiting for events. It is typically used to
 | 
				
			||||||
 | 
						 * release locks. */
 | 
				
			||||||
	void (*before) (void *data);
 | 
						void (*before) (void *data);
 | 
				
			||||||
	/** Executed right after waiting for events */
 | 
						/** Executed right after waiting for events. It is typically used to
 | 
				
			||||||
 | 
						 * reacquire locks. */
 | 
				
			||||||
	void (*after) (void *data);
 | 
						void (*after) (void *data);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -124,15 +126,40 @@ struct spa_loop_control {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Add a hook
 | 
						/** Add a hook
 | 
				
			||||||
	 * \param ctrl the control to change
 | 
						 * \param ctrl the control to change
 | 
				
			||||||
	 * \param hooks the hooks to add */
 | 
						 * \param hooks the hooks to add
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * Adds hooks to the loop controlled by \a ctrl.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
	void (*add_hook) (struct spa_loop_control *ctrl,
 | 
						void (*add_hook) (struct spa_loop_control *ctrl,
 | 
				
			||||||
			  struct spa_hook *hook,
 | 
								  struct spa_hook *hook,
 | 
				
			||||||
			  const struct spa_loop_control_hooks *hooks,
 | 
								  const struct spa_loop_control_hooks *hooks,
 | 
				
			||||||
			  void *data);
 | 
								  void *data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** Enter a loop
 | 
				
			||||||
 | 
						 * \param ctrl the control
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * Start an interation of the loop. This function should be called
 | 
				
			||||||
 | 
						 * before calling iterate and is typically used to capture the thread
 | 
				
			||||||
 | 
						 * that this loop will run in.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
	void (*enter) (struct spa_loop_control *ctrl);
 | 
						void (*enter) (struct spa_loop_control *ctrl);
 | 
				
			||||||
 | 
						/** Leave a loop
 | 
				
			||||||
 | 
						 * \param ctrl the control
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * Ends the iteration of a loop. This should be called after calling
 | 
				
			||||||
 | 
						 * iterate.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
	void (*leave) (struct spa_loop_control *ctrl);
 | 
						void (*leave) (struct spa_loop_control *ctrl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** Perform one iteration of the loop.
 | 
				
			||||||
 | 
						 * \param ctrl the control
 | 
				
			||||||
 | 
						 * \param timeout an optional timeout. 0 for no timeout, -1 for infinte
 | 
				
			||||||
 | 
						 *		timeout.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * This function will block
 | 
				
			||||||
 | 
						 * up to \a timeout and then dispatch the fds with activity.
 | 
				
			||||||
 | 
						 * The number of dispatched fds is returned.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
	int (*iterate) (struct spa_loop_control *ctrl, int timeout);
 | 
						int (*iterate) (struct spa_loop_control *ctrl, int timeout);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -364,7 +364,7 @@ static int loop_iterate(struct spa_loop_control *ctrl, int timeout)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	process_destroy(impl);
 | 
						process_destroy(impl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return nfds;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void source_io_func(struct spa_source *source)
 | 
					static void source_io_func(struct spa_source *source)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue