Lines Matching refs:list
34 char **list;
51 static int hint_list_add(struct hint_list *list,
57 if (list->count + 1 >= list->allocated) {
58 char **n = realloc(list->list, (list->allocated + 10) * sizeof(char *));
61 memset(n + list->allocated, 0, 10 * sizeof(*n));
62 list->allocated += 10;
63 list->list = n;
78 list->list[list->count++] = x;
85 static int hint_list_add_custom(struct hint_list *list,
96 return hint_list_add(list, entry, NULL);
102 err = hint_list_add(list, name, sep + 1);
116 static int get_dev_name1(struct hint_list *list, char **res, int device,
122 switch (list->iface) {
128 if (snd_ctl_hwdep_info(list->ctl, &info) < 0)
140 if (snd_ctl_pcm_info(list->ctl, &info) < 0)
159 if (snd_ctl_rawmidi_info(list->ctl, &info) < 0)
170 static char *get_dev_name(struct hint_list *list)
175 device = list->device_input >= 0 ? list->device_input : list->device;
176 if (get_dev_name1(list, &str1, device, 1) < 0)
178 device = list->device_output >= 0 ? list->device_output : list->device;
179 if (get_dev_name1(list, &str2, device, 0) < 0) {
187 res = malloc(strlen(list->cardname) + strlen(str2) + 3);
189 strcpy(res, list->cardname);
194 res = malloc(strlen(list->cardname) + strlen(str2) + strlen(str1) + 6);
196 strcpy(res, list->cardname);
213 res = malloc(strlen(list->cardname) + strlen(str1) + 19);
218 strcpy(res, list->cardname);
228 if (list->device >= 0 || list->device_input >= 0 || list->device_output >= 0)
230 return strdup(list->cardname);
238 struct hint_list *list,
248 long dev = list->device;
251 list->device_input = -1;
252 list->device_output = -1;
263 if (list->card >= 0 && list->device >= 0)
264 sprintf(buf, "%s:CARD=%s,DEV=%i", name, snd_ctl_card_info_get_id(list->info), list->device);
265 else if (list->card >= 0)
266 sprintf(buf, "%s:CARD=%s", name, snd_ctl_card_info_get_id(list->info));
314 if (list->card < 0 &&
337 list->device_input = dev;
338 list->device_output = dev;
341 if (snd_config_get_integer(n, &list->device_input) < 0) {
347 if (list->device_output < 0)
348 list->device_output = DEV_SKIP;
351 if (snd_config_get_integer(n, &list->device_output) < 0) {
357 if (list->device_input < 0)
358 list->device_input = DEV_SKIP;
360 } else if (level == 1 && !list->show_all)
379 /* skip the argument list */
397 list->device = dev;
398 str = list->card >= 0 ? get_dev_name(list) : NULL;
418 } else if (list->device >= 0)
420 err = hint_list_add(list, buf, buf1);
447 static int add_card(snd_config_t *config, snd_config_t *rw_config, struct hint_list *list, int card)
457 list->info = &info;
458 err = snd_config_search(config, list->siface, &conf);
462 err = snd_ctl_open(&list->ctl, ctl_name, 0);
465 err = snd_ctl_card_info(list->ctl, &info);
473 if (next_devices[list->iface] != NULL) {
474 list->card = card;
476 err = next_devices[list->iface](list->ctl, &device);
482 err = next_devices[list->iface](list->ctl, &device);
488 list->device = device;
489 err = try_config(rw_config, list, list->siface, str);
502 list->card = card;
503 list->device = -1;
504 err = try_config(rw_config, list, list->siface, str);
511 snd_ctl_close(list->ctl);
515 static int get_card_name(struct hint_list *list, int card)
520 free(list->cardname);
521 list->cardname = NULL;
522 err = snd_card_get_name(card, &list->cardname);
526 s = realloc(list->cardname, strlen(list->cardname) + strlen(scard) + 1);
529 list->cardname = s;
534 struct hint_list *list)
541 err = snd_config_search(config, list->siface, &conf);
548 list->card = -1;
549 list->device = -1;
550 err = try_config(rw_config, list, list->siface, str);
585 struct hint_list list;
601 list.list = NULL;
602 list.count = list.allocated = 0;
603 list.siface = iface;
604 list.show_all = 0;
605 list.cardname = NULL;
607 list.iface = SND_CTL_ELEM_IFACE_PCM;
609 list.iface = SND_CTL_ELEM_IFACE_RAWMIDI;
611 list.iface = SND_CTL_ELEM_IFACE_TIMER;
613 list.iface = SND_CTL_ELEM_IFACE_SEQUENCER;
615 list.iface = SND_CTL_ELEM_IFACE_HWDEP;
617 list.iface = SND_CTL_ELEM_IFACE_MIXER;
624 list.show_all = snd_config_get_bool(conf) > 0;
626 err = get_card_name(&list, card);
628 err = add_card(local_config, local_config_rw, &list, card);
630 add_software_devices(local_config, local_config_rw, &list);
635 err = get_card_name(&list, card);
638 err = add_card(local_config, local_config_rw, &list, card);
646 sprintf(ehints, "namehint.%s", list.siface);
653 err = hint_list_add_custom(&list, str);
663 if (!err && !list.list)
664 err = hint_list_add(&list, NULL, NULL);
666 snd_device_name_free_hint((void **)list.list);
668 *hints = (void **)list.list;
669 free(list.cardname);
680 * \brief Free a list of device name hints.