OSDN Git Service

Fixed lisp for ordinary mixer API
authorJaroslav Kysela <perex@perex.cz>
Sun, 21 Dec 2003 18:25:57 +0000 (18:25 +0000)
committerJaroslav Kysela <perex@perex.cz>
Sun, 21 Dec 2003 18:25:57 +0000 (18:25 +0000)
alsalisp/test.lisp
src/alisp/alisp.c
src/alisp/alisp_local.h
src/conf/sndo-mixer.alisp
src/ordinary_mixer/ordinary_mixer.c

index 3ac061d..eebb7b7 100644 (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)
index f335d2b..e70b6d2 100644 (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;
index c5836d7..920b100 100644 (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;
index 3b3ffdf..b125b6e 100644 (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)
index 9443a04..fe9eb4d 100644 (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)