summaryrefslogtreecommitdiffstats
path: root/alsa-binding
diff options
context:
space:
mode:
Diffstat (limited to 'alsa-binding')
-rw-r--r--alsa-binding/Alsa-AddCtl.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/alsa-binding/Alsa-AddCtl.c b/alsa-binding/Alsa-AddCtl.c
index a1da706..02bc268 100644
--- a/alsa-binding/Alsa-AddCtl.c
+++ b/alsa-binding/Alsa-AddCtl.c
@@ -62,14 +62,14 @@ static const unsigned int *allocate_bool_fake_tlv(void) {
return tlv;
}
-static const unsigned int *allocate_int_dbscale_tlv(int min, int step, int mute) {
+static const unsigned int *allocate_int_dbscale_tlv(int min_dB, int max_dB) {
// SNDRV_CTL_TLVD_DECLARE_DB_SCALE(range, min, step, mute);
size_t tlvSize = sizeof (4 * sizeof (unsigned int));
unsigned int *tlv = malloc(tlvSize);
- tlv[0] = SNDRV_CTL_TLVT_DB_LINEAR;
- tlv[1] = (int) tlvSize;
- tlv[2] = min * 100;
- tlv[3] = ((step * 100) & SNDRV_CTL_TLVD_DB_SCALE_MASK) | ((mute * 100) ? SNDRV_CTL_TLVD_DB_SCALE_MUTE : 0);
+ tlv[0] = SND_CTL_TLVT_DB_SCALE;
+ tlv[1] = 2 * sizeof(int);
+ tlv[2] = (int)(min_dB * 100);
+ tlv[3] = (int)((max_dB - min_dB) * 100 / max_dB);
return tlv;
}
@@ -249,7 +249,7 @@ STATIC json_object * addOneSndCtl(afb_req request, snd_ctl_t *ctlDev, json_objec
int step = json_object_get_int(tmpJ);
if (step <= 0) step = 1;
- elemTlv = allocate_int_dbscale_tlv(min, max, step);
+ elemTlv = allocate_int_dbscale_tlv(min, max);
}
} else {
@@ -268,7 +268,7 @@ STATIC json_object * addOneSndCtl(afb_req request, snd_ctl_t *ctlDev, json_objec
goto OnErrorExit;
}
- int length = json_object_array_length(enumsJ);
+ size_t length = json_object_array_length(enumsJ);
const char **enumlabels = malloc(length * sizeof (char*));
for (int jdx = 0; jdx < length; jdx++) {
@@ -276,7 +276,7 @@ STATIC json_object * addOneSndCtl(afb_req request, snd_ctl_t *ctlDev, json_objec
enumlabels[jdx] = json_object_get_string(tmpJ);
}
- err = snd_ctl_add_enumerated_elem_set(ctlDev, elemInfo, 1, ctlCount, length, enumlabels);
+ err = snd_ctl_add_enumerated_elem_set(ctlDev, elemInfo, 1, ctlCount, (int) length, enumlabels);
if (err) {
afb_req_fail_f(request, "ctl-invalid-bool", "devid=%s crl=%s invalid enumerated control", snd_ctl_name(ctlDev), json_object_get_string(ctlJ));
goto OnErrorExit;