mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: support: loop: add some invariant assertions
This commit is contained in:
		
							parent
							
								
									55ee5ec8b2
								
							
						
					
					
						commit
						cfc8510ce8
					
				
					 1 changed files with 18 additions and 2 deletions
				
			
		| 
						 | 
					@ -125,6 +125,9 @@ static int loop_add_source(void *object, struct spa_source *source)
 | 
				
			||||||
static int loop_update_source(void *object, struct spa_source *source)
 | 
					static int loop_update_source(void *object, struct spa_source *source)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct impl *impl = object;
 | 
						struct impl *impl = object;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spa_assert(source->loop == &impl->loop);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return spa_system_pollfd_mod(impl->system, impl->poll_fd, source->fd, source->mask, source);
 | 
						return spa_system_pollfd_mod(impl->system, impl->poll_fd, source->fd, source->mask, source);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -132,6 +135,9 @@ static int loop_remove_source(void *object, struct spa_source *source)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct impl *impl = object;
 | 
						struct impl *impl = object;
 | 
				
			||||||
	struct spa_poll_event *e;
 | 
						struct spa_poll_event *e;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spa_assert(source->loop == &impl->loop);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((e = source->priv)) {
 | 
						if ((e = source->priv)) {
 | 
				
			||||||
		/* active in an iteration of the loop, remove it from there */
 | 
							/* active in an iteration of the loop, remove it from there */
 | 
				
			||||||
		e->data = NULL;
 | 
							e->data = NULL;
 | 
				
			||||||
| 
						 | 
					@ -441,6 +447,8 @@ static int loop_update_io(void *object, struct spa_source *source, uint32_t mask
 | 
				
			||||||
	struct source_impl *s = SPA_CONTAINER_OF(source, struct source_impl, source);
 | 
						struct source_impl *s = SPA_CONTAINER_OF(source, struct source_impl, source);
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spa_assert(s->impl == object);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_log_trace(impl->log, "%p: update %08x -> %08x", s, source->mask, mask);
 | 
						spa_log_trace(impl->log, "%p: update %08x -> %08x", s, source->mask, mask);
 | 
				
			||||||
	source->mask = mask;
 | 
						source->mask = mask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -463,6 +471,8 @@ static int loop_enable_idle(void *object, struct spa_source *source, bool enable
 | 
				
			||||||
	struct source_impl *s = SPA_CONTAINER_OF(source, struct source_impl, source);
 | 
						struct source_impl *s = SPA_CONTAINER_OF(source, struct source_impl, source);
 | 
				
			||||||
	int res = 0;
 | 
						int res = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spa_assert(s->impl == object);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (enabled && !s->enabled) {
 | 
						if (enabled && !s->enabled) {
 | 
				
			||||||
		if ((res = spa_system_eventfd_write(s->impl->system, source->fd, 1)) < 0)
 | 
							if ((res = spa_system_eventfd_write(s->impl->system, source->fd, 1)) < 0)
 | 
				
			||||||
			spa_log_warn(s->impl->log, "%p: failed to write idle fd %d: %s",
 | 
								spa_log_warn(s->impl->log, "%p: failed to write idle fd %d: %s",
 | 
				
			||||||
| 
						 | 
					@ -576,6 +586,8 @@ static int loop_signal_event(void *object, struct spa_source *source)
 | 
				
			||||||
	struct source_impl *s = SPA_CONTAINER_OF(source, struct source_impl, source);
 | 
						struct source_impl *s = SPA_CONTAINER_OF(source, struct source_impl, source);
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spa_assert(s->impl == object);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (SPA_UNLIKELY((res = spa_system_eventfd_write(s->impl->system, source->fd, 1)) < 0))
 | 
						if (SPA_UNLIKELY((res = spa_system_eventfd_write(s->impl->system, source->fd, 1)) < 0))
 | 
				
			||||||
		spa_log_warn(s->impl->log, "%p: failed to write event fd %d: %s",
 | 
							spa_log_warn(s->impl->log, "%p: failed to write event fd %d: %s",
 | 
				
			||||||
				source, source->fd, spa_strerror(res));
 | 
									source, source->fd, spa_strerror(res));
 | 
				
			||||||
| 
						 | 
					@ -640,10 +652,12 @@ static int
 | 
				
			||||||
loop_update_timer(void *object, struct spa_source *source,
 | 
					loop_update_timer(void *object, struct spa_source *source,
 | 
				
			||||||
		  struct timespec *value, struct timespec *interval, bool absolute)
 | 
							  struct timespec *value, struct timespec *interval, bool absolute)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct impl *impl = object;
 | 
						struct source_impl *s = SPA_CONTAINER_OF(source, struct source_impl, source);
 | 
				
			||||||
	struct itimerspec its;
 | 
						struct itimerspec its;
 | 
				
			||||||
	int flags = 0, res;
 | 
						int flags = 0, res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spa_assert(s->impl == object);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_zero(its);
 | 
						spa_zero(its);
 | 
				
			||||||
	if (SPA_LIKELY(value)) {
 | 
						if (SPA_LIKELY(value)) {
 | 
				
			||||||
		its.it_value = *value;
 | 
							its.it_value = *value;
 | 
				
			||||||
| 
						 | 
					@ -656,7 +670,7 @@ loop_update_timer(void *object, struct spa_source *source,
 | 
				
			||||||
	if (SPA_LIKELY(absolute))
 | 
						if (SPA_LIKELY(absolute))
 | 
				
			||||||
		flags |= SPA_FD_TIMER_ABSTIME;
 | 
							flags |= SPA_FD_TIMER_ABSTIME;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (SPA_UNLIKELY((res = spa_system_timerfd_settime(impl->system, source->fd, flags, &its, NULL)) < 0))
 | 
						if (SPA_UNLIKELY((res = spa_system_timerfd_settime(s->impl->system, source->fd, flags, &its, NULL)) < 0))
 | 
				
			||||||
		return res;
 | 
							return res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -719,6 +733,8 @@ static void loop_destroy_source(void *object, struct spa_source *source)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct source_impl *s = SPA_CONTAINER_OF(source, struct source_impl, source);
 | 
						struct source_impl *s = SPA_CONTAINER_OF(source, struct source_impl, source);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spa_assert(s->impl == object);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_log_trace(s->impl->log, "%p ", s);
 | 
						spa_log_trace(s->impl->log, "%p ", s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_list_remove(&s->link);
 | 
						spa_list_remove(&s->link);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue