mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	control.c: snd_ctl_wait: fix revents handling
The revents parameter of snd_ctl_poll_descriptors_revents() is a single value, not an array. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
This commit is contained in:
		
							parent
							
								
									f3dc8e2aa4
								
							
						
					
					
						commit
						34d63b449f
					
				
					 1 changed files with 10 additions and 17 deletions
				
			
		| 
						 | 
					@ -674,8 +674,8 @@ int snd_ctl_read(snd_ctl_t *ctl, snd_ctl_event_t *event)
 | 
				
			||||||
int snd_ctl_wait(snd_ctl_t *ctl, int timeout)
 | 
					int snd_ctl_wait(snd_ctl_t *ctl, int timeout)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct pollfd *pfd;
 | 
						struct pollfd *pfd;
 | 
				
			||||||
	unsigned short *revents;
 | 
						unsigned short revents;
 | 
				
			||||||
	int i, npfds, pollio, err, err_poll;
 | 
						int i, npfds, err, err_poll;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	npfds = snd_ctl_poll_descriptors_count(ctl);
 | 
						npfds = snd_ctl_poll_descriptors_count(ctl);
 | 
				
			||||||
	if (npfds <= 0 || npfds >= 16) {
 | 
						if (npfds <= 0 || npfds >= 16) {
 | 
				
			||||||
| 
						 | 
					@ -683,7 +683,6 @@ int snd_ctl_wait(snd_ctl_t *ctl, int timeout)
 | 
				
			||||||
		return -EIO;
 | 
							return -EIO;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pfd = alloca(sizeof(*pfd) * npfds);
 | 
						pfd = alloca(sizeof(*pfd) * npfds);
 | 
				
			||||||
	revents = alloca(sizeof(*revents) * npfds);
 | 
					 | 
				
			||||||
	err = snd_ctl_poll_descriptors(ctl, pfd, npfds);
 | 
						err = snd_ctl_poll_descriptors(ctl, pfd, npfds);
 | 
				
			||||||
	if (err < 0)
 | 
						if (err < 0)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
| 
						 | 
					@ -691,26 +690,20 @@ int snd_ctl_wait(snd_ctl_t *ctl, int timeout)
 | 
				
			||||||
		SNDMSG("invalid poll descriptors %d\n", err);
 | 
							SNDMSG("invalid poll descriptors %d\n", err);
 | 
				
			||||||
		return -EIO;
 | 
							return -EIO;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	do {
 | 
						for (;;) {
 | 
				
			||||||
		err_poll = poll(pfd, npfds, timeout);
 | 
							err_poll = poll(pfd, npfds, timeout);
 | 
				
			||||||
		if (err_poll < 0)
 | 
							if (err_poll < 0)
 | 
				
			||||||
			return -errno;
 | 
								return -errno;
 | 
				
			||||||
		if (! err_poll)
 | 
							if (! err_poll)
 | 
				
			||||||
			break;
 | 
								return 0;
 | 
				
			||||||
		err = snd_ctl_poll_descriptors_revents(ctl, pfd, npfds, revents);
 | 
							err = snd_ctl_poll_descriptors_revents(ctl, pfd, npfds, &revents);
 | 
				
			||||||
		if (err < 0)
 | 
							if (err < 0)
 | 
				
			||||||
			return err;
 | 
								return err;
 | 
				
			||||||
		pollio = 0;
 | 
							if (revents & (POLLERR | POLLNVAL))
 | 
				
			||||||
		for (i = 0; i < npfds; i++) {
 | 
					 | 
				
			||||||
			if (revents[i] & (POLLERR | POLLNVAL))
 | 
					 | 
				
			||||||
			return -EIO;
 | 
								return -EIO;
 | 
				
			||||||
			if ((revents[i] & (POLLIN | POLLOUT)) == 0)
 | 
							if (revents & (POLLIN | POLLOUT))
 | 
				
			||||||
				continue;
 | 
								return 1;
 | 
				
			||||||
			pollio++;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	} while (! pollio);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return err_poll > 0 ? 1 : 0;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue