1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
| pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel_map *bonus) { pa_alsa_profile_set *ps; pa_alsa_profile *p; pa_alsa_mapping *m; pa_alsa_decibel_fix *db_fix; char *fn; int r; void *state;
static pa_config_item items[] = { { "auto-profiles", pa_config_parse_bool, NULL, "General" },
{ "device-strings", mapping_parse_device_strings, NULL, NULL }, { "channel-map", mapping_parse_channel_map, NULL, NULL }, { "paths-input", mapping_parse_paths, NULL, NULL }, { "paths-output", mapping_parse_paths, NULL, NULL }, { "element-input", mapping_parse_element, NULL, NULL }, { "element-output", mapping_parse_element, NULL, NULL }, { "direction", mapping_parse_direction, NULL, NULL }, { "exact-channels", mapping_parse_exact_channels, NULL, NULL },
{ "description", mapping_parse_description, NULL, NULL }, { "priority", mapping_parse_priority, NULL, NULL }, { "fallback", mapping_parse_fallback, NULL, NULL },
{ "input-mappings", profile_parse_mappings, NULL, NULL }, { "output-mappings", profile_parse_mappings, NULL, NULL }, { "skip-probe", profile_parse_skip_probe, NULL, NULL },
{ "db-values", decibel_fix_parse_db_values, NULL, NULL }, { NULL, NULL, NULL, NULL } };
ps = pa_xnew0(pa_alsa_profile_set, 1);
ps->mappings = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) mapping_free); ps->profiles = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) profile_free); ps->decibel_fixes = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) decibel_fix_free); ps->input_paths = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) pa_alsa_path_free); ps->output_paths = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) pa_alsa_path_free);
ps->cust_paths = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, (pa_free_cb_t) pa_xfree, (pa_free_cb_t) pa_xfree); ps->cust_folder = NULL;
items[0].data = &ps->auto_profiles;
if (!fname) fname = "default.conf";
fn = pa_maybe_prefix_path(fname, pa_run_from_build_tree() ? PA_SRCDIR "/modules/alsa/mixer/profile-sets/" : PA_ALSA_PROFILE_SETS_DIR);
r = pa_config_parse(fn, NULL, items, NULL, false, ps); pa_xfree(fn);
if (r < 0) goto fail;
PA_HASHMAP_FOREACH(m, ps->mappings, state) if (mapping_verify(m, bonus) < 0) goto fail;
if (ps->auto_profiles) profile_set_add_auto(ps);
PA_HASHMAP_FOREACH(p, ps->profiles, state) if (profile_verify(p) < 0) goto fail;
PA_HASHMAP_FOREACH(db_fix, ps->decibel_fixes, state) if (decibel_fix_verify(db_fix) < 0) goto fail;
return ps;
fail: pa_alsa_profile_set_free(ps); return NULL; }
|