From: Clemens Ladisch Date: Fri, 29 Jul 2005 14:33:00 +0000 (+0000) Subject: sound - fix .iface field of mixer control elements X-Git-Tag: v1.0.10rc1~4 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=7fcbc9917e819dc894eaab391ba64e426e903500;p=alsa-tools.git sound - fix .iface field of mixer control elements This patch changes .iface to SNDRV_CTL_ELEM_IFACE_MIXER whre _PCM or _HWDEP was used in controls that are not associated with a specific PCM (sub)stream or hwdep device, and changes some controls that got inconsitent .iface values due to copy+paste errors. Furthermore, it makes sure that all control that do use _PCM or _HWDEP use the correct number in the .device field. --- diff --git a/hdspconf/src/HC_Aeb.cxx b/hdspconf/src/HC_Aeb.cxx index ba7b76a..d7a98d6 100644 --- a/hdspconf/src/HC_Aeb.cxx +++ b/hdspconf/src/HC_Aeb.cxx @@ -32,10 +32,7 @@ static void setAebStatus(char *ctl_name, int val, int card_index) snd_ctl_elem_value_alloca(&ctl); snd_ctl_elem_id_alloca(&id); snd_ctl_elem_id_set_name(id, ctl_name); - snd_ctl_elem_id_set_numid(id, 0); - snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); - snd_ctl_elem_id_set_device(id, 0); - snd_ctl_elem_id_set_subdevice(id, 0); + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); snd_ctl_elem_id_set_index(id, 0); snd_ctl_elem_value_set_id(ctl, id); snd_ctl_elem_value_set_integer(ctl, 0, val); @@ -44,8 +41,13 @@ static void setAebStatus(char *ctl_name, int val, int card_index) return; } if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { - fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); - return; + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); + snd_ctl_elem_value_set_id(ctl, id); + if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { + fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); + snd_ctl_close(handle); + return; + } } snd_ctl_close(handle); } diff --git a/hdspconf/src/HC_BreakoutCable.cxx b/hdspconf/src/HC_BreakoutCable.cxx index 229f9b8..89d3ec8 100644 --- a/hdspconf/src/HC_BreakoutCable.cxx +++ b/hdspconf/src/HC_BreakoutCable.cxx @@ -32,10 +32,7 @@ static void setXlrStatus(char *ctl_name, int val, int card_index) snd_ctl_elem_value_alloca(&ctl); snd_ctl_elem_id_alloca(&id); snd_ctl_elem_id_set_name(id, ctl_name); - snd_ctl_elem_id_set_numid(id, 0); - snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); - snd_ctl_elem_id_set_device(id, 0); - snd_ctl_elem_id_set_subdevice(id, 0); + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); snd_ctl_elem_id_set_index(id, 0); snd_ctl_elem_value_set_id(ctl, id); snd_ctl_elem_value_set_integer(ctl, 0, val); @@ -44,8 +41,13 @@ static void setXlrStatus(char *ctl_name, int val, int card_index) return; } if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { - fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); - return; + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); + snd_ctl_elem_value_set_id(ctl, id); + if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { + fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); + snd_ctl_close(handle); + return; + } } snd_ctl_close(handle); } diff --git a/hdspconf/src/HC_ClockSource.cxx b/hdspconf/src/HC_ClockSource.cxx index f442c0e..4bb978a 100644 --- a/hdspconf/src/HC_ClockSource.cxx +++ b/hdspconf/src/HC_ClockSource.cxx @@ -60,10 +60,7 @@ void clock_source_cb(Fl_Widget *w, void *arg) snd_ctl_elem_value_alloca(&ctl); snd_ctl_elem_id_alloca(&id); snd_ctl_elem_id_set_name(id, "Sample Clock Source"); - snd_ctl_elem_id_set_numid(id, 0); - snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_PCM); - snd_ctl_elem_id_set_device(id, 0); - snd_ctl_elem_id_set_subdevice(id, 0); + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); snd_ctl_elem_id_set_index(id, 0); snd_ctl_elem_value_set_id(ctl, id); snd_ctl_elem_value_set_enumerated(ctl, 0, src); @@ -72,9 +69,14 @@ void clock_source_cb(Fl_Widget *w, void *arg) return; } if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { - fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); - return; - } + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_PCM); + snd_ctl_elem_value_set_id(ctl, id); + if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { + fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); + snd_ctl_close(handle); + return; + } + } snd_ctl_close(handle); } diff --git a/hdspconf/src/HC_InputLevel.cxx b/hdspconf/src/HC_InputLevel.cxx index deef8dc..c3f088a 100644 --- a/hdspconf/src/HC_InputLevel.cxx +++ b/hdspconf/src/HC_InputLevel.cxx @@ -43,10 +43,7 @@ void input_level_cb(Fl_Widget *w, void *arg) snd_ctl_elem_value_alloca(&ctl); snd_ctl_elem_id_alloca(&id); snd_ctl_elem_id_set_name(id, "AD Gain"); - snd_ctl_elem_id_set_numid(id, 0); - snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); - snd_ctl_elem_id_set_device(id, 0); - snd_ctl_elem_id_set_subdevice(id, 0); + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); snd_ctl_elem_id_set_index(id, 0); snd_ctl_elem_value_set_id(ctl, id); snd_ctl_elem_value_set_enumerated(ctl, 0, gain); @@ -55,8 +52,13 @@ void input_level_cb(Fl_Widget *w, void *arg) return; } if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { - fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); - return; + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); + snd_ctl_elem_value_set_id(ctl, id); + if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { + fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); + snd_ctl_close(handle); + return; + } } snd_ctl_close(handle); } diff --git a/hdspconf/src/HC_OutputLevel.cxx b/hdspconf/src/HC_OutputLevel.cxx index f42e71a..abcc95f 100644 --- a/hdspconf/src/HC_OutputLevel.cxx +++ b/hdspconf/src/HC_OutputLevel.cxx @@ -43,10 +43,7 @@ void output_level_cb(Fl_Widget *w, void *arg) snd_ctl_elem_value_alloca(&ctl); snd_ctl_elem_id_alloca(&id); snd_ctl_elem_id_set_name(id, "DA Gain"); - snd_ctl_elem_id_set_numid(id, 0); - snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); - snd_ctl_elem_id_set_device(id, 0); - snd_ctl_elem_id_set_subdevice(id, 0); + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); snd_ctl_elem_id_set_index(id, 0); snd_ctl_elem_value_set_id(ctl, id); snd_ctl_elem_value_set_enumerated(ctl, 0, gain); @@ -55,8 +52,13 @@ void output_level_cb(Fl_Widget *w, void *arg) return; } if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { - fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); - return; + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); + snd_ctl_elem_value_set_id(ctl, id); + if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { + fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); + snd_ctl_close(handle); + return; + } } snd_ctl_close(handle); } diff --git a/hdspconf/src/HC_Phones.cxx b/hdspconf/src/HC_Phones.cxx index fb1c600..8bc230a 100644 --- a/hdspconf/src/HC_Phones.cxx +++ b/hdspconf/src/HC_Phones.cxx @@ -43,10 +43,7 @@ void phones_cb(Fl_Widget *w, void *arg) snd_ctl_elem_value_alloca(&ctl); snd_ctl_elem_id_alloca(&id); snd_ctl_elem_id_set_name(id, "Phones Gain"); - snd_ctl_elem_id_set_numid(id, 0); - snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); - snd_ctl_elem_id_set_device(id, 0); - snd_ctl_elem_id_set_subdevice(id, 0); + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); snd_ctl_elem_id_set_index(id, 0); snd_ctl_elem_value_set_id(ctl, id); snd_ctl_elem_value_set_enumerated(ctl, 0, gain); @@ -55,8 +52,13 @@ void phones_cb(Fl_Widget *w, void *arg) return; } if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { - fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); - return; + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); + snd_ctl_elem_value_set_id(ctl, id); + if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { + fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); + snd_ctl_close(handle); + return; + } } snd_ctl_close(handle); } diff --git a/hdspconf/src/HC_PrefSyncRef.cxx b/hdspconf/src/HC_PrefSyncRef.cxx index 3fd636a..a3c7096 100644 --- a/hdspconf/src/HC_PrefSyncRef.cxx +++ b/hdspconf/src/HC_PrefSyncRef.cxx @@ -49,10 +49,7 @@ void pref_sync_ref_cb(Fl_Widget *w, void *arg) snd_ctl_elem_value_alloca(&ctl); snd_ctl_elem_id_alloca(&id); snd_ctl_elem_id_set_name(id, "Preferred Sync Reference"); - snd_ctl_elem_id_set_numid(id, 0); - snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); - snd_ctl_elem_id_set_device(id, 0); - snd_ctl_elem_id_set_subdevice(id, 0); + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); snd_ctl_elem_id_set_index(id, 0); snd_ctl_elem_value_set_id(ctl, id); snd_ctl_elem_value_set_enumerated(ctl, 0, ref); @@ -61,8 +58,13 @@ void pref_sync_ref_cb(Fl_Widget *w, void *arg) return; } if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { - fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); - return; + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); + snd_ctl_elem_value_set_id(ctl, id); + if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { + fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); + snd_ctl_close(handle); + return; + } } snd_ctl_close(handle); } diff --git a/hdspconf/src/HC_SpdifIn.cxx b/hdspconf/src/HC_SpdifIn.cxx index 211af05..204b82c 100644 --- a/hdspconf/src/HC_SpdifIn.cxx +++ b/hdspconf/src/HC_SpdifIn.cxx @@ -45,10 +45,7 @@ void spdif_in_cb(Fl_Widget *w, void *arg) snd_ctl_elem_value_alloca(&ctl); snd_ctl_elem_id_alloca(&id); snd_ctl_elem_id_set_name(id, "IEC958 Input Connector"); - snd_ctl_elem_id_set_numid(id, 0); - snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_PCM); - snd_ctl_elem_id_set_device(id, 0); - snd_ctl_elem_id_set_subdevice(id, 0); + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); snd_ctl_elem_id_set_index(id, 0); snd_ctl_elem_value_set_id(ctl, id); snd_ctl_elem_value_set_enumerated(ctl, 0, in); @@ -57,8 +54,13 @@ void spdif_in_cb(Fl_Widget *w, void *arg) return; } if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { - fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); - return; + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_PCM); + snd_ctl_elem_value_set_id(ctl, id); + if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { + fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); + snd_ctl_close(handle); + return; + } } snd_ctl_close(handle); } diff --git a/hdspconf/src/HC_SpdifOut.cxx b/hdspconf/src/HC_SpdifOut.cxx index 8ba484a..71c7bfe 100644 --- a/hdspconf/src/HC_SpdifOut.cxx +++ b/hdspconf/src/HC_SpdifOut.cxx @@ -32,10 +32,7 @@ static void setSpdifBit(char *ctl_name, int val, int card_index) snd_ctl_elem_value_alloca(&ctl); snd_ctl_elem_id_alloca(&id); snd_ctl_elem_id_set_name(id, ctl_name); - snd_ctl_elem_id_set_numid(id, 0); - snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); - snd_ctl_elem_id_set_device(id, 0); - snd_ctl_elem_id_set_subdevice(id, 0); + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); snd_ctl_elem_id_set_index(id, 0); snd_ctl_elem_value_set_id(ctl, id); snd_ctl_elem_value_set_integer(ctl, 0, val); @@ -44,8 +41,13 @@ static void setSpdifBit(char *ctl_name, int val, int card_index) return; } if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { - fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); - return; + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); + snd_ctl_elem_value_set_id(ctl, id); + if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { + fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name); + snd_ctl_close(handle); + return; + } } snd_ctl_close(handle); } diff --git a/hdspmixer/src/HDSPMixerCard.cxx b/hdspmixer/src/HDSPMixerCard.cxx index ea8573d..faed6fb 100644 --- a/hdspmixer/src/HDSPMixerCard.cxx +++ b/hdspmixer/src/HDSPMixerCard.cxx @@ -155,13 +155,14 @@ int HDSPMixerCard::getAutosyncSpeed() } snd_ctl_elem_id_set_name(elemid, "System Sample Rate"); - snd_ctl_elem_id_set_numid(elemid, 16); - snd_ctl_elem_id_set_interface(elemid, SND_CTL_ELEM_IFACE_HWDEP); - snd_ctl_elem_id_set_device(elemid, 0); - snd_ctl_elem_id_set_subdevice(elemid, 0); + snd_ctl_elem_id_set_interface(elemid, SND_CTL_ELEM_IFACE_MIXER); snd_ctl_elem_id_set_index(elemid, 0); snd_ctl_elem_value_set_id(elemval, elemid); - snd_ctl_elem_read(handle, elemval); + if (snd_ctl_elem_read(handle, elemval) < 0) { + snd_ctl_elem_id_set_interface(elemid, SND_CTL_ELEM_IFACE_HWDEP); + snd_ctl_elem_value_set_id(elemval, elemid); + snd_ctl_elem_read(handle, elemval); + } rate = snd_ctl_elem_value_get_integer(elemval, 0); snd_ctl_close(handle); @@ -187,13 +188,14 @@ int HDSPMixerCard::getSpeed() return -1; } snd_ctl_elem_id_set_name(elemid, "Sample Clock Source"); - snd_ctl_elem_id_set_numid(elemid, 11); - snd_ctl_elem_id_set_interface(elemid, SND_CTL_ELEM_IFACE_PCM); - snd_ctl_elem_id_set_device(elemid, 0); - snd_ctl_elem_id_set_subdevice(elemid, 0); + snd_ctl_elem_id_set_interface(elemid, SND_CTL_ELEM_IFACE_MIXER); snd_ctl_elem_id_set_index(elemid, 0); snd_ctl_elem_value_set_id(elemval, elemid); - snd_ctl_elem_read(handle, elemval); + if (snd_ctl_elem_read(handle, elemval) < 0) { + snd_ctl_elem_id_set_interface(elemid, SND_CTL_ELEM_IFACE_PCM); + snd_ctl_elem_value_set_id(elemval, elemid); + snd_ctl_elem_read(handle, elemval); + } val = snd_ctl_elem_value_get_enumerated(elemval, 0); snd_ctl_close(handle); switch (val) { diff --git a/hdspmixer/src/HDSPMixerWindow.cxx b/hdspmixer/src/HDSPMixerWindow.cxx index d92d57c..cab0d5e 100644 --- a/hdspmixer/src/HDSPMixerWindow.cxx +++ b/hdspmixer/src/HDSPMixerWindow.cxx @@ -918,10 +918,8 @@ void HDSPMixerWindow::setGain(int in, int out, int value) snd_ctl_elem_value_alloca(&ctl); snd_ctl_elem_id_alloca(&id); snd_ctl_elem_id_set_name(id, "Mixer"); - snd_ctl_elem_id_set_numid(id, 0); snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); snd_ctl_elem_id_set_device(id, 0); - snd_ctl_elem_id_set_subdevice(id, 0); snd_ctl_elem_id_set_index(id, 0); snd_ctl_elem_value_set_id(ctl, id); @@ -966,10 +964,8 @@ void HDSPMixerWindow::setMixer(int idx, int src, int dst) snd_ctl_elem_value_alloca(&ctl); snd_ctl_elem_id_alloca(&id); snd_ctl_elem_id_set_name(id, "Mixer"); - snd_ctl_elem_id_set_numid(id, 0); snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP); snd_ctl_elem_id_set_device(id, 0); - snd_ctl_elem_id_set_subdevice(id, 0); snd_ctl_elem_id_set_index(id, 0); snd_ctl_elem_value_set_id(ctl, id); @@ -1009,6 +1005,7 @@ muted: snd_ctl_elem_value_set_integer(ctl, 2, (int)left_val); if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { fprintf(stderr, "Alsa error: %s\n", snd_strerror(err)); + snd_ctl_close(handle); return; } snd_ctl_elem_value_set_integer(ctl, 0, src*cards[current_card]->playbacks_offset+cards[current_card]->channel_map[idx-1]); @@ -1016,6 +1013,7 @@ muted: snd_ctl_elem_value_set_integer(ctl, 2, (int)right_val); if ((err = snd_ctl_elem_write(handle, ctl)) < 0) { fprintf(stderr, "Alsa error: %s\n", snd_strerror(err)); + snd_ctl_close(handle); return; } snd_ctl_close(handle);