mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-31 22:25:35 -04:00
More alisp changes
This commit is contained in:
parent
16647d9c53
commit
2699f5510b
3 changed files with 70 additions and 7 deletions
|
|
@ -49,7 +49,14 @@
|
|||
(princ "last : " (acall 'hctl_last_elem hctl) "\n")
|
||||
(princ "next (first): " (acall 'hctl_elem_next (acall 'hctl_first_elem hctl)) "\n")
|
||||
(princ "prev (last) : " (acall 'hctl_elem_prev (acall 'hctl_last_elem hctl)) "\n")
|
||||
(princ "first info : " (acall 'hctl_elem_info (acall 'hctl_first_elem hctl)) "\n")
|
||||
(setq elem (acall 'hctl_first_elem hctl))
|
||||
(while elem
|
||||
(progn
|
||||
(setq info (acall 'hctl_elem_info elem))
|
||||
(princ info "\n")
|
||||
(setq elem (acall 'hctl_elem_next elem))
|
||||
)
|
||||
)
|
||||
(setq hctl (acall 'hctl_close hctl))
|
||||
(if (= hctl 0)
|
||||
(princ "hctl close success\n")
|
||||
|
|
@ -66,3 +73,5 @@
|
|||
(princ "ctl open failed: " ctl "\n")
|
||||
)
|
||||
)
|
||||
|
||||
(&stat-memory)
|
||||
|
|
|
|||
|
|
@ -683,6 +683,7 @@ static const char *obj_type_str(struct alisp_object * p)
|
|||
case ALISP_OBJ_FLOAT: return "float";
|
||||
case ALISP_OBJ_IDENTIFIER: return "identifier";
|
||||
case ALISP_OBJ_STRING: return "string";
|
||||
case ALISP_OBJ_POINTER: return "pointer";
|
||||
case ALISP_OBJ_CONS: return "cons";
|
||||
default: assert(0);
|
||||
}
|
||||
|
|
@ -777,10 +778,14 @@ static void do_garbage_collect(struct alisp_instance *instance)
|
|||
lisp_debug(instance, "** collecting cons %p", p);
|
||||
free_object(p);
|
||||
|
||||
p->next = instance->free_objs_list;
|
||||
instance->free_objs_list = p;
|
||||
if (instance->free_objs < 1000) {
|
||||
p->next = instance->free_objs_list;
|
||||
instance->free_objs_list = p;
|
||||
++instance->free_objs;
|
||||
} else {
|
||||
free(p);
|
||||
}
|
||||
|
||||
++instance->free_objs;
|
||||
--instance->used_objs;
|
||||
} else {
|
||||
/* The object is referenced somewhere. */
|
||||
|
|
@ -1884,6 +1889,17 @@ static struct alisp_object * F_dump_memory(struct alisp_instance *instance, stru
|
|||
return &alsa_lisp_nil;
|
||||
}
|
||||
|
||||
static struct alisp_object * F_stat_memory(struct alisp_instance *instance, struct alisp_object * args ATTRIBUTE_UNUSED)
|
||||
{
|
||||
snd_output_printf(instance->out, "*** Memory stats\n");
|
||||
snd_output_printf(instance->out, " used_objs = %i, free_objs = %i, obj_size = %i (total = %i)\n",
|
||||
instance->used_objs,
|
||||
instance->free_objs,
|
||||
sizeof(struct alisp_object),
|
||||
(instance->used_objs + instance->free_objs) * sizeof(struct alisp_object));
|
||||
return &alsa_lisp_nil;
|
||||
}
|
||||
|
||||
static struct alisp_object * F_dump_objects(struct alisp_instance *instance, struct alisp_object * args)
|
||||
{
|
||||
struct alisp_object * p = car(args);
|
||||
|
|
@ -1909,6 +1925,7 @@ static struct intrinsic intrinsics[] = {
|
|||
{ "%", F_mod },
|
||||
{ "&dump-memory", F_dump_memory },
|
||||
{ "&dump-objects", F_dump_objects },
|
||||
{ "&stat-memory", F_stat_memory },
|
||||
{ "*", F_mul },
|
||||
{ "+", F_add },
|
||||
{ "-", F_sub },
|
||||
|
|
|
|||
|
|
@ -137,6 +137,30 @@ static struct alisp_object * add_cons(struct alisp_instance * instance, struct a
|
|||
return lexpr;
|
||||
}
|
||||
|
||||
static struct alisp_object * add_cons1(struct alisp_instance * instance, struct alisp_object *lexpr, int cdr, int id, struct alisp_object *obj)
|
||||
{
|
||||
struct alisp_object * p1;
|
||||
|
||||
if (lexpr == NULL || obj == NULL)
|
||||
return NULL;
|
||||
if (cdr) {
|
||||
p1 = lexpr->value.c.cdr = new_object(instance, ALISP_OBJ_CONS);
|
||||
} else {
|
||||
p1 = lexpr->value.c.car = new_object(instance, ALISP_OBJ_CONS);
|
||||
}
|
||||
lexpr = p1;
|
||||
if (p1 == NULL)
|
||||
return NULL;
|
||||
p1->value.c.car = new_object(instance, ALISP_OBJ_CONS);
|
||||
if ((p1 = p1->value.c.car) == NULL)
|
||||
return NULL;
|
||||
p1->value.c.car = new_integer(instance, id);
|
||||
if (p1->value.c.car == NULL)
|
||||
return NULL;
|
||||
p1->value.c.cdr = obj;
|
||||
return lexpr;
|
||||
}
|
||||
|
||||
static inline struct alisp_object * new_result(struct alisp_instance * instance, int err)
|
||||
{
|
||||
return new_integer(instance, err);
|
||||
|
|
@ -361,7 +385,7 @@ static struct alisp_object * FA_card_info(struct alisp_instance * instance, stru
|
|||
static struct alisp_object * create_ctl_elem_id(struct alisp_instance * instance, snd_ctl_elem_id_t * id, struct alisp_object * cons)
|
||||
{
|
||||
cons = add_cons(instance, cons, 0, "numid", new_integer(instance, snd_ctl_elem_id_get_numid(id)));
|
||||
cons = add_cons(instance, cons, 1, "iface", new_string(instance, snd_ctl_elem_iface_name(snd_ctl_elem_id_get_numid(id))));
|
||||
cons = add_cons(instance, cons, 1, "iface", new_string(instance, snd_ctl_elem_iface_name(snd_ctl_elem_id_get_interface(id))));
|
||||
cons = add_cons(instance, cons, 1, "dev", new_integer(instance, snd_ctl_elem_id_get_device(id)));
|
||||
cons = add_cons(instance, cons, 1, "subdev", new_integer(instance, snd_ctl_elem_id_get_subdevice(id)));
|
||||
cons = add_cons(instance, cons, 1, "name", new_string(instance, snd_ctl_elem_id_get_name(id)));
|
||||
|
|
@ -402,8 +426,21 @@ static struct alisp_object * FA_hctl_elem_info(struct alisp_instance * instance,
|
|||
p1 = add_cons(instance, p1, 1, "isowner", new_integer(instance, snd_ctl_elem_info_is_owner(info)));
|
||||
p1 = add_cons(instance, p1, 1, "owner", new_integer(instance, snd_ctl_elem_info_get_owner(info)));
|
||||
p1 = add_cons(instance, p1, 1, "count", new_integer(instance, snd_ctl_elem_info_get_count(info)));
|
||||
if (type == SND_CTL_ELEM_TYPE_ENUMERATED)
|
||||
p1 = add_cons(instance, p1, 1, "items", new_integer(instance, snd_ctl_elem_info_get_items(info)));
|
||||
if (type == SND_CTL_ELEM_TYPE_ENUMERATED) {
|
||||
unsigned int items, item;
|
||||
items = snd_ctl_elem_info_get_items(info);
|
||||
p1 = add_cons(instance, p1, 1, "items", new_integer(instance, items));
|
||||
p1 = add_cons(instance, p1, 1, "inames", p2 = new_object(instance, ALISP_OBJ_CONS));
|
||||
for (item = 0; item < items; item++) {
|
||||
snd_ctl_elem_info_set_item(info, item);
|
||||
err = snd_hctl_elem_info(handle, info);
|
||||
if (err < 0) {
|
||||
p2 = add_cons1(instance, p2, item > 0, item, &alsa_lisp_nil);
|
||||
} else {
|
||||
p2 = add_cons1(instance, p2, item > 0, item, new_string(instance, snd_ctl_elem_info_get_item_name(info)));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p1 == NULL)
|
||||
return NULL;
|
||||
return lexpr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue