mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-10-29 05:40:25 -04:00 
			
		
		
		
	Recoded the universal switch interface...
This commit is contained in:
		
							parent
							
								
									a5b307a711
								
							
						
					
					
						commit
						6e72ca3977
					
				
					 8 changed files with 42 additions and 204 deletions
				
			
		|  | @ -5,6 +5,13 @@ | |||
|  *                                                                          * | ||||
|  ****************************************************************************/ | ||||
| 
 | ||||
| typedef struct snd_ctl_callbacks { | ||||
| 	void *private_data;	/* should be used by an application */ | ||||
| 	void (*rebuild) (void *private_data); | ||||
| 	void (*xswitch) (void *private_data, int cmd, int iface, snd_switch_list_item_t *item); | ||||
| 	void *reserved[29];	/* reserved for the future use - must be NULL!!! */ | ||||
| } snd_ctl_callbacks_t; | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
|  | @ -51,6 +58,7 @@ int snd_ctl_rawmidi_output_switch_write(void *handle, int dev, snd_switch_t * sw | |||
| int snd_ctl_rawmidi_input_switch_list(void *handle, int dev, snd_switch_list_t *list); | ||||
| int snd_ctl_rawmidi_input_switch_read(void *handle, int dev, snd_switch_t * sw); | ||||
| int snd_ctl_rawmidi_input_switch_write(void *handle, int dev, snd_switch_t * sw); | ||||
| int snd_ctl_read(void *handle, snd_ctl_callbacks_t * callbacks); | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| } | ||||
|  |  | |||
|  | @ -10,8 +10,7 @@ typedef struct snd_mixer_callbacks { | |||
| 	void (*rebuild) (void *private_data); | ||||
| 	void (*element) (void *private_data, int cmd, snd_mixer_eid_t *eid); | ||||
| 	void (*group) (void *private_data, int cmd, snd_mixer_gid_t *gid); | ||||
| 	void (*xswitch) (void *private_data, int cmd, snd_switch_list_item_t *item); | ||||
| 	void *reserved[27];	/* reserved for the future use - must be NULL!!! */ | ||||
| 	void *reserved[28];	/* reserved for the future use - must be NULL!!! */ | ||||
| } snd_mixer_callbacks_t; | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  | @ -29,9 +28,6 @@ int snd_mixer_group(void *handle, snd_mixer_group_t * group); | |||
| int snd_mixer_element_info(void *handle, snd_mixer_element_info_t * info); | ||||
| int snd_mixer_element_read(void *handle, snd_mixer_element_t * element); | ||||
| int snd_mixer_element_write(void *handle, snd_mixer_element_t * element); | ||||
| int snd_mixer_switch_list(void *handle, snd_switch_list_t * list); | ||||
| int snd_mixer_switch_read(void *handle, snd_switch_t * sw); | ||||
| int snd_mixer_switch_write(void *handle, snd_switch_t * sw); | ||||
| int snd_mixer_read(void *handle, snd_mixer_callbacks_t * callbacks); | ||||
| 
 | ||||
