bool CALSAHControlMonitor::Add(const std::string& ctlHandleName,
                               snd_ctl_elem_iface_t interface,
                               unsigned int device,
                               const std::string& name)
{
  snd_hctl_t *hctl = GetHandle(ctlHandleName);

  if (!hctl)
  {
    return false;
  }

  snd_ctl_elem_id_t *id;

  snd_ctl_elem_id_alloca(&id);

  snd_ctl_elem_id_set_interface(id, interface);
  snd_ctl_elem_id_set_name     (id, name.c_str());
  snd_ctl_elem_id_set_device   (id, device);

  snd_hctl_elem_t *elem = snd_hctl_find_elem(hctl, id);

  if (!elem)
  {
    PutHandle(ctlHandleName);
    return false;
  }

  snd_hctl_elem_set_callback(elem, HCTLCallback);

  return true;
}
static void
_phoneui_utils_sound_init_set_volume_mute_control(enum SoundState state, enum SoundStateType type,
	enum SoundControlType control_type, const char *ctl_name)
{
	snd_hctl_elem_t *elem;

	/*if an empty string, return */
	if (*ctl_name == '\0') {
		controls[calc_state_index(state, type)][control_type].mute_element = NULL;
		return;
	}
	elem = controls[calc_state_index(state, type)][control_type].mute_element =
		_phoneui_utils_sound_init_get_control_by_name(ctl_name);
	if (elem) {
		snd_hctl_elem_set_callback(elem, _phoneui_utils_sound_volume_mute_changed_cb);
	}
	else {
		g_warning("ALSA: No control named '%s' found - "
				"Sound state: %d type: %d", ctl_name, state, control_type);
	}

}