all: update pa_module_unload() call to PA 8.0 api
[staging/agl-audio-plugin.git] / classify.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 <pulsecore/pulsecore-config.h> /* required for headers below */
23 #include <pulsecore/core-util.h>        /* required for "pa_streq" */
24
25 #include "classify.h"
26 #include "node.h"
27
28 agl_node_type agl_classify_guess_stream_node_type (struct userdata *u,  pa_proplist *pl)
29 {
30         agl_nodeset *ns;
31         agl_nodeset_map *map;
32         agl_node_type type;
33         const char *role;
34
35         pa_assert (u);
36         pa_assert (pl);
37         pa_assert_se (ns = u->nodeset);
38
39         role = pa_proplist_gets (pl, PA_PROP_MEDIA_ROLE);
40
41         if (!role)
42                 type = agl_node_type_unknown;
43
44          /* ask the configuration, see defaults in "config.c" */
45         else if (map = pa_hashmap_get (ns->roles, role))
46                 type = map->type;
47          /* configuration did not match, here are some sensible defaults */
48         else if (pa_streq (role, "radio"))
49                 type = agl_radio;
50         else if (pa_streq (role, "music"))
51                 type = agl_player;
52         else if (pa_streq (role, "navi"))
53                 type = agl_navigator;
54         else if (pa_streq (role, "game"))
55                 type = agl_game;
56         else if (pa_streq (role, "browser"))
57                 type = agl_browser;
58         else if (pa_streq (role, "camera"))
59                 type = agl_camera;
60         else if (pa_streq (role, "phone"))
61                 type = agl_phone;
62         else if (pa_streq (role, "alert"))
63                 type = agl_alert;
64         else if (pa_streq (role, "event"))
65                 type = agl_event;
66         else if (pa_streq (role, "system"))
67                 type = agl_system;
68         else
69                 type = agl_player;
70
71         return type;
72 }