3a20ab9c84bfc9a315137ab2154b934815ecaaca
[staging/agl-audio-plugin.git] / zone.c
1 /*
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
6  *
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.
10  *
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.
15  *
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,
19  * MA 02110-1301 USA.
20  *
21  */
22 #include "zone.h"
23
24 struct agl_zoneset {
25         struct {
26                 pa_hashmap     *hash;
27                 agl_zone       *index[AGL_ZONE_MAX];
28         } zones;
29 };
30
31 agl_zoneset *agl_zoneset_init (struct userdata *u)
32 {
33         agl_zoneset *zs;
34
35         pa_assert (u);
36
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);
40
41         return zs;
42 }
43
44 void agl_zoneset_done (struct userdata *u)
45 {
46         agl_zoneset *zs;
47         void *state;
48         agl_zone *zone;
49
50         if (u && (zs = u->zoneset)) {
51
52                 PA_HASHMAP_FOREACH(zone, zs->zones.hash, state) {
53                         pa_xfree ((void *)zone->name);
54                 }
55                 pa_hashmap_free (zs->zones.hash);
56                 free (zs);
57         }    
58 }