alsa: Remove unnecessary hctl handles being passed around

Now that we have switched to using the mixer handle only,
there is no use for sending hctl handles around.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
David Henningsson 2014-09-01 15:58:22 +02:00
parent f2120fc2b6
commit 300a5e3ed7
8 changed files with 28 additions and 74 deletions

View file

@ -1476,30 +1476,6 @@ snd_mixer_elem_t *pa_alsa_mixer_find(snd_mixer_t *mixer, const char *name, unsig
return NULL;
}
snd_hctl_elem_t* pa_alsa_find_jack(snd_hctl_t *hctl, const char* jack_name) {
snd_ctl_elem_id_t *id;
snd_ctl_elem_id_alloca(&id);
snd_ctl_elem_id_clear(id);
snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_CARD);
snd_ctl_elem_id_set_name(id, jack_name);
return snd_hctl_find_elem(hctl, id);
}
snd_hctl_elem_t* pa_alsa_find_eld_ctl(snd_hctl_t *hctl, int device) {
snd_ctl_elem_id_t *id;
/* See if we can find the ELD control */
snd_ctl_elem_id_alloca(&id);
snd_ctl_elem_id_clear(id);
snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_PCM);
snd_ctl_elem_id_set_name(id, "ELD");
snd_ctl_elem_id_set_device(id, device);
return snd_hctl_find_elem(hctl, id);
}
static int mixer_class_compare(const snd_mixer_elem_t *c1, const snd_mixer_elem_t *c2)
{
/* Dummy compare function */
@ -1544,7 +1520,7 @@ static int mixer_class_event(snd_mixer_class_t *class, unsigned int mask,
return 0;
}
static int prepare_mixer(snd_mixer_t *mixer, const char *dev, snd_hctl_t **hctl) {
static int prepare_mixer(snd_mixer_t *mixer, const char *dev) {
int err;
snd_mixer_class_t *class;
@ -1556,13 +1532,6 @@ static int prepare_mixer(snd_mixer_t *mixer, const char *dev, snd_hctl_t **hctl)
return -1;
}
/* Note: The hctl handle returned should not be freed.
It is closed/freed by alsa-lib on snd_mixer_close/free */
if (hctl && (err = snd_mixer_get_hctl(mixer, dev, hctl)) < 0) {
pa_log_info("Unable to get hctl of mixer %s: %s", dev, pa_alsa_strerror(err));
return -1;
}
if (snd_mixer_class_malloc(&class)) {
pa_log_info("Failed to allocate mixer class for %s", dev);
return -1;
@ -1590,7 +1559,7 @@ static int prepare_mixer(snd_mixer_t *mixer, const char *dev, snd_hctl_t **hctl)
return 0;
}
snd_mixer_t *pa_alsa_open_mixer(int alsa_card_index, char **ctl_device, snd_hctl_t **hctl) {
snd_mixer_t *pa_alsa_open_mixer(int alsa_card_index, char **ctl_device) {
int err;
snd_mixer_t *m;
char *md;
@ -1604,7 +1573,7 @@ snd_mixer_t *pa_alsa_open_mixer(int alsa_card_index, char **ctl_device, snd_hctl
/* Then, try by card index */
md = pa_sprintf_malloc("hw:%i", alsa_card_index);
if (prepare_mixer(m, md, hctl) >= 0) {
if (prepare_mixer(m, md) >= 0) {
if (ctl_device)
*ctl_device = md;
@ -1620,7 +1589,7 @@ snd_mixer_t *pa_alsa_open_mixer(int alsa_card_index, char **ctl_device, snd_hctl
return NULL;
}
snd_mixer_t *pa_alsa_open_mixer_for_pcm(snd_pcm_t *pcm, char **ctl_device, snd_hctl_t **hctl) {
snd_mixer_t *pa_alsa_open_mixer_for_pcm(snd_pcm_t *pcm, char **ctl_device) {
int err;
snd_mixer_t *m;
const char *dev;
@ -1636,7 +1605,7 @@ snd_mixer_t *pa_alsa_open_mixer_for_pcm(snd_pcm_t *pcm, char **ctl_device, snd_h
/* First, try by name */
if ((dev = snd_pcm_name(pcm)))
if (prepare_mixer(m, dev, hctl) >= 0) {
if (prepare_mixer(m, dev) >= 0) {
if (ctl_device)
*ctl_device = pa_xstrdup(dev);
@ -1653,7 +1622,7 @@ snd_mixer_t *pa_alsa_open_mixer_for_pcm(snd_pcm_t *pcm, char **ctl_device, snd_h
md = pa_sprintf_malloc("hw:%i", card_idx);
if (!dev || !pa_streq(dev, md))
if (prepare_mixer(m, md, hctl) >= 0) {
if (prepare_mixer(m, md) >= 0) {
if (ctl_device)
*ctl_device = md;
@ -1671,25 +1640,19 @@ snd_mixer_t *pa_alsa_open_mixer_for_pcm(snd_pcm_t *pcm, char **ctl_device, snd_h
return NULL;
}
int pa_alsa_get_hdmi_eld(snd_hctl_t *hctl, int device, pa_hdmi_eld *eld) {
int pa_alsa_get_hdmi_eld(snd_hctl_elem_t *elem, pa_hdmi_eld *eld) {
/* The ELD format is specific to HDA Intel sound cards and defined in the
HDA specification: http://www.intel.com/content/www/us/en/standards/high-definition-audio-specification.html */
int err;
snd_hctl_elem_t *elem;
snd_ctl_elem_info_t *info;
snd_ctl_elem_value_t *value;
uint8_t *elddata;
unsigned int eldsize, mnl;
unsigned int device;
pa_assert(eld != NULL);
/* See if we can find the ELD control */
elem = pa_alsa_find_eld_ctl(hctl, device);
if (elem == NULL) {
pa_log_debug("No ELD info control found (for device=%d)", device);
return -1;
}
pa_assert(elem != NULL);
/* Does it have any contents? */
snd_ctl_elem_info_alloca(&info);
@ -1700,6 +1663,7 @@ int pa_alsa_get_hdmi_eld(snd_hctl_t *hctl, int device, pa_hdmi_eld *eld) {
return -1;
}
device = snd_hctl_elem_get_device(elem);
eldsize = snd_ctl_elem_info_get_count(info);
elddata = (unsigned char *) snd_ctl_elem_value_get_bytes(value);
if (elddata == NULL || eldsize == 0) {