mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	Coding style...
This commit is contained in:
		
							parent
							
								
									2605e4d7dd
								
							
						
					
					
						commit
						a741225e6e
					
				
					 6 changed files with 1345 additions and 1223 deletions
				
			
		| 
						 | 
					@ -43,9 +43,11 @@ int snd_ctl_open( void **handle, int card )
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*handle = NULL;
 | 
						*handle = NULL;
 | 
				
			||||||
  if ( card < 0 || card >= SND_CARDS ) return -EINVAL;
 | 
						if (card < 0 || card >= SND_CARDS)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	sprintf(filename, SND_FILE_CONTROL, card);
 | 
						sprintf(filename, SND_FILE_CONTROL, card);
 | 
				
			||||||
  if ( (fd = open( filename, O_RDWR )) < 0 ) return -errno;
 | 
						if ((fd = open(filename, O_RDWR)) < 0)
 | 
				
			||||||
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(fd, SND_CTL_IOCTL_PVERSION, &ver) < 0) {
 | 
						if (ioctl(fd, SND_CTL_IOCTL_PVERSION, &ver) < 0) {
 | 
				
			||||||
		close(fd);
 | 
							close(fd);
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -71,7 +73,8 @@ int snd_ctl_close( void *handle )
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	res = close(ctl->fd) < 0 ? -errno : 0;
 | 
						res = close(ctl->fd) < 0 ? -errno : 0;
 | 
				
			||||||
	free(ctl);
 | 
						free(ctl);
 | 
				
			||||||
	return res;
 | 
						return res;
 | 
				
			||||||
| 
						 | 
					@ -82,7 +85,8 @@ int snd_ctl_file_descriptor( void *handle )
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	return ctl->fd;
 | 
						return ctl->fd;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,7 +95,8 @@ int snd_ctl_hw_info( void *handle, struct snd_ctl_hw_info *info )
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_HW_INFO, info) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_HW_INFO, info) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -103,7 +108,8 @@ int snd_ctl_switches( void *handle )
 | 
				
			||||||
	int result;
 | 
						int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_SWITCHES, &result) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_SWITCHES, &result) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
| 
						 | 
					@ -116,7 +122,8 @@ int snd_ctl_switch( void *handle, const char *switch_id )
 | 
				
			||||||
	int idx, switches, err;
 | 
						int idx, switches, err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	/* bellow implementation isn't optimized for speed */
 | 
						/* bellow implementation isn't optimized for speed */
 | 
				
			||||||
	/* info about switches should be cached in the snd_ctl_t structure */
 | 
						/* info about switches should be cached in the snd_ctl_t structure */
 | 
				
			||||||
	if ((switches = snd_ctl_switches(handle)) < 0)
 | 
						if ((switches = snd_ctl_switches(handle)) < 0)
 | 
				
			||||||
| 
						 | 
					@ -135,7 +142,8 @@ int snd_ctl_switch_read( void *handle, int switchn, struct snd_ctl_switch *data
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_SWITCH_READ, data) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_SWITCH_READ, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -147,7 +155,8 @@ int snd_ctl_switch_write( void *handle, int switchn, struct snd_ctl_switch *data
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_SWITCH_WRITE, data) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_SWITCH_WRITE, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -159,7 +168,8 @@ int snd_ctl_pcm_info( void *handle, int dev, snd_pcm_info_t *info )
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_INFO, info) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_INFO, info) < 0)
 | 
				
			||||||
| 
						 | 
					@ -172,7 +182,8 @@ int snd_ctl_pcm_playback_info( void *handle, int dev, snd_pcm_playback_info_t *i
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_PLAYBACK_INFO, info) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_PLAYBACK_INFO, info) < 0)
 | 
				
			||||||
| 
						 | 
					@ -185,7 +196,8 @@ int snd_ctl_pcm_record_info( void *handle, int dev, snd_pcm_record_info_t *info
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_RECORD_INFO, info) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_RECORD_INFO, info) < 0)
 | 
				
			||||||
| 
						 | 
					@ -199,7 +211,8 @@ int snd_ctl_pcm_playback_switches( void *handle, int dev )
 | 
				
			||||||
	int result;
 | 
						int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_PSWITCHES, &result) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_PSWITCHES, &result) < 0)
 | 
				
			||||||
| 
						 | 
					@ -214,7 +227,8 @@ int snd_ctl_pcm_playback_switch( void *handle, int dev, const char *switch_id )
 | 
				
			||||||
	int idx, switches, err;
 | 
						int idx, switches, err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	/* bellow implementation isn't optimized for speed */
 | 
						/* bellow implementation isn't optimized for speed */
 | 
				
			||||||
	/* info about switches should be cached in the snd_ctl_t structure */
 | 
						/* info about switches should be cached in the snd_ctl_t structure */
 | 
				
			||||||
	if ((switches = snd_ctl_pcm_playback_switches(handle, dev)) < 0)
 | 
						if ((switches = snd_ctl_pcm_playback_switches(handle, dev)) < 0)
 | 
				
			||||||
| 
						 | 
					@ -233,7 +247,8 @@ int snd_ctl_pcm_playback_switch_read( void *handle, int dev, int switchn, snd_pc
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -247,7 +262,8 @@ int snd_ctl_pcm_playback_switch_write( void *handle, int dev, int switchn, snd_p
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -262,7 +278,8 @@ int snd_ctl_pcm_record_switches( void *handle, int dev )
 | 
				
			||||||
	int result;
 | 
						int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_RSWITCHES, &result) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_RSWITCHES, &result) < 0)
 | 
				
			||||||
