scripting: add zone support
[profile/ivi/pulseaudio-module-murphy-ivi.git] / murphy / murphy-ivi.lua
1 zone { name = "driver" }
2 zone { name = "passanger1" }
3 zone { name = "passanger2" }
4 zone { name = "passanger3" }
5 zone { name = "passanger4" }
6
7 routing_group {
8     name = "default",
9     node_type = node.output,
10     accept = builtin.method.accept_default,
11     compare = builtin.method.compare_default
12 }
13
14 routing_group {
15     name = "phone",
16     node_type = node.input,
17     accept = builtin.method.accept_phone,
18     compare = builtin.method.compare_phone
19 }
20
21 routing_group {
22     name = "phone",
23     node_type = node.output,
24     accept = builtin.method.accept_phone,
25     compare = builtin.method.compare_phone
26 }
27
28 application_class {
29     node_type = node.event,
30     priority = 6,
31     route = {
32         output = routing_group.default_output
33     },
34     roles = { event = no_resource }
35 }
36
37 application_class {
38     class = "phone",
39     node_type = node.phone,
40     priority = 5,
41     route = {
42         input = routing_group.phone_input,
43         output = routing_group.phone_output
44     },
45     roles = { phone = no_resource, carkit = no_resource }
46 }
47
48 application_class {
49     node_type = node.alert,
50     priority = 4,
51     route = {
52         output = routing_group.default_output
53     },
54     roles = { ringtone = no_resource, alarm = no_resource }
55 }
56
57 application_class {
58     class = "navigator",
59     node_type = node.navigator,
60     priority = 3,
61     route = {
62         output = routing_group.default_output
63     },
64     roles = { navigator = {0, "autorelease", "mandatory", "shared"} }
65 }
66
67 application_class {
68     class = "game",
69     node_type = node.game,
70     priority = 2,
71     route = {
72         output = routing_group.default_output
73     },
74     roles = { game = {0, "mandatory", "exclusive"} }
75 }
76
77 application_class {
78     class = "player",
79     node_type = node.radio,
80     priority = 1,
81     route = {
82         output = routing_group.default_output
83     },
84     roles = { radio = {1, "mandatory", "exclusive"} },
85 }
86
87 application_class {
88     class = "player",
89     node_type = node.player,
90     priority = 1,
91     route = {
92         output = routing_group.default_output
93     },
94     roles = { music   = {0, "mandatory", "exclusive"},
95               video   = {0, "mandatory", "exclusive"},
96               test    = {0, "mandatory", "exclusive"}
97     }
98 }
99
100 application_class {
101     class = "player",
102     node_type = node.browser,
103     priority = 1,
104     route = {
105         output = routing_group.default_output
106     },
107     roles = { browser = {0, "mandatory", "shared"} }
108 }
109
110
111
112 audio_resource {
113     name = { recording = "audio_recording", playback = "audio_playback" },
114     attributes = {
115        role = {"media.role", mdb.string, "music"},
116        pid  = {"application.process.id", mdb.string, "<unknown>"}
117     }
118 }
119
120 mdb.import {
121     table = "speedvol",
122     columns = {"value"},
123     condition = "zone = 'driver' AND device = 'speaker'",
124     maxrow = 1,
125     update = builtin.method.make_volumes
126 }
127
128 mdb.import {
129     table = "audio_playback_owner",
130     columns = {"zone_id", "application_class", "role"},
131     condition = "zone_name = 'driver'",
132     maxrow = 1,
133     update = function(self)
134         zid = self[1].zone_id
135         if (zid == nil) then zid = "<nil>" end
136         class = self[1].application_class
137         if (class == nil) then class = "<nil>" end
138         role = self[1].role
139         if (role == nil) then role = "<nil>" end
140 --      print("*** import "..self.table.." update: zone:"..zid.." class:"..class.." role:"..role)
141     end
142 }
143
144 mdb.import {
145     table = "amb_shift_position",
146     columns = {"shift_position"},
147     condition = "id = 0",
148     maxrow = 1,
149     update = builtin.method.make_volumes
150 }
151
152 volume_limit {
153     name = "speed_adjust",
154     type = volume_limit.generic,
155     limit = mdb.import.speedvol:link(1,"value"),
156     calculate = builtin.method.volume_correct
157 }
158
159 volume_limit {
160     name = "suppress",
161     type = volume_limit.class,
162     limit = -20;
163     node_type = { node.phone, node.navigator },
164     calculate = builtin.method.volume_supress
165 }
166
167 volume_limit {
168     name = "video",
169     type = volume_limit.class,
170     limit = -90,
171     node_type = { node.player, node.game },
172     calculate = function(self, class, device)
173 --      print("*** limit "..self.name.." class:"..class.." stream:"..device.name)
174         position = mdb.import.amb_shift_position[1].shift_position
175         if (position  and position == 128) then
176             return self.limit
177         end
178         return 0
179     end
180 }
181
182