mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	Added snd_*_poll_descriptors_revents functions.
This commit is contained in:
		
							parent
							
								
									23ab0b3509
								
							
						
					
					
						commit
						ddb7209e9a
					
				
					 15 changed files with 195 additions and 36 deletions
				
			
		| 
						 | 
				
			
			@ -1003,14 +1003,33 @@ int snd_pcm_poll_descriptors_count(snd_pcm_t *pcm)
 | 
			
		|||
 */
 | 
			
		||||
int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space)
 | 
			
		||||
{
 | 
			
		||||
	assert(pcm);
 | 
			
		||||
	if (space >= 1) {
 | 
			
		||||
	assert(pcm && pfds);
 | 
			
		||||
	if (space >= 1 && pfds) {
 | 
			
		||||
		pfds->fd = pcm->poll_fd;
 | 
			
		||||
		pfds->events = pcm->stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN;
 | 
			
		||||
	}
 | 
			
		||||
		pfds->events = pcm->stream == SND_PCM_STREAM_PLAYBACK ? (POLLOUT|POLLERR) : (POLLIN|POLLERR);
 | 
			
		||||
	} else
 | 
			
		||||
		return 0;
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \brief get returned events from poll descriptors
 | 
			
		||||
 * \param pcm PCM handle
 | 
			
		||||
 * \param pfds array of poll descriptors
 | 
			
		||||
 * \param nfds count of poll descriptors
 | 
			
		||||
 * \param revents returned events
 | 
			
		||||
 * \return zero if success, otherwise a negative error code
 | 
			
		||||
 */
 | 
			
		||||
int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
 | 
			
		||||
{
 | 
			
		||||
	assert(pcm && pfds && revents);
 | 
			
		||||
	if (nfds == 1) {
 | 
			
		||||
		*revents = pfds->revents;
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
	return -EINVAL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifndef DOC_HIDDEN
 | 
			
		||||
#define STATE(v) [SND_PCM_STATE_##v] = #v
 | 
			
		||||
#define STREAM(v) [SND_PCM_STREAM_##v] = #v
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue