add appid property back to resource attributes
[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_driver",
9     node_type = node.output,
10     accept = function(self, n)
11         return (n.type ~= node.bluetooth_carkit and n.type ~= node.hdmi)
12     end,
13     compare = builtin.method.compare_default
14 }
15
16 routing_group {
17     name = "default_passanger1",
18     node_type = node.output,
19     accept = function(self, n)
20         return (n.type == node.hdmi or n.name == 'Silent')
21     end,
22     compare = builtin.method.compare_default
23 }
24
25 routing_group {
26     name = "phone",
27     node_type = node.input,
28     accept = builtin.method.accept_phone,
29     compare = builtin.method.compare_phone
30 }
31
32 routing_group {
33     name = "phone",
34     node_type = node.output,
35     accept = builtin.method.accept_phone,
36     compare = builtin.method.compare_phone
37 }
38
39 application_class {
40     class = "event",
41     node_type = node.event,
42     priority = 6,
43     route = {
44         output = { driver = routing_group.default_driver_output }
45     },
46     roles = { event  = no_resource,
47               speech = no_resource }
48 }
49
50 application_class {
51     class = "phone",
52     node_type = node.phone,
53     priority = 5,
54     route = {
55         input  = { driver = routing_group.phone_input },
56         output = {driver = routing_group.phone_output }
57     },
58     roles = { phone = no_resource, carkit = no_resource }
59 }
60
61 application_class {
62     node_type = node.alert,
63     priority = 4,
64     route = {
65         output = { driver = routing_group.default_driver_output },
66     },
67     roles = { ringtone = no_resource, alarm = no_resource }
68 }
69
70 application_class {
71     class = "navigator",
72     node_type = node.navigator,
73     priority = 3,
74     route = {
75         output = { driver = routing_group.default_driver_output,
76                passanger1 = routing_group.default_passanger1_output }
77     },
78     roles = { navigator = {0, "autorelease", "mandatory", "shared"} },
79     binaries = { ['net.zmap.navi'] = { 0, "autorelease", "mandatory", "shared" } }
80 }
81
82 application_class {
83     class = "game",
84     node_type = node.game,
85     priority = 2,
86     route = {
87         output = { driver = routing_group.default_driver_output,
88                passanger1 = routing_group.default_passanger1_output }
89     },
90     roles = { game = {0, "mandatory", "exclusive"} }
91 }
92
93 application_class {
94     class = "player",
95     node_type = node.radio,
96     priority = 1,
97     route = {
98         output = { driver = routing_group.default_driver_output }
99     },
100     roles = { radio = {1, "mandatory", "exclusive"} },
101 }
102
103 application_class {
104     class = "player",
105     node_type = node.player,
106     priority = 1,
107     route = {
108         output = { driver = routing_group.default_driver_output,
109                    passanger1 = routing_group.default_passanger1_output }
110     },
111     roles = { music    = {0, "mandatory", "exclusive"},
112               video    = {0, "mandatory", "exclusive"},
113               test     = {0, "mandatory", "exclusive"},
114               bt_music = no_resource,
115               player   = no_resource
116     },
117     binaries = { ['t8j6HTRpuz.MediaPlayer'] = "music" }
118 }
119
120 application_class {
121     class = "player",
122     node_type = node.browser,
123     priority = 1,
124     route = {
125         output = { driver = routing_group.default_driver_output,
126                passanger1 = routing_group.default_passanger1_output }
127     },
128     roles = { browser = {0, "mandatory", "shared"} }
129 }
130
131
132
133 audio_resource {
134     name = { recording = "audio_recording", playback = "audio_playback" },
135     attributes = {
136        role = {"media.role", mdb.string, "music"},
137        pid  = {"application.process.id", mdb.string, "<unknown>"},
138        name = {"resource.set.name", mdb.string, "<unknown>"},
139        appid = {"resource.set.appid", mdb.string, "<unknown>"}
140     }
141 }
142
143 mdb.import {
144     table = "speedvol",
145     columns = {"value"},
146     condition = "zone = 'driver' AND device = 'speaker'",
147     maxrow = 1,
148     update = builtin.method.make_volumes
149 }
150
151 mdb.import {
152     table = "audio_playback_owner",
153     columns = {"zone_id", "application_class", "role"},
154     condition = "zone_name = 'driver'",
155     maxrow = 1,
156     update = function(self)
157         zid = self[1].zone_id
158     if (zid == nil) then zid = "<nil>" end
159     class = self[1].application_class
160     if (class == nil) then class = "<nil>" end
161     role = self[1].role
162     if (role == nil) then role = "<nil>" end
163 --      print("*** import "..self.table.." update: zone:"..zid.." class:"..class.." role:"..role)
164     end
165 }
166
167 mdb.import {
168     table = "amb_gear_position",
169     columns = { "value" },
170     condition = "key = 'GearPosition'",
171     maxrow = 1,
172     update = builtin.method.make_volumes
173 }
174
175 mdb.import {
176     table = "volume_context",
177     columns = {"value"},
178     condition = "id = 1",
179     maxrow = 1,
180     update = builtin.method.change_volume_context
181 }
182
183 volume_limit {
184     name = "speed_adjust",
185     type = volume_limit.generic,
186     limit = mdb.import.speedvol:link(1,"value"),
187     calculate = builtin.method.volume_correct
188 }
189
190 volume_limit {
191     name = "phone_suppress",
192     type = volume_limit.class,
193     limit = -20,
194     node_type = { node.phone },
195     calculate = builtin.method.volume_supress
196 }
197
198
199 volume_limit {
200     name = "navi_suppress",
201     type = volume_limit.class,
202     limit = -20,
203     node_type = { node.navigator, node.phone },
204     calculate = builtin.method.volume_supress
205 }
206
207 volume_limit {
208     name = "navi_maxlim",
209     type = volume_limit.maximum,
210     limit = -10,
211     node_type = { node.navigator }
212 }
213
214 volume_limit {
215     name = "player_maxlim",
216     type = volume_limit.maximum,
217     limit = -20,
218     node_type = { node.player }
219 }
220
221 volume_limit {
222     name = "video",
223     type = volume_limit.class,
224     limit = -90,
225     node_type = { node.player, node.game },
226     calculate = function(self, class, device, mask)
227 --      print("*** limit "..self.name.." class:"..class.." stream:"..device.name)
228         position = mdb.import.amb_gear_position[1].value
229         if (position and position == 128) then
230             return self.limit
231         end
232         return 0
233     end
234 }
235
236