Fixed lisp for ordinary mixer API

This commit is contained in:
Jaroslav Kysela 2003-12-21 18:25:57 +00:00
parent 319c46a982
commit 4aec7396ff
5 changed files with 29 additions and 18 deletions

View file

@ -47,6 +47,9 @@
(+ 1.1 2.2 3.3) (&check-memory)
(+ 'aaaa) (&check-memory)
(+ 'aaaa 'bbbb) (&check-memory)
(+ "aaaa") (&check-memory)
(+ "aaaa" "bbbb") (&check-memory)
(+ "aaaa" "bbbb" "cccc") (&check-memory)
(-) (&check-memory)
(- 1) (&check-memory)

View file

@ -1138,9 +1138,8 @@ static struct alisp_object * F_add(struct alisp_instance *instance, struct alisp
lisp_warn(instance, "sum with a non integer or float operand");
}
delete_tree(instance, p1);
n = cdr(p);
delete_object(instance, p);
p = n;
p = cdr(n = p);
delete_object(instance, n);
if (p == &alsa_lisp_nil)
break;
p1 = eval(instance, car(p));
@ -1170,13 +1169,11 @@ static struct alisp_object * F_add(struct alisp_instance *instance, struct alisp
lisp_warn(instance, "concat with a non string or identifier operand");
}
delete_tree(instance, p1);
n = cdr(p);
delete_object(instance, p);
p = n;
p = cdr(n = p);
delete_object(instance, n);
if (p == &alsa_lisp_nil)
break;
p1 = eval(instance, car(p));
delete_object(instance, car(p));
}
p = new_string(instance, str);
free(str);
@ -1626,6 +1623,7 @@ static void princ_string(snd_output_t *out, char *s)
case '\r': snd_output_putc(out, '\\'); snd_output_putc(out, 'r'); break;
case '\t': snd_output_putc(out, '\\'); snd_output_putc(out, 't'); break;
case '\v': snd_output_putc(out, '\\'); snd_output_putc(out, 'v'); break;
case '"': snd_output_putc(out, '\\'); snd_output_putc(out, '"'); break;
default: snd_output_putc(out, *p);
}
snd_output_putc(out, '"');
@ -2219,11 +2217,9 @@ static struct alisp_object * F_unsetq(struct alisp_instance *instance, struct al
do {
if (p1)
delete_tree(instance, p1);
p1 = car(p);
delete_tree(instance, unset_object(instance, p1));
n = cdr(p);
delete_object(instance, p);
p = n;
p1 = unset_object(instance, car(p));
p = cdr(n = p);
delete_object(instance, n);
} while (p != &alsa_lisp_nil);
return p1;
@ -2482,13 +2478,19 @@ struct alisp_object * F_str(struct alisp_instance *instance, struct alisp_object
return p;
if (alisp_compare_type(p, ALISP_OBJ_INTEGER) ||
alisp_compare_type(p, ALISP_OBJ_FLOAT)) {
char buf[64];
if (alisp_compare_type(p, ALISP_INTEGER)) {
char *buf = malloc(64);
if (buf == NULL) {
delete_tree(instance, p);
nomem();
return NULL;
}
if (alisp_compare_type(p, ALISP_OBJ_INTEGER)) {
snprintf(buf, sizeof(buf), "%ld", p->value.i);
} else {
snprintf(buf, sizeof(buf), "%.f", p->value.f);
}
p1 = new_string(instance, buf);
free(buf);
} else {
lisp_warn(instance, "expected an integer or float for integer conversion");
p1 = &alsa_lisp_nil;

View file

@ -45,13 +45,12 @@ enum alisp_objects {
struct alisp_object;
#define ALISP_MAX_REFS 0x0fffffff
#define ALISP_MAX_REFS_LIMIT ((ALISP_MAX_REFS + 1) / 2)
#define ALISP_TYPE_MASK 0xf0000000
#define ALISP_TYPE_SHIFT 28
#define ALISP_REFS_MASK 0x0fffffff
#define ALISP_REFS_SHIFT 0
#define ALISP_MAX_REFS (ALISP_REFS_MASK>>ALISP_REFS_SHIFT)
#define ALISP_MAX_REFS_LIMIT ((ALISP_MAX_REFS + 1) / 2)
struct alisp_object {
struct list_head list;

View file

@ -66,7 +66,9 @@
(setq r (sndo_mixer_open1 ppcm "p"))
(when (= r 0) (setq r (sndo_mixer_open1 cpcm "c")))
(when (!= r 0) (sndo_mixer_close))
(unsetq r)
(unsetq sndo_mixer_open sndo_mixer_open1
sndo_mixer_open_virtual sndo_mixer_open_fcn
sndo_include r)
)
(defun sndo_mixer_close1 (hctl stream)

View file

@ -101,6 +101,11 @@ int sndo_mixer_open(sndo_mixer_t **pmixer,
cfg = alsa_lisp_default_cfg(input);
if (cfg == NULL)
return -ENOMEM;
#if 0
cfg->debug = 1;
cfg->verbose = 1;
cfg->warning = 1;
#endif
}
err = alsa_lisp(cfg, &alisp);
if (err < 0)