mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	jack: update the eventfd from the data loop
Also update the variables we use from the data loop.
This commit is contained in:
		
							parent
							
								
									1e9a557c06
								
							
						
					
					
						commit
						fa154955af
					
				
					 1 changed files with 45 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -420,6 +420,9 @@ struct client {
 | 
			
		|||
		struct spa_io_position *position;
 | 
			
		||||
		struct pw_node_activation *driver_activation;
 | 
			
		||||
		struct spa_list target_links;
 | 
			
		||||
		unsigned int prepared:1;
 | 
			
		||||
		unsigned int first:1;
 | 
			
		||||
		unsigned int thread_entered:1;
 | 
			
		||||
	} rt;
 | 
			
		||||
 | 
			
		||||
	pthread_mutex_t rt_lock;
 | 
			
		||||
| 
						 | 
				
			
			@ -429,8 +432,6 @@ struct client {
 | 
			
		|||
	unsigned int started:1;
 | 
			
		||||
	unsigned int active:1;
 | 
			
		||||
	unsigned int destroyed:1;
 | 
			
		||||
	unsigned int first:1;
 | 
			
		||||
	unsigned int thread_entered:1;
 | 
			
		||||
	unsigned int has_transport:1;
 | 
			
		||||
	unsigned int allow_mlock:1;
 | 
			
		||||
	unsigned int warn_mlock:1;
 | 
			
		||||
| 
						 | 
				
			
			@ -1834,10 +1835,10 @@ static inline uint32_t cycle_run(struct client *c)
 | 
			
		|||
 | 
			
		||||
	activation->awake_time = get_time_ns(c->l->system);
 | 
			
		||||
 | 
			
		||||
	if (SPA_UNLIKELY(c->first)) {
 | 
			
		||||
	if (SPA_UNLIKELY(c->rt.first)) {
 | 
			
		||||
		if (c->thread_init_callback)
 | 
			
		||||
			c->thread_init_callback(c->thread_init_arg);
 | 
			
		||||
		c->first = false;
 | 
			
		||||
		c->rt.first = false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (SPA_UNLIKELY(pos == NULL)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1967,8 +1968,8 @@ on_rtsocket_condition(void *data, int fd, uint32_t mask)
 | 
			
		|||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	if (SPA_UNLIKELY(c->thread_callback)) {
 | 
			
		||||
		if (!c->thread_entered) {
 | 
			
		||||
			c->thread_entered = true;
 | 
			
		||||
		if (!c->rt.thread_entered) {
 | 
			
		||||
			c->rt.thread_entered = true;
 | 
			
		||||
			c->thread_callback(c->thread_arg);
 | 
			
		||||
		}
 | 
			
		||||
	} else if (SPA_LIKELY(mask & SPA_IO_IN)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -2106,7 +2107,7 @@ do_update_driver_activation(struct spa_loop *loop,
 | 
			
		|||
	c->rt.position = c->position;
 | 
			
		||||
	c->rt.driver_activation = c->driver_activation;
 | 
			
		||||
	if (c->position) {
 | 
			
		||||
		pw_log_info("%p: driver:%d clock:%s", c,
 | 
			
		||||
		pw_log_debug("%p: driver:%d clock:%s", c,
 | 
			
		||||
				c->driver_id, c->position->clock.name);
 | 
			
		||||
		check_sample_rate(c, c->position);
 | 
			
		||||
		check_buffer_frames(c, c->position);
 | 
			
		||||
| 
						 | 
				
			
			@ -2194,6 +2195,39 @@ static int client_node_event(void *data, const struct spa_event *event)
 | 
			
		|||
	return -ENOTSUP;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int do_prepare_client(struct spa_loop *loop, bool async, uint32_t seq,
 | 
			
		||||
		const void *data, size_t size, void *user_data)
 | 
			
		||||
{
 | 
			
		||||
	struct client *c = user_data;
 | 
			
		||||
 | 
			
		||||
	if (c->rt.prepared)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	pw_loop_update_io(c->l,
 | 
			
		||||
			  c->socket_source,
 | 
			
		||||
			  SPA_IO_IN | SPA_IO_ERR | SPA_IO_HUP);
 | 
			
		||||
 | 
			
		||||
	c->rt.first = true;
 | 
			
		||||
	c->rt.thread_entered = false;
 | 
			
		||||
	c->rt.prepared = true;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int do_unprepare_client(struct spa_loop *loop, bool async, uint32_t seq,
 | 
			
		||||
		const void *data, size_t size, void *user_data)
 | 
			
		||||
{
 | 
			
		||||
	struct client *c = user_data;
 | 
			
		||||
 | 
			
		||||
	if (!c->rt.prepared)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	pw_loop_update_io(c->l,
 | 
			
		||||
			  c->socket_source, SPA_IO_ERR | SPA_IO_HUP);
 | 
			
		||||
 | 
			
		||||
	c->rt.prepared = false;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int client_node_command(void *data, const struct spa_command *command)
 | 
			
		||||
{
 | 
			
		||||
	struct client *c = (struct client *) data;
 | 
			
		||||
| 
						 | 
				
			
			@ -2204,8 +2238,8 @@ static int client_node_command(void *data, const struct spa_command *command)
 | 
			
		|||
	case SPA_NODE_COMMAND_Suspend:
 | 
			
		||||
	case SPA_NODE_COMMAND_Pause:
 | 
			
		||||
		if (c->started) {
 | 
			
		||||
			pw_loop_update_io(c->l,
 | 
			
		||||
					  c->socket_source, SPA_IO_ERR | SPA_IO_HUP);
 | 
			
		||||
			pw_data_loop_invoke(c->loop,
 | 
			
		||||
				do_unprepare_client, SPA_ID_INVALID, NULL, 0, false, c);
 | 
			
		||||
 | 
			
		||||
			c->started = false;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -2213,12 +2247,9 @@ static int client_node_command(void *data, const struct spa_command *command)
 | 
			
		|||
 | 
			
		||||
	case SPA_NODE_COMMAND_Start:
 | 
			
		||||
		if (!c->started) {
 | 
			
		||||
			pw_loop_update_io(c->l,
 | 
			
		||||
					  c->socket_source,
 | 
			
		||||
					  SPA_IO_IN | SPA_IO_ERR | SPA_IO_HUP);
 | 
			
		||||
			pw_data_loop_invoke(c->loop,
 | 
			
		||||
				do_prepare_client, SPA_ID_INVALID, NULL, 0, false, c);
 | 
			
		||||
			c->started = true;
 | 
			
		||||
			c->first = true;
 | 
			
		||||
			c->thread_entered = false;
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue