mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	Recoded the universal switch interface...
This commit is contained in:
		
							parent
							
								
									a5b307a711
								
							
						
					
					
						commit
						6e72ca3977
					
				
					 8 changed files with 42 additions and 204 deletions
				
			
		| 
						 | 
				
			
			@ -450,3 +450,36 @@ int snd_ctl_rawmidi_input_switch_write(void *handle, int dev, snd_switch_t * sw)
 | 
			
		|||
		return -errno;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_control_read(void *handle, snd_ctl_callbacks_t * callbacks)
 | 
			
		||||
{
 | 
			
		||||
	snd_ctl_t *ctl;
 | 
			
		||||
	int result, count;
 | 
			
		||||
	snd_ctl_read_t r;
 | 
			
		||||
 | 
			
		||||
	ctl = (snd_ctl_t *) handle;
 | 
			
		||||
	if (!ctl)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
	count = 0;
 | 
			
		||||
	while ((result = read(ctl->fd, &r, sizeof(r))) > 0) {
 | 
			
		||||
		if (result != sizeof(r))
 | 
			
		||||
			return -EIO;
 | 
			
		||||
		if (!callbacks)
 | 
			
		||||
			continue;
 | 
			
		||||
		switch (r.cmd) {
 | 
			
		||||
		case SND_CTL_READ_REBUILD:
 | 
			
		||||
			if (callbacks->rebuild)
 | 
			
		||||
				callbacks->rebuild(callbacks->private_data);
 | 
			
		||||
			break;
 | 
			
		||||
		case SND_CTL_READ_SWITCH_VALUE:
 | 
			
		||||
		case SND_CTL_READ_SWITCH_CHANGE:
 | 
			
		||||
		case SND_CTL_READ_SWITCH_ADD:
 | 
			
		||||
		case SND_CTL_READ_SWITCH_REMOVE:
 | 
			
		||||
			if (callbacks->xswitch)
 | 
			
		||||
				callbacks->xswitch(callbacks->private_data, r.cmd, r.data.sw.iface, &r.data.sw.switem);
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		count++;
 | 
			
		||||
	}
 | 
			
		||||
	return result >= 0 ? count : -errno;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue