mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-09 17:35:42 +01:00
Fixed some trouble with USER switch and added USER_READ_ONLY switch support.
This commit is contained in:
parent
6016056f83
commit
079252a8f7
4 changed files with 27 additions and 9 deletions
|
@ -121,11 +121,15 @@ true|on|yes return L_TRUE;
|
|||
int val;
|
||||
yylval.a_value.data = d = (unsigned char *)malloc( 32 );
|
||||
yylval.a_value.datalen = 0;
|
||||
while (p) {
|
||||
strncpy(x, p, 2); x[2] = '\0';
|
||||
sscanf(x, "%02x", &val);
|
||||
*d++ = val;
|
||||
++yylval.a_value.datalen;
|
||||
while (*p) {
|
||||
strncpy(x, p, 2); x[2] = '\0';
|
||||
sscanf(x, "%02x", &val);
|
||||
*d++ = val;
|
||||
++yylval.a_value.datalen;
|
||||
p += 2;
|
||||
if (*p == '@')
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
return L_BYTEARRAY; }
|
||||
|
||||
|
|
|
@ -810,7 +810,7 @@ static void set_switch_integer(int val)
|
|||
|
||||
static void set_switch_bytearray(struct bytearray val)
|
||||
{
|
||||
Xswitch->s.type = SND_SW_TYPE_LAST + 1;
|
||||
Xswitch->s.type = SND_SW_TYPE_USER;
|
||||
|
||||
if (val.datalen > 32)
|
||||
yyerror("Byte array too large for switch.");
|
||||
|
|
|
@ -99,6 +99,18 @@ static int merge_one_sw(struct ctl_switch *csw, struct ctl_switch *usw, int card
|
|||
csw->s.value.data32[0] = usw->s.value.data32[0];
|
||||
}
|
||||
break;
|
||||
case SND_SW_TYPE_USER_READ_ONLY:
|
||||
break;
|
||||
case SND_SW_TYPE_USER:
|
||||
if (usw->s.type != SND_SW_TYPE_USER) {
|
||||
error("A wrong type %i for the switch %s. The type user is expected. Skipping...", usw->s.type, sw_id(usw->s.name, cardno, devno, id));
|
||||
return 1;
|
||||
}
|
||||
if (memcmp(csw->s.value.data8, usw->s.value.data8, 32)) {
|
||||
csw->change = 1;
|
||||
memcpy(csw->s.value.data8, usw->s.value.data8, 32);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error("The switch type %i is not known.", csw->s.type);
|
||||
}
|
||||
|
|
|
@ -666,6 +666,8 @@ static void soundcard_setup_write_switch(FILE * out, const char *space, int inte
|
|||
s = "list";
|
||||
sprintf(v, "%u", sw->value.item_number);
|
||||
break;
|
||||
case SND_SW_TYPE_USER_READ_ONLY:
|
||||
return;
|
||||
default:
|
||||
s = "unknown";
|
||||
}
|
||||
|
@ -726,11 +728,11 @@ static void soundcard_setup_write_switch(FILE * out, const char *space, int inte
|
|||
fprintf(out, v);
|
||||
if (sw->type < 0 || sw->type > SND_SW_TYPE_LIST_ITEM) {
|
||||
/* TODO: some well known types should be verbose */
|
||||
fprintf(out, "rawdata(");
|
||||
fprintf(out, "rawdata(@");
|
||||
for (idx = 0; idx < 31; idx++) {
|
||||
fprintf(out, "@%02x:", sw->value.data8[idx]);
|
||||
fprintf(out, "%02x:", sw->value.data8[idx]);
|
||||
}
|
||||
fprintf(out, "%02x@)\n", sw->value.data8[31]);
|
||||
fprintf(out, "%02x@)", sw->value.data8[31]);
|
||||
}
|
||||
}
|
||||
__end:
|
||||
|
|
Loading…
Reference in a new issue