| void snd_mixer_set_bit(unsigned int *bitmap, int bit, int val); | ||||
|  |  | |||
|  | @ -20,12 +20,6 @@ int snd_pcm_block_mode(void *handle, int enable); | |||
| int snd_pcm_info(void *handle, snd_pcm_info_t * info); | ||||
| int snd_pcm_playback_info(void *handle, snd_pcm_playback_info_t * info); | ||||
| int snd_pcm_record_info(void *handle, snd_pcm_record_info_t * info); | ||||
| int snd_pcm_playback_switch_list(void *handle, snd_switch_list_t * list); | ||||
| int snd_pcm_playback_switch_read(void *handle, snd_switch_t * sw); | ||||
| int snd_pcm_playback_switch_write(void *handle, snd_switch_t * sw); | ||||
| int snd_pcm_record_switch_list(void *handle, snd_switch_list_t * list); | ||||
| int snd_pcm_record_switch_read(void *handle, snd_switch_t * sw); | ||||
| int snd_pcm_record_switch_write(void *handle, snd_switch_t * sw); | ||||
| int snd_pcm_playback_format(void *handle, snd_pcm_format_t * format); | ||||
| int snd_pcm_record_format(void *handle, snd_pcm_format_t * format); | ||||
| int snd_pcm_playback_params(void *handle, snd_pcm_playback_params_t * params); | ||||
|  |  | |||
|  | @ -18,12 +18,6 @@ int snd_rawmidi_close(void *handle); | |||
| int snd_rawmidi_file_descriptor(void *handle); | ||||
| int snd_rawmidi_block_mode(void *handle, int enable); | ||||
| int snd_rawmidi_info(void *handle, snd_rawmidi_info_t * info); | ||||
| int snd_rawmidi_output_switch_list(void *handle, snd_switch_list_t * list); | ||||
| int snd_rawmidi_output_switch_read(void *handle, snd_switch_t * sw); | ||||
| int snd_rawmidi_output_switch_write(void *handle, snd_switch_t * sw); | ||||
| int snd_rawmidi_input_switch_list(void *handle, snd_switch_list_t * list); | ||||
| int snd_rawmidi_input_switch_read(void *handle, snd_switch_t * sw); | ||||
| int snd_rawmidi_input_switch_write(void *handle, snd_switch_t * sw); | ||||
| int snd_rawmidi_output_params(void *handle, snd_rawmidi_output_params_t * params); | ||||
| int snd_rawmidi_input_params(void *handle, snd_rawmidi_input_params_t * params); | ||||
| int snd_rawmidi_output_status(void *handle, snd_rawmidi_output_status_t * status); | ||||
|  |  | |||
|  | @ -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; | ||||
| } | ||||
|  |  | |||
|  | @ -193,42 +193,6 @@ int snd_mixer_element_write(void *handle, snd_mixer_element_t * element) | |||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_mixer_switch_list(void *handle, snd_switch_list_t * list) | ||||
| { | ||||
| 	snd_mixer_t *mixer; | ||||
| 
 | ||||
| 	mixer = (snd_mixer_t *) handle; | ||||
| 	if (!mixer || !list) | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(mixer->fd, SND_MIXER_IOCTL_SWITCH_LIST, &list) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_mixer_switch_read(void *handle, snd_switch_t * sw) | ||||
| { | ||||
| 	snd_mixer_t *mixer; | ||||
| 
 | ||||
| 	mixer = (snd_mixer_t *) handle; | ||||
| 	if (!mixer || !sw || sw->name[0] == '\0') | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(mixer->fd, SND_MIXER_IOCTL_SWITCH_READ, sw) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_mixer_switch_write(void *handle, snd_switch_t * sw) | ||||
| { | ||||
| 	snd_mixer_t *mixer; | ||||
| 
 | ||||
| 	mixer = (snd_mixer_t *) handle; | ||||
| 	if (!mixer || !sw || sw->name[0] == '\0') | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(mixer->fd, SND_MIXER_IOCTL_SWITCH_WRITE, sw) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_mixer_read(void *handle, snd_mixer_callbacks_t * callbacks) | ||||
| { | ||||
| 	snd_mixer_t *mixer; | ||||
|  | @ -263,13 +227,6 @@ int snd_mixer_read(void *handle, snd_mixer_callbacks_t * callbacks) | |||
| 			if (callbacks->group) | ||||
| 				callbacks->group(callbacks->private_data, r.cmd, &r.data.gid); | ||||
| 			break; | ||||
| 		case SND_MIXER_READ_SWITCH_VALUE: | ||||
| 		case SND_MIXER_READ_SWITCH_CHANGE: | ||||
| 		case SND_MIXER_READ_SWITCH_ADD: | ||||
| 		case SND_MIXER_READ_SWITCH_REMOVE: | ||||
| 			if (callbacks->xswitch) | ||||
| 				callbacks->xswitch(callbacks->private_data, r.cmd, &r.data.switem); | ||||
| 			break; | ||||
| 		} | ||||
| 		count++; | ||||
| 	} | ||||
|  |  | |||
|  | @ -151,78 +151,6 @@ int snd_pcm_record_info(void *handle, snd_pcm_record_info_t * info) | |||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_pcm_playback_switch_list(void *handle, snd_switch_list_t * list) | ||||
| { | ||||
| 	snd_pcm_t *pcm; | ||||
| 
 | ||||
| 	pcm = (snd_pcm_t *) handle; | ||||
| 	if (!pcm || !list) | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(pcm->fd, SND_PCM_IOCTL_PSWITCH_LIST, &list) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_pcm_playback_switch_read(void *handle, snd_switch_t * sw) | ||||
| { | ||||
| 	snd_pcm_t *pcm; | ||||
| 
 | ||||
| 	pcm = (snd_pcm_t *) handle; | ||||
| 	if (!pcm || !sw || sw->name[0] == '\0') | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(pcm->fd, SND_PCM_IOCTL_PSWITCH_READ, sw) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_pcm_playback_switch_write(void *handle, snd_switch_t * sw) | ||||
| { | ||||
| 	snd_pcm_t *pcm; | ||||
| 
 | ||||
| 	pcm = (snd_pcm_t *) handle; | ||||
| 	if (!pcm || !sw || sw->name[0] == '\0') | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(pcm->fd, SND_PCM_IOCTL_PSWITCH_WRITE, sw) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_pcm_record_switch_list(void *handle, snd_switch_list_t * list) | ||||
| { | ||||
| 	snd_pcm_t *pcm; | ||||
| 
 | ||||
| 	pcm = (snd_pcm_t *) handle; | ||||
| 	if (!pcm || !list) | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(pcm->fd, SND_PCM_IOCTL_RSWITCH_LIST, list) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_pcm_record_switch_read(void *handle, snd_switch_t * sw) | ||||
| { | ||||
| 	snd_pcm_t *pcm; | ||||
| 
 | ||||
| 	pcm = (snd_pcm_t *) handle; | ||||
| 	if (!pcm || !sw || sw->name[0] == '\0') | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(pcm->fd, SND_PCM_IOCTL_RSWITCH_READ, sw) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_pcm_record_switch_write(void *handle, snd_switch_t * sw) | ||||
| { | ||||
| 	snd_pcm_t *pcm; | ||||
| 
 | ||||
| 	pcm = (snd_pcm_t *) handle; | ||||
| 	if (!pcm || !sw || sw->name[0] == '\0') | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(pcm->fd, SND_PCM_IOCTL_RSWITCH_WRITE, sw) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_pcm_playback_format(void *handle, snd_pcm_format_t * format) | ||||
| { | ||||
| 	snd_pcm_t *pcm; | ||||
|  |  | |||
|  | @ -127,78 +127,6 @@ int snd_rawmidi_info(void *handle, snd_rawmidi_info_t * info) | |||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_rawmidi_output_switch_list(void *handle, snd_switch_list_t * list) | ||||
| { | ||||
| 	snd_rawmidi_t *rmidi; | ||||
| 
 | ||||
| 	rmidi = (snd_rawmidi_t *) handle; | ||||
| 	if (!rmidi || !list) | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCH_LIST, list) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_rawmidi_output_switch_read(void *handle, snd_switch_t * sw) | ||||
| { | ||||
| 	snd_rawmidi_t *rmidi; | ||||
| 
 | ||||
| 	rmidi = (snd_rawmidi_t *) handle; | ||||
| 	if (!rmidi || !sw || sw->name[0] == '\0') | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCH_READ, sw) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_rawmidi_output_switch_write(void *handle, snd_switch_t * sw) | ||||
| { | ||||
| 	snd_rawmidi_t *rmidi; | ||||
| 
 | ||||
| 	rmidi = (snd_rawmidi_t *) handle; | ||||
| 	if (!rmidi || !sw || sw->name[0] == '\0') | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_OSWITCH_WRITE, sw) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_rawmidi_input_switch_list(void *handle, snd_switch_list_t * list) | ||||
| { | ||||
| 	snd_rawmidi_t *rmidi; | ||||
| 
 | ||||
| 	rmidi = (snd_rawmidi_t *) handle; | ||||
| 	if (!rmidi) | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCH_LIST, list) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_rawmidi_input_switch_read(void *handle, snd_switch_t * sw) | ||||
| { | ||||
| 	snd_rawmidi_t *rmidi; | ||||
| 
 | ||||
| 	rmidi = (snd_rawmidi_t *) handle; | ||||
| 	if (!rmidi || !sw || sw->name[0] == '\0') | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCH_READ, sw) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_rawmidi_input_switch_write(void *handle, snd_switch_t * sw) | ||||
| { | ||||
| 	snd_rawmidi_t *rmidi; | ||||
| 
 | ||||
| 	rmidi = (snd_rawmidi_t *) handle; | ||||
| 	if (!rmidi || !sw || sw->name[0] == '\0') | ||||
| 		return -EINVAL; | ||||
| 	if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_ISWITCH_WRITE, sw) < 0) | ||||
| 		return -errno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int snd_rawmidi_output_params(void *handle, snd_rawmidi_output_params_t * params) | ||||
| { | ||||
| 	snd_rawmidi_t *rmidi; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jaroslav Kysela
						Jaroslav Kysela