| 
						 | 
					@ -277,7 +294,8 @@ int snd_ctl_pcm_record_switch( void *handle, int dev, const char *switch_id )
 | 
				
			||||||
	int idx, switches, err;
 | 
						int idx, switches, err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	/* bellow implementation isn't optimized for speed */
 | 
						/* bellow implementation isn't optimized for speed */
 | 
				
			||||||
	/* info about switches should be cached in the snd_ctl_t structure */
 | 
						/* info about switches should be cached in the snd_ctl_t structure */
 | 
				
			||||||
	if ((switches = snd_ctl_pcm_record_switches(handle, dev)) < 0)
 | 
						if ((switches = snd_ctl_pcm_record_switches(handle, dev)) < 0)
 | 
				
			||||||
| 
						 | 
					@ -296,7 +314,8 @@ int snd_ctl_pcm_record_switch_read( void *handle, int dev, int switchn, snd_pcm_
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -310,7 +329,8 @@ int snd_ctl_pcm_record_switch_write( void *handle, int dev, int switchn, snd_pcm
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -324,7 +344,8 @@ int snd_ctl_mixer_info( void *handle, int dev, snd_mixer_info_t *info )
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_MIXER_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_MIXER_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_MIXER_INFO, info) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_MIXER_INFO, info) < 0)
 | 
				
			||||||
| 
						 | 
					@ -338,7 +359,8 @@ int snd_ctl_mixer_switches( void *handle, int dev )
 | 
				
			||||||
	int result;
 | 
						int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_MIXER_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_MIXER_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_MIXER_SWITCHES, &result) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_MIXER_SWITCHES, &result) < 0)
 | 
				
			||||||
| 
						 | 
					@ -353,7 +375,8 @@ int snd_ctl_mixer_switch( void *handle, int dev, const char *switch_id )
 | 
				
			||||||
	int idx, switches, err;
 | 
						int idx, switches, err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	/* bellow implementation isn't optimized for speed */
 | 
						/* bellow implementation isn't optimized for speed */
 | 
				
			||||||
	/* info about switches should be cached in the snd_ctl_t structure */
 | 
						/* info about switches should be cached in the snd_ctl_t structure */
 | 
				
			||||||
	if ((switches = snd_ctl_mixer_switches(handle, dev)) < 0)
 | 
						if ((switches = snd_ctl_mixer_switches(handle, dev)) < 0)
 | 
				
			||||||
| 
						 | 
					@ -372,7 +395,8 @@ int snd_ctl_mixer_switch_read( void *handle, int dev, int switchn, snd_mixer_swi
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_MIXER_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_MIXER_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -386,7 +410,8 @@ int snd_ctl_mixer_switch_write( void *handle, int dev, int switchn, snd_mixer_sw
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_MIXER_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_MIXER_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -400,7 +425,8 @@ int snd_ctl_rawmidi_info( void *handle, int dev, snd_rawmidi_info_t *info )
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_INFO, info) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_INFO, info) < 0)
 | 
				
			||||||
| 
						 | 
					@ -413,7 +439,8 @@ int snd_ctl_rawmidi_output_info( void *handle, int dev, snd_rawmidi_output_info_
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_OUTPUT_INFO, info) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_OUTPUT_INFO, info) < 0)
 | 
				
			||||||
| 
						 | 
					@ -426,7 +453,8 @@ int snd_ctl_rawmidi_input_info( void *handle, int dev, snd_rawmidi_input_info_t
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_INPUT_INFO, info) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_INPUT_INFO, info) < 0)
 | 
				
			||||||
| 
						 | 
					@ -440,7 +468,8 @@ int snd_ctl_rawmidi_output_switches( void *handle, int dev )
 | 
				
			||||||
	int result;
 | 
						int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_OSWITCHES, &result) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_OSWITCHES, &result) < 0)
 | 
				
			||||||
| 
						 | 
					@ -455,7 +484,8 @@ int snd_ctl_rawmidi_output_switch( void *handle, int dev, const char *switch_id
 | 
				
			||||||
	int idx, switches, err;
 | 
						int idx, switches, err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	/* bellow implementation isn't optimized for speed */
 | 
						/* bellow implementation isn't optimized for speed */
 | 
				
			||||||
	/* info about switches should be cached in the snd_ctl_t structure */
 | 
						/* info about switches should be cached in the snd_ctl_t structure */
 | 
				
			||||||
	if ((switches = snd_ctl_rawmidi_output_switches(handle, dev)) < 0)
 | 
						if ((switches = snd_ctl_rawmidi_output_switches(handle, dev)) < 0)
 | 
				
			||||||
| 
						 | 
					@ -474,7 +504,8 @@ int snd_ctl_rawmidi_output_switch_read( void *handle, int dev, int switchn, snd_
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -488,7 +519,8 @@ int snd_ctl_rawmidi_output_switch_write( void *handle, int dev, int switchn, snd
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -503,7 +535,8 @@ int snd_ctl_rawmidi_input_switches( void *handle, int dev )
 | 
				
			||||||
	int result;
 | 
						int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_ISWITCHES, &result) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_ISWITCHES, &result) < 0)
 | 
				
			||||||
| 
						 | 
					@ -518,7 +551,8 @@ int snd_ctl_rawmidi_input_switch( void *handle, int dev, const char *switch_id )
 | 
				
			||||||
	int idx, switches, err;
 | 
						int idx, switches, err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	/* bellow implementation isn't optimized for speed */
 | 
						/* bellow implementation isn't optimized for speed */
 | 
				
			||||||
	/* info about switches should be cached in the snd_ctl_t structure */
 | 
						/* info about switches should be cached in the snd_ctl_t structure */
 | 
				
			||||||
	if ((switches = snd_ctl_rawmidi_input_switches(handle, dev)) < 0)
 | 
						if ((switches = snd_ctl_rawmidi_input_switches(handle, dev)) < 0)
 | 
				
			||||||
| 
						 | 
					@ -537,7 +571,8 @@ int snd_ctl_rawmidi_input_switch_read( void *handle, int dev, int switchn, snd_r
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -551,7 +586,8 @@ int snd_ctl_rawmidi_input_switch_write( void *handle, int dev, int switchn, snd_
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctl = (snd_ctl_t *) handle;
 | 
						ctl = (snd_ctl_t *) handle;
 | 
				
			||||||
  if ( !ctl ) return -EINVAL;
 | 
						if (!ctl)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
						if (ioctl(ctl->fd, SND_CTL_IOCTL_RAWMIDI_DEVICE, &dev) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,13 +26,15 @@
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include "asoundlib.h"
 | 
					#include "asoundlib.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const char *snd_error_codes[] = {
 | 
					static const char *snd_error_codes[] =
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
	"Sound protocol isn't compatible"
 | 
						"Sound protocol isn't compatible"
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *snd_strerror(int errnum)
 | 
					const char *snd_strerror(int errnum)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if ( errnum < 0 ) errnum = -errnum;
 | 
						if (errnum < 0)
 | 
				
			||||||
 | 
							errnum = -errnum;
 | 
				
			||||||
	if (errnum < SND_ERROR_BEGIN)
 | 
						if (errnum < SND_ERROR_BEGIN)
 | 
				
			||||||
		return (const char *) strerror(errnum);
 | 
							return (const char *) strerror(errnum);
 | 
				
			||||||
	errnum -= SND_ERROR_BEGIN;
 | 
						errnum -= SND_ERROR_BEGIN;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,9 +44,11 @@ int snd_mixer_open( void **handle, int card, int device )
 | 
				
			||||||
	snd_mixer_t *mixer;
 | 
						snd_mixer_t *mixer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*handle = NULL;
 | 
						*handle = NULL;
 | 
				
			||||||
  if ( card < 0 || card >= SND_CARDS ) return -EINVAL;
 | 
						if (card < 0 || card >= SND_CARDS)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	sprintf(filename, SND_FILE_MIXER, card, device);
 | 
						sprintf(filename, SND_FILE_MIXER, card, device);
 | 
				
			||||||
  if ( (fd = open( filename, O_RDWR )) < 0 ) return -errno;
 | 
						if ((fd = open(filename, O_RDWR)) < 0)
 | 
				
			||||||
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(fd, SND_MIXER_IOCTL_PVERSION, &ver) < 0) {
 | 
						if (ioctl(fd, SND_MIXER_IOCTL_PVERSION, &ver) < 0) {
 | 
				
			||||||
		close(fd);
 | 
							close(fd);
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -73,7 +75,8 @@ int snd_mixer_close( void *handle )
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	res = close(mixer->fd) < 0 ? -errno : 0;
 | 
						res = close(mixer->fd) < 0 ? -errno : 0;
 | 
				
			||||||
	free(mixer);
 | 
						free(mixer);
 | 
				
			||||||
	return res;
 | 
						return res;
 | 
				
			||||||
| 
						 | 
					@ -84,7 +87,8 @@ int snd_mixer_file_descriptor( void *handle )
 | 
				
			||||||
	snd_mixer_t *mixer;
 | 
						snd_mixer_t *mixer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	return mixer->fd;
 | 
						return mixer->fd;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,7 +98,8 @@ int snd_mixer_channels( void *handle )
 | 
				
			||||||
	int result;
 | 
						int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(mixer->fd, SND_MIXER_IOCTL_CHANNELS, &result) < 0)
 | 
						if (ioctl(mixer->fd, SND_MIXER_IOCTL_CHANNELS, &result) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
| 
						 | 
					@ -105,7 +110,8 @@ int snd_mixer_info( void *handle, snd_mixer_info_t *info )
 | 
				
			||||||
	snd_mixer_t *mixer;
 | 
						snd_mixer_t *mixer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(mixer->fd, SND_MIXER_IOCTL_INFO, info) < 0)
 | 
						if (ioctl(mixer->fd, SND_MIXER_IOCTL_INFO, info) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -116,7 +122,8 @@ int snd_mixer_exact_mode( void *handle, int enable )
 | 
				
			||||||
	snd_mixer_t *mixer;
 | 
						snd_mixer_t *mixer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(mixer->fd, SND_MIXER_IOCTL_EXACT, &enable) < 0)
 | 
						if (ioctl(mixer->fd, SND_MIXER_IOCTL_EXACT, &enable) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -129,7 +136,8 @@ int snd_mixer_channel( void *handle, const char *channel_id )
 | 
				
			||||||
	int idx, channels, err;
 | 
						int idx, channels, err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	/* bellow implementation isn't optimized for speed */
 | 
						/* bellow implementation isn't optimized for speed */
 | 
				
			||||||
	/* info about channels should be cached in the snd_mixer_t structure */
 | 
						/* info about channels should be cached in the snd_mixer_t structure */
 | 
				
			||||||
	if ((channels = snd_mixer_channels(handle)) < 0)
 | 
						if ((channels = snd_mixer_channels(handle)) < 0)
 | 
				
			||||||
| 
						 | 
					@ -148,7 +156,8 @@ int snd_mixer_channel_info( void *handle, int channel, snd_mixer_channel_info_t
 | 
				
			||||||
	snd_mixer_t *mixer;
 | 
						snd_mixer_t *mixer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	info->channel = channel;
 | 
						info->channel = channel;
 | 
				
			||||||
	if (ioctl(mixer->fd, SND_MIXER_IOCTL_CHANNEL_INFO, info) < 0)
 | 
						if (ioctl(mixer->fd, SND_MIXER_IOCTL_CHANNEL_INFO, info) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -160,7 +169,8 @@ int snd_mixer_channel_read( void *handle, int channel, snd_mixer_channel_t *data
 | 
				
			||||||
	snd_mixer_t *mixer;
 | 
						snd_mixer_t *mixer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->channel = channel;
 | 
						data->channel = channel;
 | 
				
			||||||
	if (ioctl(mixer->fd, SND_MIXER_IOCTL_CHANNEL_READ, data) < 0)
 | 
						if (ioctl(mixer->fd, SND_MIXER_IOCTL_CHANNEL_READ, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -172,7 +182,8 @@ int snd_mixer_channel_write( void *handle, int channel, snd_mixer_channel_t *dat
 | 
				
			||||||
	snd_mixer_t *mixer;
 | 
						snd_mixer_t *mixer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->channel = channel;
 | 
						data->channel = channel;
 | 
				
			||||||
	if (ioctl(mixer->fd, SND_MIXER_IOCTL_CHANNEL_WRITE, data) < 0)
 | 
						if (ioctl(mixer->fd, SND_MIXER_IOCTL_CHANNEL_WRITE, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -185,7 +196,8 @@ int snd_mixer_switches( void *handle )
 | 
				
			||||||
	int result;
 | 
						int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(mixer->fd, SND_MIXER_IOCTL_SWITCHES, &result) < 0)
 | 
						if (ioctl(mixer->fd, SND_MIXER_IOCTL_SWITCHES, &result) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
| 
						 | 
					@ -198,7 +210,8 @@ int snd_mixer_switch( void *handle, const char *switch_id )
 | 
				
			||||||
	int idx, switches, err;
 | 
						int idx, switches, err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	/* bellow implementation isn't optimized for speed */
 | 
						/* bellow implementation isn't optimized for speed */
 | 
				
			||||||
	/* info about switches should be cached in the snd_mixer_t structure */
 | 
						/* info about switches should be cached in the snd_mixer_t structure */
 | 
				
			||||||
	if ((switches = snd_mixer_switches(handle)) < 0)
 | 
						if ((switches = snd_mixer_switches(handle)) < 0)
 | 
				
			||||||
| 
						 | 
					@ -217,7 +230,8 @@ int snd_mixer_switch_read( void *handle, int switchn, snd_mixer_switch_t *data )
 | 
				
			||||||
	snd_mixer_t *mixer;
 | 
						snd_mixer_t *mixer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(mixer->fd, SND_MIXER_IOCTL_SWITCH_READ, data) < 0)
 | 
						if (ioctl(mixer->fd, SND_MIXER_IOCTL_SWITCH_READ, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -229,7 +243,8 @@ int snd_mixer_switch_write( void *handle, int switchn, snd_mixer_switch_t *data
 | 
				
			||||||
	snd_mixer_t *mixer;
 | 
						snd_mixer_t *mixer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(mixer->fd, SND_MIXER_IOCTL_SWITCH_WRITE, data) < 0)
 | 
						if (ioctl(mixer->fd, SND_MIXER_IOCTL_SWITCH_WRITE, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -244,11 +259,14 @@ int snd_mixer_read( void *handle, snd_mixer_callbacks_t *callbacks )
 | 
				
			||||||
	unsigned char buffer[64];
 | 
						unsigned char buffer[64];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mixer = (snd_mixer_t *) handle;
 | 
						mixer = (snd_mixer_t *) handle;
 | 
				
			||||||
  if ( !mixer ) return -EINVAL;
 | 
						if (!mixer)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	count = 0;
 | 
						count = 0;
 | 
				
			||||||
	while ((result = read(mixer->fd, &buffer, sizeof(buffer))) > 0) {
 | 
						while ((result = read(mixer->fd, &buffer, sizeof(buffer))) > 0) {
 | 
				
			||||||
    if ( result & 7 ) return -EIO;
 | 
							if (result & 7)
 | 
				
			||||||
    if ( !callbacks ) continue;
 | 
								return -EIO;
 | 
				
			||||||
 | 
							if (!callbacks)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
		for (idx = 0; idx < result; idx += 8) {
 | 
							for (idx = 0; idx < result; idx += 8) {
 | 
				
			||||||
			cmd = *(unsigned int *) &buffer[idx];
 | 
								cmd = *(unsigned int *) &buffer[idx];
 | 
				
			||||||
			tmp = *(unsigned int *) &buffer[idx + 4];
 | 
								tmp = *(unsigned int *) &buffer[idx + 4];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,9 +44,11 @@ int snd_pcm_open( void **handle, int card, int device, int mode )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*handle = NULL;
 | 
						*handle = NULL;
 | 
				
			||||||
  if ( card < 0 || card >= SND_CARDS ) return -EINVAL;
 | 
						if (card < 0 || card >= SND_CARDS)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	sprintf(filename, SND_FILE_PCM, card, device);
 | 
						sprintf(filename, SND_FILE_PCM, card, device);
 | 
				
			||||||
  if ( (fd = open( filename, mode )) < 0 ) return -errno;
 | 
						if ((fd = open(filename, mode)) < 0)
 | 
				
			||||||
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(fd, SND_PCM_IOCTL_PVERSION, &ver) < 0) {
 | 
						if (ioctl(fd, SND_PCM_IOCTL_PVERSION, &ver) < 0) {
 | 
				
			||||||
		close(fd);
 | 
							close(fd);
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -73,7 +75,8 @@ int snd_pcm_close( void *handle )
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	res = close(pcm->fd) < 0 ? -errno : 0;
 | 
						res = close(pcm->fd) < 0 ? -errno : 0;
 | 
				
			||||||
	free(pcm);
 | 
						free(pcm);
 | 
				
			||||||
	return res;
 | 
						return res;
 | 
				
			||||||
| 
						 | 
					@ -84,7 +87,8 @@ int snd_pcm_file_descriptor( void *handle )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	return pcm->fd;
 | 
						return pcm->fd;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,7 +98,8 @@ int snd_pcm_block_mode( void *handle, int enable )
 | 
				
			||||||
	long flags;
 | 
						long flags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (fcntl(pcm->fd, F_GETFL, &flags) < 0)
 | 
						if (fcntl(pcm->fd, F_GETFL, &flags) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (enable)
 | 
						if (enable)
 | 
				
			||||||
| 
						 | 
					@ -111,7 +116,8 @@ int snd_pcm_info( void *handle, snd_pcm_info_t *info )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_INFO, info) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_INFO, info) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -122,7 +128,8 @@ int snd_pcm_playback_info( void *handle, snd_pcm_playback_info_t *info )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_PLAYBACK_INFO, info) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_PLAYBACK_INFO, info) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -133,7 +140,8 @@ int snd_pcm_record_info( void *handle, snd_pcm_record_info_t *info )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_INFO, info) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_INFO, info) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -145,7 +153,8 @@ int snd_pcm_playback_switches( void *handle )
 | 
				
			||||||
	int result;
 | 
						int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_PSWITCHES, &result) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_PSWITCHES, &result) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
| 
						 | 
					@ -158,7 +167,8 @@ int snd_pcm_playback_switch( void *handle, const char *switch_id )
 | 
				
			||||||
	int idx, switches, err;
 | 
						int idx, switches, err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	/* bellow implementation isn't optimized for speed */
 | 
						/* bellow implementation isn't optimized for speed */
 | 
				
			||||||
	/* info about switches should be cached in the snd_mixer_t structure */
 | 
						/* info about switches should be cached in the snd_mixer_t structure */
 | 
				
			||||||
	if ((switches = snd_pcm_playback_switches(handle)) < 0)
 | 
						if ((switches = snd_pcm_playback_switches(handle)) < 0)
 | 
				
			||||||
| 
						 | 
					@ -177,7 +187,8 @@ int snd_pcm_playback_switch_read( void *handle, int switchn, snd_pcm_switch_t *d
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_PSWITCH_READ, data) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_PSWITCH_READ, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -189,7 +200,8 @@ int snd_pcm_playback_switch_write( void *handle, int switchn, snd_pcm_switch_t *
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_PSWITCH_WRITE, data) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_PSWITCH_WRITE, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -202,7 +214,8 @@ int snd_pcm_record_switches( void *handle )
 | 
				
			||||||
	int result;
 | 
						int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_RSWITCHES, &result) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_RSWITCHES, &result) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
| 
						 | 
					@ -215,7 +228,8 @@ int snd_pcm_record_switch( void *handle, const char *switch_id )
 | 
				
			||||||
	int idx, switches, err;
 | 
						int idx, switches, err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	/* bellow implementation isn't optimized for speed */
 | 
						/* bellow implementation isn't optimized for speed */
 | 
				
			||||||
	/* info about switches should be cached in the snd_mixer_t structure */
 | 
						/* info about switches should be cached in the snd_mixer_t structure */
 | 
				
			||||||
	if ((switches = snd_pcm_record_switches(handle)) < 0)
 | 
						if ((switches = snd_pcm_record_switches(handle)) < 0)
 | 
				
			||||||
| 
						 | 
					@ -234,7 +248,8 @@ int snd_pcm_record_switch_read( void *handle, int switchn, snd_pcm_switch_t *dat
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_RSWITCH_READ, data) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_RSWITCH_READ, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -246,7 +261,8 @@ int snd_pcm_record_switch_write( void *handle, int switchn, snd_pcm_switch_t *da
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_RSWITCH_WRITE, data) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_RSWITCH_WRITE, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -258,7 +274,8 @@ int snd_pcm_playback_format( void *handle, snd_pcm_format_t *format )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_PLAYBACK_FORMAT, format) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_PLAYBACK_FORMAT, format) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -269,7 +286,8 @@ int snd_pcm_record_format( void *handle, snd_pcm_format_t *format )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_FORMAT, format) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_FORMAT, format) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -280,7 +298,8 @@ int snd_pcm_playback_params( void *handle, snd_pcm_playback_params_t *params )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_PLAYBACK_PARAMS, params) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_PLAYBACK_PARAMS, params) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -291,7 +310,8 @@ int snd_pcm_record_params( void *handle, snd_pcm_record_params_t *params )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_PARAMS, params) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_PARAMS, params) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -302,7 +322,8 @@ int snd_pcm_playback_status( void *handle, snd_pcm_playback_status_t *status )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_PLAYBACK_STATUS, status) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_PLAYBACK_STATUS, status) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -313,7 +334,8 @@ int snd_pcm_record_status( void *handle, snd_pcm_record_status_t *status )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_STATUS, status) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_STATUS, status) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -324,7 +346,8 @@ int snd_pcm_drain_playback( void *handle )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_DRAIN_PLAYBACK) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_DRAIN_PLAYBACK) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -335,7 +358,8 @@ int snd_pcm_flush_playback( void *handle )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_FLUSH_PLAYBACK) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_FLUSH_PLAYBACK) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -346,7 +370,8 @@ int snd_pcm_flush_record( void *handle )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_FLUSH_RECORD) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_FLUSH_RECORD) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -357,7 +382,8 @@ int snd_pcm_playback_pause( void *handle, int enable )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_PLAYBACK_PAUSE, &enable) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_PLAYBACK_PAUSE, &enable) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -368,7 +394,8 @@ int snd_pcm_playback_time( void *handle, int enable )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_PLAYBACK_TIME, &enable) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_PLAYBACK_TIME, &enable) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -379,7 +406,8 @@ int snd_pcm_record_time( void *handle, int enable )
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_TIME, &enable) < 0)
 | 
						if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_TIME, &enable) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -391,9 +419,11 @@ ssize_t snd_pcm_write( void *handle, const void *buffer, size_t size )
 | 
				
			||||||
	ssize_t result;
 | 
						ssize_t result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	result = write(pcm->fd, buffer, size);
 | 
						result = write(pcm->fd, buffer, size);
 | 
				
			||||||
  if ( result < 0 ) return -errno;
 | 
						if (result < 0)
 | 
				
			||||||
 | 
							return -errno;
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -403,8 +433,10 @@ ssize_t snd_pcm_read( void *handle, void *buffer, size_t size )
 | 
				
			||||||
	ssize_t result;
 | 
						ssize_t result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pcm = (snd_pcm_t *) handle;
 | 
						pcm = (snd_pcm_t *) handle;
 | 
				
			||||||
  if ( !pcm ) return -EINVAL;
 | 
						if (!pcm)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	result = read(pcm->fd, buffer, size);
 | 
						result = read(pcm->fd, buffer, size);
 | 
				
			||||||
  if ( result < 0 ) return -errno;
 | 
						if (result < 0)
 | 
				
			||||||
 | 
							return -errno;
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,10 +44,12 @@ int snd_pcm_loopback_open( void **handle, int card, int device, int mode )
 | 
				
			||||||
	snd_pcm_loopback_t *lb;
 | 
						snd_pcm_loopback_t *lb;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*handle = NULL;
 | 
						*handle = NULL;
 | 
				
			||||||
  if ( card < 0 || card >= SND_CARDS ) return -EINVAL;
 | 
						if (card < 0 || card >= SND_CARDS)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	sprintf(filename, SND_FILE_PCM_LB, card, device,
 | 
						sprintf(filename, SND_FILE_PCM_LB, card, device,
 | 
				
			||||||
		mode == SND_PCM_LB_OPEN_RECORD ? "r" : "p");
 | 
							mode == SND_PCM_LB_OPEN_RECORD ? "r" : "p");
 | 
				
			||||||
  if ( (fd = open( filename, mode )) < 0 ) return -errno;
 | 
						if ((fd = open(filename, mode)) < 0)
 | 
				
			||||||
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(fd, SND_PCM_IOCTL_PVERSION, &ver) < 0) {
 | 
						if (ioctl(fd, SND_PCM_IOCTL_PVERSION, &ver) < 0) {
 | 
				
			||||||
		close(fd);
 | 
							close(fd);
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -74,7 +76,8 @@ int snd_pcm_loopback_close( void *handle )
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	lb = (snd_pcm_loopback_t *) handle;
 | 
						lb = (snd_pcm_loopback_t *) handle;
 | 
				
			||||||
  if ( !lb ) return -EINVAL;
 | 
						if (!lb)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	res = close(lb->fd) < 0 ? -errno : 0;
 | 
						res = close(lb->fd) < 0 ? -errno : 0;
 | 
				
			||||||
	free(lb);
 | 
						free(lb);
 | 
				
			||||||
	return res;
 | 
						return res;
 | 
				
			||||||
| 
						 | 
					@ -85,7 +88,8 @@ int snd_pcm_loopback_file_descriptor( void *handle )
 | 
				
			||||||
	snd_pcm_loopback_t *lb;
 | 
						snd_pcm_loopback_t *lb;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	lb = (snd_pcm_loopback_t *) handle;
 | 
						lb = (snd_pcm_loopback_t *) handle;
 | 
				
			||||||
  if ( !lb ) return -EINVAL;
 | 
						if (!lb)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	return lb->fd;
 | 
						return lb->fd;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -95,7 +99,8 @@ int snd_pcm_loopback_block_mode( void *handle, int enable )
 | 
				
			||||||
	long flags;
 | 
						long flags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	lb = (snd_pcm_loopback_t *) handle;
 | 
						lb = (snd_pcm_loopback_t *) handle;
 | 
				
			||||||
  if ( !lb ) return -EINVAL;
 | 
						if (!lb)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (fcntl(lb->fd, F_GETFL, &flags) < 0)
 | 
						if (fcntl(lb->fd, F_GETFL, &flags) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (enable)
 | 
						if (enable)
 | 
				
			||||||
| 
						 | 
					@ -113,7 +118,8 @@ int snd_pcm_loopback_stream_mode( void *handle, int mode )
 | 
				
			||||||
	long lmode = mode;
 | 
						long lmode = mode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	lb = (snd_pcm_loopback_t *) handle;
 | 
						lb = (snd_pcm_loopback_t *) handle;
 | 
				
			||||||
  if ( !lb ) return -EINVAL;
 | 
						if (!lb)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(lb->fd, SND_PCM_LB_IOCTL_STREAM_MODE, &lmode) < 0)
 | 
						if (ioctl(lb->fd, SND_PCM_LB_IOCTL_STREAM_MODE, &lmode) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -124,7 +130,8 @@ int snd_pcm_loopback_format( void *handle, snd_pcm_format_t *format )
 | 
				
			||||||
	snd_pcm_loopback_t *lb;
 | 
						snd_pcm_loopback_t *lb;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	lb = (snd_pcm_loopback_t *) handle;
 | 
						lb = (snd_pcm_loopback_t *) handle;
 | 
				
			||||||
  if ( !lb ) return -EINVAL;
 | 
						if (!lb)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(lb->fd, SND_PCM_LB_IOCTL_FORMAT, format) < 0)
 | 
						if (ioctl(lb->fd, SND_PCM_LB_IOCTL_FORMAT, format) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -136,8 +143,10 @@ ssize_t snd_pcm_loopback_read( void *handle, void *buffer, size_t size )
 | 
				
			||||||
	ssize_t result;
 | 
						ssize_t result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	lb = (snd_pcm_loopback_t *) handle;
 | 
						lb = (snd_pcm_loopback_t *) handle;
 | 
				
			||||||
  if ( !lb ) return -EINVAL;
 | 
						if (!lb)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	result = read(lb->fd, buffer, size);
 | 
						result = read(lb->fd, buffer, size);
 | 
				
			||||||
  if ( result < 0 ) return -errno;
 | 
						if (result < 0)
 | 
				
			||||||
 | 
							return -errno;
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,9 +44,11 @@ int snd_rawmidi_open( void **handle, int card, int device, int mode )
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*handle = NULL;
 | 
						*handle = NULL;
 | 
				
			||||||
  if ( card < 0 || card >= SND_CARDS ) return -EINVAL;
 | 
						if (card < 0 || card >= SND_CARDS)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	sprintf(filename, SND_FILE_RAWMIDI, card, device);
 | 
						sprintf(filename, SND_FILE_RAWMIDI, card, device);
 | 
				
			||||||
  if ( (fd = open( filename, mode )) < 0 ) return -errno;
 | 
						if ((fd = open(filename, mode)) < 0)
 | 
				
			||||||
 | 
							return -errno;
 | 
				
			||||||
	if (ioctl(fd, SND_RAWMIDI_IOCTL_PVERSION, &ver) < 0) {
 | 
						if (ioctl(fd, SND_RAWMIDI_IOCTL_PVERSION, &ver) < 0) {
 | 
				
			||||||
		close(fd);
 | 
							close(fd);
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -73,7 +75,8 @@ int snd_rawmidi_close( void *handle )
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	res = close(rmidi->fd) < 0 ? -errno : 0;
 | 
						res = close(rmidi->fd) < 0 ? -errno : 0;
 | 
				
			||||||
	free(rmidi);
 | 
						free(rmidi);
 | 
				
			||||||
	return res;
 | 
						return res;
 | 
				
			||||||
| 
						 | 
					@ -84,7 +87,8 @@ int snd_rawmidi_file_descriptor( void *handle )
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	return rmidi->fd;
 | 
						return rmidi->fd;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,7 +98,8 @@ int snd_rawmidi_block_mode( void *handle, int enable )
 | 
				
			||||||
	long flags;
 | 
						long flags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (fcntl(rmidi->fd, F_GETFL, &flags) < 0)
 | 
						if (fcntl(rmidi->fd, F_GETFL, &flags) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	if (enable)
 | 
						if (enable)
 | 
				
			||||||
| 
						 | 
					@ -111,7 +116,8 @@ int snd_rawmidi_info( void *handle, snd_rawmidi_info_t *info )
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INFO, info) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INFO, info) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -123,7 +129,8 @@ int snd_rawmidi_output_switches( void *handle )
 | 
				
			||||||
	int result;
 | 
						int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCHES, &result) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCHES, &result) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
| 
						 | 
					@ -136,7 +143,8 @@ int snd_rawmidi_output_switch( void *handle, const char *switch_id )
 | 
				
			||||||
	int idx, switches, err;
 | 
						int idx, switches, err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	/* bellow implementation isn't optimized for speed */
 | 
						/* bellow implementation isn't optimized for speed */
 | 
				
			||||||
	/* info about switches should be cached in the snd_mixer_t structure */
 | 
						/* info about switches should be cached in the snd_mixer_t structure */
 | 
				
			||||||
	if ((switches = snd_rawmidi_output_switches(handle)) < 0)
 | 
						if ((switches = snd_rawmidi_output_switches(handle)) < 0)
 | 
				
			||||||
| 
						 | 
					@ -155,7 +163,8 @@ int snd_rawmidi_output_switch_read( void *handle, int switchn, snd_rawmidi_switc
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCH_READ, data) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCH_READ, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -167,7 +176,8 @@ int snd_rawmidi_output_switch_write( void *handle, int switchn, snd_rawmidi_swit
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCH_WRITE, data) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCH_WRITE, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -180,7 +190,8 @@ int snd_rawmidi_input_switches( void *handle )
 | 
				
			||||||
	int result;
 | 
						int result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCHES, &result) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCHES, &result) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
| 
						 | 
					@ -193,7 +204,8 @@ int snd_rawmidi_input_switch( void *handle, const char *switch_id )
 | 
				
			||||||
	int idx, switches, err;
 | 
						int idx, switches, err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	/* bellow implementation isn't optimized for speed */
 | 
						/* bellow implementation isn't optimized for speed */
 | 
				
			||||||
	/* info about switches should be cached in the snd_mixer_t structure */
 | 
						/* info about switches should be cached in the snd_mixer_t structure */
 | 
				
			||||||
	if ((switches = snd_rawmidi_input_switches(handle)) < 0)
 | 
						if ((switches = snd_rawmidi_input_switches(handle)) < 0)
 | 
				
			||||||
| 
						 | 
					@ -212,7 +224,8 @@ int snd_rawmidi_input_switch_read( void *handle, int switchn, snd_rawmidi_switch
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCH_READ, data) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCH_READ, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -224,7 +237,8 @@ int snd_rawmidi_input_switch_write( void *handle, int switchn, snd_rawmidi_switc
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	data->switchn = switchn;
 | 
						data->switchn = switchn;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCH_WRITE, data) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCH_WRITE, data) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
| 
						 | 
					@ -236,7 +250,8 @@ int snd_rawmidi_output_params( void *handle, snd_rawmidi_output_params_t *params
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OUTPUT_PARAMS, params) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OUTPUT_PARAMS, params) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -247,7 +262,8 @@ int snd_rawmidi_input_params( void *handle, snd_rawmidi_input_params_t *params )
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INPUT_PARAMS, params) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INPUT_PARAMS, params) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -258,7 +274,8 @@ int snd_rawmidi_output_status( void *handle, snd_rawmidi_output_status_t *status
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OUTPUT_STATUS, status) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OUTPUT_STATUS, status) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -269,7 +286,8 @@ int snd_rawmidi_input_status( void *handle, snd_rawmidi_input_status_t *status )
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INPUT_STATUS, status) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_INPUT_STATUS, status) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -280,7 +298,8 @@ int snd_rawmidi_drain_output( void *handle )
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_DRAIN_OUTPUT) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_DRAIN_OUTPUT) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -291,7 +310,8 @@ int snd_rawmidi_flush_output( void *handle )
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_FLUSH_OUTPUT) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_FLUSH_OUTPUT) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -302,7 +322,8 @@ int snd_rawmidi_flush_input( void *handle )
 | 
				
			||||||
	snd_rawmidi_t *rmidi;
 | 
						snd_rawmidi_t *rmidi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_FLUSH_INPUT) < 0)
 | 
						if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_FLUSH_INPUT) < 0)
 | 
				
			||||||
		return -errno;
 | 
							return -errno;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -314,9 +335,11 @@ ssize_t snd_rawmidi_write( void *handle, const void *buffer, size_t size )
 | 
				
			||||||
	ssize_t result;
 | 
						ssize_t result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	result = write(rmidi->fd, buffer, size);
 | 
						result = write(rmidi->fd, buffer, size);
 | 
				
			||||||
  if ( result < 0 ) return -errno;
 | 
						if (result < 0)
 | 
				
			||||||
 | 
							return -errno;
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -326,8 +349,10 @@ ssize_t snd_rawmidi_read( void *handle, void *buffer, size_t size )
 | 
				
			||||||
	ssize_t result;
 | 
						ssize_t result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rmidi = (snd_rawmidi_t *) handle;
 | 
						rmidi = (snd_rawmidi_t *) handle;
 | 
				
			||||||
  if ( !rmidi ) return -EINVAL;
 | 
						if (!rmidi)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
	result = read(rmidi->fd, buffer, size);
 | 
						result = read(rmidi->fd, buffer, size);
 | 
				
			||||||
  if ( result < 0 ) return -errno;
 | 
						if (result < 0)
 | 
				
			||||||
 | 
							return -errno;
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue