c22923cbc4b83ebe2e1b12b1c0ceffbc311e50b0
[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     node_type = node.event,
41     priority = 6,
42     route = {
43         output = { driver = routing_group.default_driver_output }
44     },
45     roles = { event = no_resource }
46 }
47
48 application_class {
49     class = "phone",
50     node_type = node.phone,
51     priority = 5,
52     route = {
53         input  = { driver = routing_group.phone_input },
54         output = {driver = routing_group.phone_output }
55     },
56     roles = { phone = no_resource, carkit = no_resource }
57 }
58
59 application_class {
60     node_type = node.alert,
61     priority = 4,
62     route = {
63         output = { driver = routing_group.default_driver_output },
64     },
65     roles = { ringtone = no_resource, alarm = no_resource }
66 }
67
68 application_class {
69     class = "navigator",
70     node_type = node.navigator,
71     priority = 3,
72     route = {
73         output = { driver = routing_group.default_driver_output,
74                    passanger1 = routing_group.default_passanger1_output }
75     },
76     roles = { navigator = {0, "autorelease", "mandatory", "shared"} },
77     binaries = { ['net.zmap.navi'] = { 0, "autorelease", "mandatory", "shared" } }
78 }
79
80 application_class {
81     class = "game",
82     node_type = node.game,
83     priority = 2,
84     route = {
85         output = { driver = routing_group.default_driver_output,
86                    passanger1 = routing_group.default_passanger1_output }
87     },
88     roles = { game = {0, "mandatory", "exclusive"} }
89 }
90
91 application_class {
92     class = "player",
93     node_type = node.radio,
94     priority = 1,
95     route = {
96         output = { driver = routing_group.default_driver_output }
97     },
98     roles = { radio = {1, "mandatory", "exclusive"} },
99 }
100
101 application_class {
102     class = "player",
103     node_type = node.player,
104     priority = 1,
105     route = {
106         output = { driver = routing_group.default_driver_output,
107                    passanger1 = routing_group.default_passanger1_output }
108     },
109     roles = { music   = {0, "mandatory", "exclusive"},
110               video   = {0, "mandatory", "exclusive"},
111               test    = {0, "mandatory", "exclusive"}
112     },
113     binaries = { ['t8j6HTRpuz.MediaPlayer'] = {0, "mandatory", "exclusive"} }
114 }
115
116 application_class {
117     class = "player",
118     node_type = node.browser,
119     priority = 1,
120     route = {
121         output = { driver = routing_group.default_driver_output,
122                    passanger1 = routing_group.default_passanger1_output }
123     },
124     roles = { browser = {0, "mandatory", "shared"} }
125 }
126
127
128
129 audio_resource {
130     name = { recording = "audio_recording", playback = "audio_playback" },
131     attributes = {
132        role = {"media.role", mdb.string, "music"},
133        pid  = {"application.process.id", mdb.string, "<unknown>"}
134     }
135 }
136
137 mdb.import {
138     table = "speedvol",
139     columns = {"value"},
140     condition = "zone = 'driver' AND device = 'speaker'",
141     maxrow = 1,
142     update = builtin.method.make_volumes
143 }
144
145 mdb.import {
146     table = "audio_playback_owner",
147     columns = {"zone_id", "application_class", "role"},
148     condition = "zone_name = 'driver'",
149     maxrow = 1,
150     update = function(self)
151         zid = self[1].zone_id
152         if (zid == nil) then zid = "<nil>" end
153         class = self[1].application_class
154         if (class == nil) then class = "<nil>" end
155         role = self[1].role
156         if (role == nil) then role = "<nil>" end
157 --      print("*** import "..self.table.." update: zone:"..zid.." class:"..class.." role:"..role)
158     end
159 }
160
161 mdb.import {
162     table = "amb_shift_position",
163     columns = {"shift_position"},
164     condition = "id = 0",
165     maxrow = 1,
166     update = builtin.method.make_volumes
167 }
168
169 volume_limit {
170     name = "speed_adjust",
171     type = volume_limit.generic,
172     limit = mdb.import.speedvol:link(1,"value"),
173     calculate = builtin.method.volume_correct
174 }
175
176 volume_limit {
177     name = "suppress",
178     type = volume_limit.class,
179     limit = -20;
180     node_type = { node.phone, node.navigator },
181     calculate = builtin.method.volume_supress
182 }
183
184 volume_limit {
185     name = "video",
186     type = volume_limit.class,
187     limit = -90,
188     node_type = { node.player, node.game },
189     calculate = function(self, class, device)
190 --      print("*** limit "..self.name.." class:"..class.." stream:"..device.name)
191         position = mdb.import.amb_shift_position[1].shift_position
192         if (position  and position == 128) then
193             return self.limit
194         end
195         return 0
196     end
197 }
198
199