mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	impl-node: return a result from pw_impl_node_trigger()
Return 0 when the peer was not triggered, 1 when it was triggered and an error when there was an error.
This commit is contained in:
		
							parent
							
								
									f12d37a421
								
							
						
					
					
						commit
						bc57b9ec86
					
				
					 4 changed files with 23 additions and 15 deletions
				
			
		| 
						 | 
					@ -2111,7 +2111,7 @@ int pw_filter_trigger_process(struct pw_filter *filter)
 | 
				
			||||||
	pw_log_trace_fp("%p: driving:%d", impl, filter->node->driving);
 | 
						pw_log_trace_fp("%p: driving:%d", impl, filter->node->driving);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (impl->trigger) {
 | 
						if (impl->trigger) {
 | 
				
			||||||
		pw_impl_node_trigger(filter->node);
 | 
							res = pw_impl_node_trigger(filter->node);
 | 
				
			||||||
	} else if (filter->node->driving) {
 | 
						} else if (filter->node->driving) {
 | 
				
			||||||
		res = pw_loop_invoke(impl->data_loop,
 | 
							res = pw_loop_invoke(impl->data_loop,
 | 
				
			||||||
			do_trigger_process, 1, NULL, 0, false, impl);
 | 
								do_trigger_process, 1, NULL, 0, false, impl);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1523,8 +1523,7 @@ int pw_impl_node_trigger(struct pw_impl_node *node)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	uint64_t nsec = get_time_ns(node->rt.target.system);
 | 
						uint64_t nsec = get_time_ns(node->rt.target.system);
 | 
				
			||||||
	struct pw_node_target *t = &node->rt.target;
 | 
						struct pw_node_target *t = &node->rt.target;
 | 
				
			||||||
	t->trigger(t, nsec);
 | 
						return t->trigger(t, nsec);
 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void node_on_fd_events(struct spa_source *source)
 | 
					static void node_on_fd_events(struct spa_source *source)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -539,7 +539,7 @@ struct pw_node_target {
 | 
				
			||||||
	struct pw_node_activation *activation;
 | 
						struct pw_node_activation *activation;
 | 
				
			||||||
	struct spa_system *system;
 | 
						struct spa_system *system;
 | 
				
			||||||
	int fd;
 | 
						int fd;
 | 
				
			||||||
	void (*trigger)(struct pw_node_target *t, uint64_t nsec);
 | 
						int (*trigger)(struct pw_node_target *t, uint64_t nsec);
 | 
				
			||||||
	unsigned int active:1;
 | 
						unsigned int active:1;
 | 
				
			||||||
	unsigned int added:1;
 | 
						unsigned int added:1;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -653,45 +653,54 @@ static inline uint64_t get_time_ns(struct spa_system *system)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* called from data-loop decrement the dependency counter of the target and when
 | 
					/* called from data-loop decrement the dependency counter of the target and when
 | 
				
			||||||
 * there are no more dependencies, trigger the node. */
 | 
					 * there are no more dependencies, trigger the node. */
 | 
				
			||||||
static inline void trigger_target_v1(struct pw_node_target *t, uint64_t nsec)
 | 
					static inline int trigger_target_v1(struct pw_node_target *t, uint64_t nsec)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct pw_node_activation *a = t->activation;
 | 
						struct pw_node_activation *a = t->activation;
 | 
				
			||||||
	struct pw_node_activation_state *state = &a->state[0];
 | 
						struct pw_node_activation_state *state = &a->state[0];
 | 
				
			||||||
	int32_t pending = SPA_ATOMIC_DEC(state->pending);
 | 
						int32_t pending = SPA_ATOMIC_DEC(state->pending);
 | 
				
			||||||
 | 
						int res = pending == 0, r;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_log_trace_fp("%p: (%s-%u) state:%p pending:%d/%d", t->node,
 | 
						pw_log_trace_fp("%p: (%s-%u) state:%p pending:%d/%d", t->node,
 | 
				
			||||||
				t->name, t->id, state, pending, state->required);
 | 
									t->name, t->id, state, pending, state->required);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (pending == 0) {
 | 
						if (res) {
 | 
				
			||||||
		if (SPA_ATOMIC_CAS(a->status,
 | 
							if (SPA_LIKELY(SPA_ATOMIC_CAS(a->status,
 | 
				
			||||||
					PW_NODE_ACTIVATION_NOT_TRIGGERED,
 | 
										PW_NODE_ACTIVATION_NOT_TRIGGERED,
 | 
				
			||||||
					PW_NODE_ACTIVATION_TRIGGERED)) {
 | 
										PW_NODE_ACTIVATION_TRIGGERED))) {
 | 
				
			||||||
			a->signal_time = nsec;
 | 
								a->signal_time = nsec;
 | 
				
			||||||
			if (SPA_UNLIKELY(spa_system_eventfd_write(t->system, t->fd, 1) < 0))
 | 
								if (SPA_UNLIKELY((r = spa_system_eventfd_write(t->system, t->fd, 1)) < 0)) {
 | 
				
			||||||
				pw_log_warn("%p: write failed %m", t->node);
 | 
									pw_log_warn("%p: write failed %s", t->node, spa_strerror(r));
 | 
				
			||||||
 | 
									res = r;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			pw_log_trace_fp("%p: (%s-%u) not ready %d", t->node,
 | 
								pw_log_trace_fp("%p: (%s-%u) not ready %d", t->node,
 | 
				
			||||||
					t->name, t->id, a->status);
 | 
										t->name, t->id, a->status);
 | 
				
			||||||
 | 
								res = -EIO;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						return res;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline void trigger_target_v0(struct pw_node_target *t, uint64_t nsec)
 | 
					static inline int trigger_target_v0(struct pw_node_target *t, uint64_t nsec)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct pw_node_activation *a = t->activation;
 | 
						struct pw_node_activation *a = t->activation;
 | 
				
			||||||
	struct pw_node_activation_state *state = &a->state[0];
 | 
						struct pw_node_activation_state *state = &a->state[0];
 | 
				
			||||||
	int32_t pending = SPA_ATOMIC_DEC(state->pending);
 | 
						int32_t pending = SPA_ATOMIC_DEC(state->pending);
 | 
				
			||||||
 | 
						int res = pending == 0, r;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_log_trace_fp("%p: (%s-%u) state:%p pending:%d/%d", t->node,
 | 
						pw_log_trace_fp("%p: (%s-%u) state:%p pending:%d/%d", t->node,
 | 
				
			||||||
			t->name, t->id, state, pending, state->required);
 | 
								t->name, t->id, state, pending, state->required);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (pending == 0) {
 | 
						if (res) {
 | 
				
			||||||
		SPA_ATOMIC_STORE(a->status, PW_NODE_ACTIVATION_TRIGGERED);
 | 
							SPA_ATOMIC_STORE(a->status, PW_NODE_ACTIVATION_TRIGGERED);
 | 
				
			||||||
		a->signal_time = nsec;
 | 
							a->signal_time = nsec;
 | 
				
			||||||
		if (SPA_UNLIKELY(spa_system_eventfd_write(t->system, t->fd, 1) < 0))
 | 
							if (SPA_UNLIKELY((r = spa_system_eventfd_write(t->system, t->fd, 1)) < 0)) {
 | 
				
			||||||
			pw_log_warn("%p: write failed %m", t->node);
 | 
								res = r;
 | 
				
			||||||
 | 
								pw_log_warn("%p: write failed %s", t->node, spa_strerror(r));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						return res;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct pw_node_peer {
 | 
					struct pw_node_peer {
 | 
				
			||||||
	int ref;
 | 
						int ref;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2579,7 +2579,7 @@ int pw_stream_trigger_process(struct pw_stream *stream)
 | 
				
			||||||
	impl->using_trigger = true;
 | 
						impl->using_trigger = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (impl->trigger) {
 | 
						if (impl->trigger) {
 | 
				
			||||||
		pw_impl_node_trigger(stream->node);
 | 
							res = pw_impl_node_trigger(stream->node);
 | 
				
			||||||
	} else if (stream->node->driving) {
 | 
						} else if (stream->node->driving) {
 | 
				
			||||||
		res = pw_loop_invoke(impl->data_loop,
 | 
							res = pw_loop_invoke(impl->data_loop,
 | 
				
			||||||
			do_trigger_driver, 1, NULL, 0, false, impl);
 | 
								do_trigger_driver, 1, NULL, 0, false, impl);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue