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) (+ 1.1 2.2 3.3) (&check-memory)
(+ 'aaaa) (&check-memory) (+ 'aaaa) (&check-memory)
(+ 'aaaa 'bbbb) (&check-memory) (+ 'aaaa 'bbbb) (&check-memory)
(+ "aaaa") (&check-memory)
(+ "aaaa" "bbbb") (&check-memory)
(+ "aaaa" "bbbb" "cccc") (&check-memory)
(-) (&check-memory) (-) (&check-memory)
(- 1) (&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"); lisp_warn(instance, "sum with a non integer or float operand");
} }
delete_tree(instance, p1); delete_tree(instance, p1);
n = cdr(p); p = cdr(n = p);
delete_object(instance, p); delete_object(instance, n);
p = n;
if (p == &alsa_lisp_nil) if (p == &alsa_lisp_nil)
break; break;
p1 = eval(instance, car(p)); 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"); lisp_warn(instance, "concat with a non string or identifier operand");
} }
delete_tree(instance, p1); delete_tree(instance, p1);
n = cdr(p); p = cdr(n = p);
delete_object(instance, p); delete_object(instance, n);
p = n;
if (p == &alsa_lisp_nil) if (p == &alsa_lisp_nil)
break; break;
p1 = eval(instance, car(p)); p1 = eval(instance, car(p));
delete_object(instance, car(p));
} }
p = new_string(instance, str); p = new_string(instance, str);
free(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 '\r': snd_output_putc(out, '\\'); snd_output_putc(out, 'r'); break;
case '\t': snd_output_putc(out, '\\'); snd_output_putc(out, 't'); 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 '\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); default: snd_output_putc(out, *p);
} }
snd_output_putc(out, '"'); snd_output_putc(out, '"');
@ -2219,11 +2217,9 @@ static struct alisp_object * F_unsetq(struct alisp_instance *instance, struct al
do { do {
if (p1) if (p1)
delete_tree(instance, p1); delete_tree(instance, p1);
p1 = car(p); p1 = unset_object(instance, car(p));
delete_tree(instance, unset_object(instance, p1)); p = cdr(n = p);
n = cdr(p); delete_object(instance, n);
delete_object(instance, p);
p = n;
} while (p != &alsa_lisp_nil); } while (p != &alsa_lisp_nil);
return p1; return p1;
@ -2482,13 +2478,19 @@ struct alisp_object * F_str(struct alisp_instance *instance, struct alisp_object
return p; return p;
if (alisp_compare_type(p, ALISP_OBJ_INTEGER) || if (alisp_compare_type(p, ALISP_OBJ_INTEGER) ||
alisp_compare_type(p, ALISP_OBJ_FLOAT)) { alisp_compare_type(p, ALISP_OBJ_FLOAT)) {
char buf[64]; char *buf = malloc(64);
if (alisp_compare_type(p, ALISP_INTEGER)) { 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); snprintf(buf, sizeof(buf), "%ld", p->value.i);
} else { } else {
snprintf(buf, sizeof(buf), "%.f", p->value.f); snprintf(buf, sizeof(buf), "%.f", p->value.f);
} }
p1 = new_string(instance, buf); p1 = new_string(instance, buf);
free(buf);
} else { } else {
lisp_warn(instance, "expected an integer or float for integer conversion"); lisp_warn(instance, "expected an integer or float for integer conversion");
p1 = &alsa_lisp_nil; p1 = &alsa_lisp_nil;

View file

@ -45,13 +45,12 @@ enum alisp_objects {
struct alisp_object; 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_MASK 0xf0000000
#define ALISP_TYPE_SHIFT 28 #define ALISP_TYPE_SHIFT 28
#define ALISP_REFS_MASK 0x0fffffff #define ALISP_REFS_MASK 0x0fffffff
#define ALISP_REFS_SHIFT 0 #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 alisp_object {
struct list_head list; struct list_head list;

View file

@ -66,7 +66,9 @@
(setq r (sndo_mixer_open1 ppcm "p")) (setq r (sndo_mixer_open1 ppcm "p"))
(when (= r 0) (setq r (sndo_mixer_open1 cpcm "c"))) (when (= r 0) (setq r (sndo_mixer_open1 cpcm "c")))
(when (!= r 0) (sndo_mixer_close)) (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) (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); cfg = alsa_lisp_default_cfg(input);
if (cfg == NULL) if (cfg == NULL)
return -ENOMEM; return -ENOMEM;
#if 0
cfg->debug = 1;
cfg->verbose = 1;
cfg->warning = 1;
#endif
} }
err = alsa_lisp(cfg, &alisp); err = alsa_lisp(cfg, &alisp);
if (err < 0) if (err < 0)