mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	Change numid properly with external ctl plugins
So far, external ctl plugins don't change numid. Some apps expect the non-zero numids with list, and the plugin doesn't work for them. This patch adds a fake numid to each control based on the offset number. The lookup with non-zero numid is supported but is pretty inefficient. Eventually the plugin side may be optimized to look at the numid, too. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
		
							parent
							
								
									e38f921625
								
							
						
					
					
						commit
						81241ffb81
					
				
					 1 changed files with 15 additions and 3 deletions
				
			
		| 
						 | 
					@ -107,6 +107,7 @@ static int snd_ctl_ext_elem_list(snd_ctl_t *handle, snd_ctl_elem_list_t *list)
 | 
				
			||||||
		ret = ext->callback->elem_list(ext, offset, ids);
 | 
							ret = ext->callback->elem_list(ext, offset, ids);
 | 
				
			||||||
		if (ret < 0)
 | 
							if (ret < 0)
 | 
				
			||||||
			return ret;
 | 
								return ret;
 | 
				
			||||||
 | 
							ids->numid = offset + 1; /* fake number */
 | 
				
			||||||
		list->used++;
 | 
							list->used++;
 | 
				
			||||||
		offset++;
 | 
							offset++;
 | 
				
			||||||
		ids++;
 | 
							ids++;
 | 
				
			||||||
| 
						 | 
					@ -114,13 +115,24 @@ static int snd_ctl_ext_elem_list(snd_ctl_t *handle, snd_ctl_elem_list_t *list)
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static snd_ctl_ext_key_t get_elem(snd_ctl_ext_t *ext, snd_ctl_elem_id_t *id)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int numid = id->numid;
 | 
				
			||||||
 | 
						if (numid > 0) {
 | 
				
			||||||
 | 
							ext->callback->elem_list(ext, numid - 1, id);
 | 
				
			||||||
 | 
							id->numid = numid;
 | 
				
			||||||
 | 
						} else
 | 
				
			||||||
 | 
							id->numid = 0;
 | 
				
			||||||
 | 
						return ext->callback->find_elem(ext, id);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int snd_ctl_ext_elem_info(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
 | 
					static int snd_ctl_ext_elem_info(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	snd_ctl_ext_t *ext = handle->private_data;
 | 
						snd_ctl_ext_t *ext = handle->private_data;
 | 
				
			||||||
	snd_ctl_ext_key_t key;
 | 
						snd_ctl_ext_key_t key;
 | 
				
			||||||
	int type, ret;
 | 
						int type, ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	key = ext->callback->find_elem(ext, &info->id);
 | 
						key = get_elem(ext, &info->id);
 | 
				
			||||||
	if (key == SND_CTL_EXT_KEY_NOT_FOUND)
 | 
						if (key == SND_CTL_EXT_KEY_NOT_FOUND)
 | 
				
			||||||
		return -ENOENT;
 | 
							return -ENOENT;
 | 
				
			||||||
	ret = ext->callback->get_attribute(ext, key, &type, &info->access, &info->count);
 | 
						ret = ext->callback->get_attribute(ext, key, &type, &info->access, &info->count);
 | 
				
			||||||
| 
						 | 
					@ -200,7 +212,7 @@ static int snd_ctl_ext_elem_read(snd_ctl_t *handle, snd_ctl_elem_value_t *contro
 | 
				
			||||||
	int type, ret;
 | 
						int type, ret;
 | 
				
			||||||
	unsigned int access, count;
 | 
						unsigned int access, count;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	key = ext->callback->find_elem(ext, &control->id);
 | 
						key = get_elem(ext, &control->id);
 | 
				
			||||||
	if (key == SND_CTL_EXT_KEY_NOT_FOUND)
 | 
						if (key == SND_CTL_EXT_KEY_NOT_FOUND)
 | 
				
			||||||
		return -ENOENT;
 | 
							return -ENOENT;
 | 
				
			||||||
	ret = ext->callback->get_attribute(ext, key, &type, &access, &count);
 | 
						ret = ext->callback->get_attribute(ext, key, &type, &access, &count);
 | 
				
			||||||
| 
						 | 
					@ -254,7 +266,7 @@ static int snd_ctl_ext_elem_write(snd_ctl_t *handle, snd_ctl_elem_value_t *contr
 | 
				
			||||||
	int type, ret;
 | 
						int type, ret;
 | 
				
			||||||
	unsigned int access, count;
 | 
						unsigned int access, count;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	key = ext->callback->find_elem(ext, &control->id);
 | 
						key = get_elem(ext, &control->id);
 | 
				
			||||||
	if (key == SND_CTL_EXT_KEY_NOT_FOUND)
 | 
						if (key == SND_CTL_EXT_KEY_NOT_FOUND)
 | 
				
			||||||
		return -ENOENT;
 | 
							return -ENOENT;
 | 
				
			||||||
	ret = ext->callback->get_attribute(ext, key, &type, &access, &count);
 | 
						ret = ext->callback->get_attribute(ext, key, &type, &access, &count);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue