2 * module-murphy-ivi -- PulseAudio module for providing audio routing support
3 * Copyright (c) 2012, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU Lesser General Public License,
7 * version 2.1, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston,
22 #include <pulsecore/pulsecore-config.h>
24 #include <pulse/proplist.h>
25 #include <pulsecore/idxset.h>
26 #include <pulsecore/hashmap.h>
27 #include <pulsecore/module.h>
29 #include <murphy/resource/data-types.h>
37 mir_zone *index[MRP_ZONE_MAX];
42 static void free_zone_cb(void *);
45 pa_zoneset *pa_zoneset_init(struct userdata *u)
51 zs = pa_xnew0(pa_zoneset, 1);
52 zs->zones.hash = pa_hashmap_new(pa_idxset_string_hash_func,
53 pa_idxset_string_compare_func);
58 void pa_zoneset_done(struct userdata *u)
64 if (u && (zs = u->zoneset)) {
66 PA_HASHMAP_FOREACH(zone, zs->zones.hash, state) {
67 pa_xfree((void *)zone->name);
70 pa_hashmap_free(zs->zones.hash);
76 int pa_zoneset_add_zone(struct userdata *u, const char *name, uint32_t index)
83 pa_assert(index < MRP_ZONE_MAX);
84 pa_assert_se((zs = u->zoneset));
86 zone = pa_xnew0(mir_zone, 1);
87 zone->name = pa_xstrdup(name);
90 if (pa_hashmap_put(zs->zones.hash, (void *)zone->name, zone))
93 zs->zones.index[index] = zone;
98 mir_zone *pa_zoneset_get_zone_by_name(struct userdata *u, const char *name)
104 pa_assert_se((zs = u->zoneset));
106 if (name && zs->zones.hash)
107 zone = pa_hashmap_get(zs->zones.hash, name);
115 mir_zone *pa_zoneset_get_zone_by_index(struct userdata *u, uint32_t index)
121 pa_assert_se((zs = u->zoneset));
123 if (index < MRP_ZONE_MAX)
124 zone = zs->zones.index[index];
131 void pa_zoneset_update_module_property(struct userdata *u)
141 pa_assert_se((module = u->module));
142 pa_assert_se((zs = u->zoneset));
143 pa_assert(zs->zones.hash);
145 e = (p = buf) + sizeof(buf);
149 PA_HASHMAP_FOREACH(zone, zs->zones.hash, state) {
151 p += snprintf(p, e-p, " '%s'", zone->name);
154 pa_proplist_sets(module->proplist, PA_PROP_ZONES, buf+1);
157 static void free_zone_cb(void *void_zone)
159 mir_zone *zone = (mir_zone *)void_zone;
161 pa_xfree((void *)zone->name);
174 * indent-tabs-mode: nil