mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	handle read from timerfd correctly
When reading the timerfd gives an error, we should return right away because the timeout did not happen. If we change the timerfd timeout before reading it, we can get -EAGAIN. Don't log an error in that case but wait for the new timeout.
This commit is contained in:
		
							parent
							
								
									3a443b4e1c
								
							
						
					
					
						commit
						f44d55f6c2
					
				
					 14 changed files with 153 additions and 55 deletions
				
			
		| 
						 | 
				
			
			@ -267,14 +267,20 @@ static void set_timer(struct impl *this, bool enabled)
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void read_timer(struct impl *this)
 | 
			
		||||
static int read_timer(struct impl *this)
 | 
			
		||||
{
 | 
			
		||||
	uint64_t expirations;
 | 
			
		||||
	int res = 0;
 | 
			
		||||
 | 
			
		||||
	if (this->async || this->props.live) {
 | 
			
		||||
		if (spa_system_timerfd_read(this->data_system, this->timer_source.fd, &expirations) < 0)
 | 
			
		||||
			perror("read timerfd");
 | 
			
		||||
		if ((res = spa_system_timerfd_read(this->data_system,
 | 
			
		||||
						this->timer_source.fd, &expirations)) < 0) {
 | 
			
		||||
			if (res != -EAGAIN)
 | 
			
		||||
				spa_log_error(this->log, NAME " %p: timerfd error: %s",
 | 
			
		||||
						this, spa_strerror(res));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return res;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int make_buffer(struct impl *this)
 | 
			
		||||
| 
						 | 
				
			
			@ -284,7 +290,8 @@ static int make_buffer(struct impl *this)
 | 
			
		|||
	uint32_t n_bytes;
 | 
			
		||||
	int res;
 | 
			
		||||
 | 
			
		||||
	read_timer(this);
 | 
			
		||||
	if (read_timer(this) < 0)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	if ((res = spa_vulkan_ready(&this->state)) < 0) {
 | 
			
		||||
		res = SPA_STATUS_OK;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue