2 * module-agl-audio -- PulseAudio module for providing audio routing support
3 * (forked from "module-murphy-ivi" - https://github.com/otcshare )
4 * Copyright (c) 2012, Intel Corporation.
5 * Copyright (c) 2016, IoT.bzh
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU Lesser General Public License,
9 * version 2.1, as published by the Free Software Foundation.
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston,
27 agl_zone *index[AGL_ZONE_MAX];
31 agl_zoneset *agl_zoneset_init (struct userdata *u)
37 zs = pa_xnew0 (agl_zoneset, 1);
38 zs->zones.hash = pa_hashmap_new (pa_idxset_string_hash_func,
39 pa_idxset_string_compare_func);
44 void agl_zoneset_done (struct userdata *u)
50 if (u && (zs = u->zoneset)) {
52 PA_HASHMAP_FOREACH(zone, zs->zones.hash, state) {
53 pa_xfree ((void *)zone->name);
55 pa_hashmap_free (zs->zones.hash);
60 int agl_zoneset_add_zone (struct userdata *u, const char *name, uint32_t index)
67 pa_assert (index < AGL_ZONE_MAX);
68 pa_assert_se (zs = u->zoneset);
70 zone = pa_xnew (agl_zone, 1);
71 zone->name = pa_xstrdup (name);
74 pa_hashmap_put (zs->zones.hash, (void *)zone->name, zone);
76 zs->zones.index[index] = zone;
81 agl_zone *agl_zoneset_get_zone_by_name (struct userdata *u, const char *name)
87 pa_assert_se (zs = u->zoneset);
89 if (name && zs->zones.hash)
90 zone = pa_hashmap_get (zs->zones.hash, name);
97 agl_zone *agl_zoneset_get_zone_by_index (struct userdata *u, uint32_t index)
103 pa_assert_se (zs = u->zoneset);
105 if (index < AGL_ZONE_MAX)
106 zone = zs->zones.index[index];