Fixed some trouble with USER switch and added USER_READ_ONLY switch support.

This commit is contained in:
Jaroslav Kysela 2000-01-27 21:41:36 +00:00
parent 6016056f83
commit 079252a8f7
4 changed files with 27 additions and 9 deletions

View file

@ -121,11 +121,15 @@ true|on|yes return L_TRUE;
int val; int val;
yylval.a_value.data = d = (unsigned char *)malloc( 32 ); yylval.a_value.data = d = (unsigned char *)malloc( 32 );
yylval.a_value.datalen = 0; yylval.a_value.datalen = 0;
while (p) { while (*p) {
strncpy(x, p, 2); x[2] = '\0'; strncpy(x, p, 2); x[2] = '\0';
sscanf(x, "%02x", &val); sscanf(x, "%02x", &val);
*d++ = val; *d++ = val;
++yylval.a_value.datalen; ++yylval.a_value.datalen;
p += 2;
if (*p == '@')
break;
p++;
} }
return L_BYTEARRAY; } return L_BYTEARRAY; }

View file

@ -810,7 +810,7 @@ static void set_switch_integer(int val)
static void set_switch_bytearray(struct bytearray 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) if (val.datalen > 32)
yyerror("Byte array too large for switch."); yyerror("Byte array too large for switch.");

View file

@ -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]; csw->s.value.data32[0] = usw->s.value.data32[0];
} }
break; 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: default:
error("The switch type %i is not known.", csw->s.type); error("The switch type %i is not known.", csw->s.type);
} }

View file

@ -666,6 +666,8 @@ static void soundcard_setup_write_switch(FILE * out, const char *space, int inte
s = "list"; s = "list";
sprintf(v, "%u", sw->value.item_number); sprintf(v, "%u", sw->value.item_number);
break; break;
case SND_SW_TYPE_USER_READ_ONLY:
return;
default: default:
s = "unknown"; s = "unknown";
} }
@ -726,11 +728,11 @@ static void soundcard_setup_write_switch(FILE * out, const char *space, int inte
fprintf(out, v); fprintf(out, v);
if (sw->type < 0 || sw->type > SND_SW_TYPE_LIST_ITEM) { if (sw->type < 0 || sw->type > SND_SW_TYPE_LIST_ITEM) {
/* TODO: some well known types should be verbose */ /* TODO: some well known types should be verbose */
fprintf(out, "rawdata("); fprintf(out, "rawdata(@");
for (idx = 0; idx < 31; idx++) { 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: __end: