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>
37 static void free_zone_cb(void *);
40 pa_zoneset *pa_zoneset_init(struct userdata *u)
46 zs = pa_xnew0(pa_zoneset, 1);
47 zs->zones = pa_hashmap_new(pa_idxset_string_hash_func,
48 pa_idxset_string_compare_func);
54 void pa_zoneset_done(struct userdata *u)
59 if (u && (zs = u->zoneset)) {
60 pa_hashmap_free(zs->zones, free_zone_cb);
66 int pa_zoneset_add_zone(struct userdata *u, const char *name, uint32_t index)
73 pa_assert_se((zs = u->zoneset));
75 zone = pa_xnew0(mir_zone, 1);
76 zone->name = pa_xstrdup(name);
79 return pa_hashmap_put(zs->zones, zone->name, zone);
82 mir_zone *pa_zoneset_get_zone(struct userdata *u, const char *name)
88 pa_assert_se((zs = u->zoneset));
90 if (name && zs->zones)
91 zone = pa_hashmap_get(zs->zones, name);
99 void pa_zoneset_update_module_property(struct userdata *u)
109 pa_assert_se((module = u->module));
110 pa_assert_se((zs = u->zoneset));
111 pa_assert(zs->zones);
113 e = (p = buf) + sizeof(buf);
117 PA_HASHMAP_FOREACH(zone, zs->zones, state) {
119 p += snprintf(p, e-p, " '%s'", zone->name);
122 pa_proplist_sets(module->proplist, PA_PROP_ZONES, buf+1); /* skip ' '@begining */
125 static void free_zone_cb(void *void_zone)
127 mir_zone *zone = (mir_zone *)void_zone;
129 pa_xfree((void *)zone->name);
142 * indent-tabs-mode: nil