1 with_system_controller = true
7 -- try loading the various logging plugins
8 m:try_load_plugin('systemd')
9 m:try_load_plugin('dlog')
11 -- load the console plugin
12 m:try_load_plugin('console')
14 m:try_load_plugin('console.disabled', 'webconsole', {
15 address = 'wsck:127.0.0.1:3000/murphy',
16 httpdir = '/usr/share/murphy/webconsole' });
18 -- load the dbus plugin
19 if m:plugin_exists('dbus') then
23 -- load the native resource plugin
24 if m:plugin_exists('resource-native') then
25 m:load_plugin('resource-native')
26 m:info("native resource plugin loaded")
28 m:info("No native resource plugin found...")
31 -- load the dbus resource plugin
32 m:try_load_plugin('resource-dbus', {
34 dbus_service = "org.Murphy",
36 default_zone = "driver",
37 default_class = "implicit"
40 -- load the domain control plugin
41 if m:plugin_exists('domain-control') then
42 m:load_plugin('domain-control')
44 m:info("No domain-control plugin found...")
47 -- load the AMB plugin
48 if m:plugin_exists('amb') then
49 m:try_load_plugin('amb')
51 if builtin.method.amb_initiate and
52 builtin.method.amb_update
57 m:info("No amb plugin found...")
60 -- load the ASM resource plugin
61 if m:plugin_exists('resource-asm') then
62 m:try_load_plugin('resource-asm', {
64 share_mmplayer = "player:AVP,mandatory,exclusive,strict",
65 ignored_argv0 = "WebProcess"
68 m:info("No audio session manager plugin found...")
71 if m:plugin_exists('ivi-resource-manager') then
72 m:load_plugin('ivi-resource-manager')
73 with_system_controller = false
76 -- define application classes
123 application_class { name="event" , priority=4 , modal=false, share=true , order="fifo" }
124 application_class { name="game" , priority=3 , modal=false, share=false, order="lifo" }
125 --# doesn't need to be created here, ivi-resource-manager creates it if loaded
126 --#application_class { name="basic" , priority=2 , modal=false, share=false, order="lifo" }
127 application_class { name="player" , priority=1 , modal=false, share=true , order="lifo" }
128 application_class { name="implicit" , priority=0 , modal=false, share=false, order="lifo" }
130 -- define zone attributes
132 type = {mdb.string, "common", "rw"},
133 location = {mdb.string, "anywhere", "rw"}
141 location = "front-left"
149 location = "front-right"
157 location = "back-left"
165 location = "back-right"
173 location = "back-left"
178 -- define resource classes
179 if not m:plugin_exists('ivi-resource-manager') then
181 name = "audio_playback",
184 role = { mdb.string, "music", "rw" },
185 pid = { mdb.string, "<unknown>", "rw" },
186 policy = { mdb.string, "relaxed", "rw" }
192 name = "audio_recording",
195 role = { mdb.string, "music" , "rw" },
196 pid = { mdb.string, "<unknown>", "rw" },
197 policy = { mdb.string, "relaxed" , "rw" }
202 name = "video_playback",
207 name = "video_recording",
211 if not m:plugin_exists('ivi-resource-manager') and
212 not with_system_controller
214 resource.method.veto = {
215 function(zone, rset, grant, owners, req_set)
221 -- test for creating selections
223 name = "audio_owner",
224 table = "audio_playback_owner",
225 columns = {"application_class"},
226 condition = "zone_name = 'driver'"
230 name = "vehicle_speed",
231 table = "amb_vehicle_speed",
233 condition = "key = 'VehicleSpeed'"
237 name = "speed2volume",
238 inputs = { speed = mdb.select.vehicle_speed, param = 9 },
239 outputs = { mdb.table { name = "speedvol",
240 index = {"zone", "device"},
241 columns = {{"zone", mdb.string, 16},
242 {"device", mdb.string, 16},
243 {"value", mdb.floating}},
248 update = function(self)
249 speed = self.inputs.speed.single_value
251 volume = (speed - 144.0) / 7.0
255 diff = volume - self.oldvolume
256 if (diff*diff > self.inputs.param) then
257 print("*** element "..self.name.." update "..volume)
258 self.oldvolume = volume
259 mdb.table.speedvol:replace({zone = "driver", device = "speakers", value = volume})
264 -- Night mode processing chain
267 name = "exterior_brightness",
268 table = "amb_exterior_brightness",
269 columns = { "value" },
270 condition = "key = 'ExteriorBrightness'"
275 inputs = { brightness = mdb.select.exterior_brightness },
279 name = "amb_nightmode",
283 { "id", mdb.unsigned },
284 { "night_mode", mdb.unsigned }
288 update = function(self)
289 -- This is a trivial function to calculate night mode. Later, we will
290 -- need a better threshold value and hysteresis to prevent oscillation.
292 brightness = self.inputs.brightness.single_value
294 if not brightness then
298 print("*** element "..self.name.." update brightness: "..brightness)
300 if brightness > 300 then
306 print("*** resulting mode: ".. mode)
308 if not (mode == self.oldmode) then
309 mdb.table.amb_nightmode:replace({ id = 0, night_mode = mode })
317 name = "select_night_mode",
318 table = "amb_nightmode",
319 columns = { "night_mode" },
326 inputs = { owner = mdb.select.select_night_mode },
327 property = "NightMode",
329 initiate = builtin.method.amb_initiate,
330 update = builtin.method.amb_update
334 -- Night mode general handlers
337 name = "nightmode_homescreen",
338 inputs = { owner = mdb.select.select_night_mode },
339 initiate = function(self)
340 data = mdb.select.select_night_mode.single_value
341 print("Night mode initiated: " .. tostring(data))
344 update = function(self)
345 data = mdb.select.select_night_mode.single_value
346 print("Night mode updated: " .. tostring(data))
348 -- tell homescreen that night mode was updated
349 sc:send_message(sysctlid, m:JSON({command=0x60001,arg=m:JSON({stateid=2,state=data})}))
354 -- Driving mode processing chain
357 name = "drivingmode",
358 inputs = { speed = mdb.select.vehicle_speed },
362 name = "amb_drivingmode",
366 { "id", mdb.unsigned },
367 { "driving_mode", mdb.unsigned }
371 update = function(self)
373 speed = self.inputs.speed.single_value
385 if not (mode == self.oldmode) then
386 mdb.table.amb_drivingmode:replace({ id = 0, driving_mode = mode })
394 name = "select_driving_mode",
395 table = "amb_drivingmode",
396 columns = { "driving_mode" },
402 name = "driving_mode",
403 inputs = { owner = mdb.select.select_driving_mode },
404 property = "DrivingMode",
406 initiate = builtin.method.amb_initiate,
407 update = builtin.method.amb_update
411 -- turn signals (left, right)
415 table = "amb_turn_signal",
416 columns = { "value" },
417 condition = "key = 'TurnSignal'"
420 -- regulation (on), use "select_driving_mode"
423 name = "driving_regulation",
424 inputs = { owner = mdb.select.select_driving_mode },
425 initiate = function(self)
426 data = mdb.select.select_driving_mode.single_value
427 print("Driving mode initiated: " .. tostring(data))
430 update = function(self)
431 data = mdb.select.select_driving_mode.single_value
432 print("Driving mode updated: " .. tostring(data))
434 -- tell homescreen that driving mode was updated
435 sc:send_message(sysctlid, m:JSON({command=0x60001,arg=m:JSON({stateid=1,state=data})}))
440 -- shift position (parking, reverse, other)
443 name = "gear_position",
444 table = "amb_gear_position",
445 columns = { "value" },
446 condition = "key = 'GearPosition'"
449 -- cameras (back, front, left, right)
452 name = "camera_state",
453 inputs = { winker = mdb.select.winker, gear = mdb.select.gear_position },
457 name = "target_camera_state",
461 { "id", mdb.unsigned },
462 { "front_camera", mdb.unsigned },
463 { "back_camera", mdb.unsigned },
464 { "right_camera", mdb.unsigned },
465 { "left_camera", mdb.unsigned }
469 update = function(self)
476 if self.inputs.gear == 128 then
478 elseif self.inputs.winker == 1 then
480 elseif self.inputs.winker == 2 then
484 mdb.table.target_camera_state:replace({ id = 0, front_camera = front_camera, back_camera = back_camera, right_camera = right_camera, left_camera = left_camera })
489 -- load the telephony plugin
490 m:try_load_plugin('telephony')
493 -- system controller test setup
495 if not with_system_controller or not m:plugin_exists('system-controller') then
499 m:load_plugin('system-controller')
501 window_manager_operation_names = {
506 function window_manager_operation_name(oper)
507 local name = window_manager_operation_names[oper]
508 if name then return name end
509 return "<unknown " .. tostring(oper) .. ">"
512 window_operation_names = {
521 function window_operation_name(oper)
522 local name = window_operation_names[oper]
523 if name then return name end
524 return "<unknown " .. tostring(oper) .. ">"
527 layer_operation_names = {
533 function layer_operation_name(oper)
534 local name = layer_operation_names[oper]
535 if name then return name end
536 return "<unknown " .. tostring(oper) .. ">"
540 [0x00001] = "send_appid",
541 [0x10001] = "create",
542 [0x10002] = "destroy",
546 [0x10006] = "change_active",
547 [0x10007] = "change_layer",
548 [0x10008] = "change_attr",
550 [0x10011] = "map_thumb",
551 [0x10012] = "unmap_thumb",
552 [0x10020] = "show layer",
553 [0x10021] = "hide_layer",
554 [0x10022] = "change_layer_attr",
555 [0x20001] = "add_input",
556 [0x20002] = "del_input",
557 [0x20003] = "send_input",
558 [0x40001] = "acquire_res",
559 [0x40002] = "release_res",
560 [0x40003] = "deprive_res",
561 [0x40004] = "waiting_res",
562 [0x40005] = "revert_res",
563 [0x40011] = "create_res",
564 [0x40012] = "destroy_res",
565 [0x50001] = "set_region",
566 [0x50002] = "unset_region",
567 [0x60001] = "change_state"
570 function command_name(command)
571 local name = command_names[command]
572 if name then return name end
573 return "<unknown " .. tostring(command) .. ">"
582 resmgr = resource_manager {
583 screen_event_handler = function(self, ev)
584 local event = ev.event
585 local surface = ev.surface
587 if event == "grant" then
589 print("*** make visible surface "..surface)
591 local a = animation({})
592 local r = m:JSON({surface = surface,
595 wmgr:window_request(r,a,0)
596 elseif event == "revoke" then
598 print("*** hide surface "..surface)
600 local a = animation({})
601 local r = m:JSON({surface = ev.surface,
603 wmgr:window_request(r,a,0)
606 print("*** resource event: "..tostring(ev))
612 resclnt = resource_client {}
614 wmgr = window_manager {
615 geometry = function(self, w,h, v)
616 if type(v) == "function" then
622 application = function(self, appid)
624 local app = application_lookup(appid)
626 app = application_lookup("default")
630 return { privileges = {screen="none", audio="none"} }
633 outputs = { { name = "Center",
640 width = function(w,h) return w end,
647 width = function(w,h) return w end,
648 height = function(w,h) return h-64-128 end
654 width = function(w,h) return w end,
655 height = function(w,h) return (h-64-128)/2 end
660 pos_y = function(w,h) return (h-64-128)/2+64 end,
661 width = function(w,h) return w end,
662 height = function(w,h) return (h-64-128)/2 end
668 width = function(w,h) return w/2 end,
669 height = function(w,h) return (h-64-128)/2 end
673 pos_x = function(w,h) return w/2 end,
675 width = function(w,h) return w/2 end,
676 height = function(w,h) return (h-64-128)/2 end
681 pos_y = function(w,h) return (h-64-128/2)+64 end,
682 width = function(w,h) return w/2 end,
683 height = function(w,h) return (h-64-128)/2 end
687 pos_x = function(w,h) return w/2 end,
688 pos_y = function(w,h) return (h-64-128/2)+64 end,
689 width = function(w,h) return w/2 end,
690 height = function(w,h) return (h-64-128)/2 end
696 width = function(w,h) return w end,
697 height = function(w,h) return h-64-128 end
703 width = function(w,h) return w/2-181 end,
704 height = function(w,h) return h-64-128 end
708 pos_x = function(w,h) return w/2+181 end,
710 width = function(w,h) return w/2-181 end,
711 height = function(w,h) return h-64-128 end
721 layers = { { 0, "Background" , 1 },
722 { 1, "Application" , 2 },
723 { 2, "Softkeyboard" , 4 },
724 { 3, "HomeScreen" , 2 },
725 { 4, "ControlBar" , 2 },
726 { 5, "InterruptApp" , 2 },
727 { 6, "OnScreen" , 2 },
728 { 101, "Input" , 3 },
729 { 102, "Cursor" , 5 },
730 { 103, "Startup" , 6 },
731 { 0x1000, "Background" , 1 },
732 { 0x2000, "Normal" , 2 },
733 { 0x3000, "Fullscreen" , 2 },
734 { 0x4000, "InputPanel" , 3 },
735 { 0xA000, "Touch" , 4 },
736 { 0xB000, "Cursor" , 5 },
737 { 0xC000, "Startup" , 6 }
741 manager_update = function(self, oper)
743 print("### <== WINDOW MANAGER UPDATE:" ..
744 window_manager_operation_name(oper))
747 local umask = window_mask { raise = true,
750 local rmask = window_mask { active = true }
752 passthrough_update = umask:tointeger(),
753 passthrough_request = rmask:tointeger()
755 self:manager_request(req)
759 window_update = function(self, oper, win, mask)
761 print("### <== WINDOW UPDATE oper:" ..
762 window_operation_name(oper) ..
763 " mask: " .. tostring(mask))
769 local arg = m:JSON({ surface = win.surface,
774 if oper == 1 then -- create
775 local layertype = win.layertype
776 if layertype and input_layer[layertype] then
778 print("ignoring input panel creation")
783 elseif oper == 2 then -- destroy
785 elseif oper == 3 then -- namechange
787 elseif oper == 4 or oper == 5 then --visible or configure
791 arg.layer = win.layer
792 arg.pos_x = win.pos_x
793 arg.pos_y = win.pos_y
794 arg.width = win.width
795 arg.height = win.height
796 arg.raise = win.raise
797 arg.visible = win.visible
798 arg.active = win.active
799 elseif oper == 6 then -- active
801 arg.active = win.active
804 print("### nothing to do")
809 local msg = m:JSON({ command = command,
815 print("### <== sending " ..
816 command_name(msg.command) ..
817 " window message to '" .. win.name .. "'")
822 sc:send_message(sysctlid, msg)
824 if oper == 1 then -- create
825 local i = input_layer[win.layertype]
826 local p = self:application(win.appid)
827 local s = p.privileges.screen
829 if s == "system" then
830 local a = animation({})
831 local r = m:JSON({surface = win.surface,
834 self:window_request(r,a,0)
838 print("do not make resource for " ..
842 resclnt:resource_set_create("screen",
848 elseif oper == 2 then -- destroy
849 resclnt:resource_set_destroy("screen", win.surface)
850 elseif oper == 6 then -- active
852 local i = input_layer[win.layertype]
853 local p = self:application(win.appid)
854 local s = p.privileges.screen
855 local surface = win.surface
856 if not i and s ~= "system" then
857 resclnt:resource_set_acquire("screen",surface)
858 resmgr:window_raise(win.appid, surface, 1)
864 layer_update = function(self, oper, layer, mask)
866 print("### LAYER UPDATE:" ..
867 layer_operation_name(oper) ..
868 " mask: " .. tostring(mask))
873 if oper == 3 then -- visible
874 local command = 0x10022
878 arg = m:JSON({layer = layer.id,
879 visible = layer.visible
883 print("### <== sending "..command_name(command)..
889 sc:send_message(sysctlid, msg)
892 print("### nothing to do")
897 output_update = function(self, oper, out, mask)
898 local idx = out.index
900 print("### OUTPUT UPDATE:" .. oper ..
901 " mask: "..tostring(mask))
904 local outdef = self.outputs[idx+1]
905 if (oper == 1) then -- create
907 self:output_request(m:JSON({index = idx,
912 elseif (oper == 5) then -- done
913 local ads = outdef.areas
914 local on = outdef.name
916 for name,ad in pairs(ads) do
917 local can = wmgr:canonical_name(on.."."..name)
918 local a = m:JSON({name = name,
920 for fld,val in pairs(ad) do
921 a[fld] = self:geometry(out.width,
926 resmgr:area_create(area[can], outdef.zone)
934 sc = m:get_system_controller()
945 -- these shoud be before wmgr:connect() is called
947 print("====== creating applications ======")
951 area = "Center.Full",
952 privileges = { screen = "none", audio = "none" },
953 resource_class = "player",
959 area = "Center.Full",
960 privileges = { screen = "system", audio = "none" },
961 resource_class = "implicit",
966 appid = "org.tizen.ico.homescreen",
967 area = "Center.Full",
968 privileges = { screen = "system", audio = "system" },
969 resource_class = "player",
974 appid = "org.tizen.ico.statusbar",
975 area = "Center.Status",
976 privileges = { screen = "system", audio = "none" },
977 resource_class = "player",
982 appid = "org.tizen.ico.login",
983 area = "Center.Full",
984 privileges = { screen = "system", audio = "system" },
985 resource_class = "player",
991 sc.client_handler = function (self, cid, msg)
992 local command = msg.command
994 print('### ==> client handler:')
999 if not connected then
1000 print('Setting sysctlid='..msg.appid)
1001 sysctlid = msg.appid
1002 print('Trying to connect to wayland...')
1003 connected = wmgr:connect()
1005 if connected and command then
1006 if command == 1 then -- send_appid
1007 local driving_mode = mdb.select.select_driving_mode.single_value
1008 local night_mode = mdb.select.select_night_mode.single_value
1010 if not driving_mode then driving_mode = 0 end
1011 if not night_mode then night_mode = 0 end
1013 local reply = m:JSON({ command = 0x60001,
1014 arg = m:JSON({ stateid = 1,
1015 state = driving_mode})
1018 print("### <== sending " ..
1019 command_name(command) .. " message")
1024 sc:send_message(sysctlid, reply)
1026 reply = m:JSON({ command = 0x60001,
1027 arg = m:JSON({ stateid = 2,
1028 state = night_mode})
1031 print("### <== sending " ..
1032 command_name(command) .. " message")
1037 sc:send_message(sysctlid, reply)
1042 sc.generic_handler = function (self, cid, msg)
1044 print('### ==> generic handler:')
1051 sc.window_handler = function (self, cid, msg)
1053 print('### ==> received ' ..
1054 command_name(msg.command) .. ' message')
1056 print(tostring(msg))
1060 local a = animation({})
1062 if msg.command == 0x10003 then -- ico SHOW command
1063 local raise_mask = 0x01000000
1064 local lower_mask = 0x02000000
1065 local nores_mask = 0x40000000
1066 local time_mask = 0x00ffffff
1070 if msg.arg.anim_time then
1071 local t = msg.arg.anim_time
1072 time = m:AND(t, time_mask)
1073 nores = m:AND(t, nores_mask)
1074 if m:AND(t, raise_mask) then
1076 elseif m:AND(t, lower_mask) then
1080 if msg.arg.anim_name then
1081 a.show = { msg.arg.anim_name, time }
1082 print('time: ' .. tostring(a.show[2]))
1086 local p = wmgr:application(msg.appid)
1087 local s = p.privileges.screen
1088 if s == "system" then
1093 print('### ==> SHOW')
1094 print(tostring(msg.arg))
1097 wmgr:window_request(msg.arg, a, 0)
1099 local surface = msg.arg.surface
1100 resclnt:resource_set_acquire("screen", surface)
1101 resmgr:window_raise(msg.appid, surface, 1)
1103 elseif msg.command == 0x10004 then -- ico HIDE command
1104 local raise_mask = 0x01000000
1105 local lower_mask = 0x02000000
1106 local nores_mask = 0x40000000
1107 local time_mask = 0x00ffffff
1111 if msg.arg.anim_time then
1112 local t = msg.arg.anim_time
1113 time = m:AND(t, time_mask)
1114 nores = m:AND(t, nores_mask)
1116 if msg.arg.anim_name then
1117 a.hide = { msg.arg.anim_name, time }
1118 print('hide animation time: ' .. tostring(a.hide[2]))
1122 local p = wmgr:application(msg.appid)
1123 local s = p.privileges.screen
1124 if s == "system" then
1129 print('### ==> HIDE REQUEST')
1130 print(tostring(msg.arg))
1133 wmgr:window_request(msg.arg, a, 0)
1135 resmgr:window_raise(msg.appid, msg.arg.surface, -1)
1137 elseif msg.command == 0x10005 then -- ico MOVE
1139 print('### ==> MOVE REQUEST')
1140 print(tostring(msg.arg))
1142 wmgr:window_request(msg.arg, a, 0)
1143 -- TODO: handle if area changed
1144 elseif msg.command == 0x10006 then -- ico ACTIVE
1145 if not msg.arg.active then
1146 msg.arg.active = 3 -- pointer + keyboard
1149 print('### ==> ACTIVE REQUEST')
1150 print(tostring(msg.arg))
1152 wmgr:window_request(msg.arg, a, 0)
1153 elseif msg.command == 0x10007 then -- ico CHANGE_LAYER
1155 print('### ==> CHANGE_LAYER REQUEST')
1156 print(tostring(msg.arg))
1159 if msg.arg.layer ~= 4 or msg.arg.layer ~= 5 then
1160 print("do not change layer for other than cursor or touch")
1164 wmgr:window_request(msg.arg, a, 0)
1165 elseif msg.command == 0x10011 then -- ico MAP_THUMB
1166 local framerate = msg.arg.framerate
1167 if not framerate or framerate < 0 then
1172 print('### ==> MAP_THUMB REQUEST')
1174 print('framerate: '..framerate)
1176 wmgr:window_request(msg.arg, a, framerate)
1177 elseif msg.command == 0x10012 then -- ico UNMAP_THUMB
1180 print('### ==> UNMAP_THUMB REQUEST')
1183 wmgr:window_request(msg.arg, a, 0)
1184 elseif msg.command == 0x10020 then -- ico SHOW_LAYER command
1187 print('### ==> SHOW_LAYER REQUEST')
1190 wmgr:layer_request(msg.arg)
1191 elseif msg.command == 0x10021 then -- ico HIDE_LAYER command
1194 print('### ==> HIDE_LAYER REQUEST')
1197 wmgr:layer_request(msg.arg)
1201 sc.input_handler = function (self, cid, msg)
1203 print('### ==> input handler: ' .. command_name(msg.comand))
1210 sc.user_handler = function (self, cid, msg)
1212 print('### ==> user handler: ' .. command_name(msg.command))
1219 print("User Manager not initialized")
1223 if msg.command == 0x00030001 then -- MSG_CMD_CHANGE_USER
1224 print("command CHANGE_USER")
1226 print("invalid message")
1230 username = msg.arg.user
1231 passwd = msg.arg.pass
1233 if not username then
1241 success = um:changeUser(username, passwd)
1248 if sc:send_message(msg.appid, reply) then
1249 print('*** sent authentication failed message')
1251 print('*** failed to send authentication failed message')
1255 elseif msg.command == 0x00030002 then -- MSG_CMD_GET_USERLIST
1256 print("command GET_USERLIST")
1257 if not msg.appid then
1258 print("invalid message")
1262 users, currentUser = um:getUserList()
1265 print("failed to get user list")
1271 for i,v in pairs(users) do
1275 if not currentUser then
1280 print("current user: " .. currentUser)
1282 for i,v in pairs(users) do
1293 user_login = currentUser
1298 print("### <== GetUserList reply: " .. tostring(reply))
1301 if sc:send_message(msg.appid, reply) then
1302 print('*** reply OK')
1304 print('*** reply FAILED')
1307 elseif msg.command == 0x00030003 then -- MSG_CMD_GET_LASTINFO
1308 print("command GET_LASTINFO")
1309 if not msg.appid then
1310 print("invalid message")
1314 lastInfo = um:getLastInfo(msg.appid)
1316 if not lastInfo then
1317 print("failed to get last info for app" .. msg.appid)
1329 if sc:send_message(msg.appid, reply) then
1330 print('*** reply OK')
1332 print('*** reply FAILED')
1335 elseif msg.command == 0x00030004 then -- MSG_CMD_SET_LASTINFO
1336 print("command SET_LASTINFO")
1337 if not msg.arg or not msg.appid then
1338 print("invalid message")
1342 lastInfo = um:setLastInfo(msg.appid, msg.arg.lastinfo)
1346 sc.resource_handler = function (self, cid, msg)
1348 print('### ==> resource handler: ' .. command_name(msg.command))
1354 createResourceSet = function (ctl, client, msg)
1355 cb = function(rset, data)
1356 print("> resource callback")
1358 -- type is either basic (0) or interrupt (1)
1360 if msg.res.type then
1361 requestType = msg.res.type
1364 if rset.acquired then
1365 cmd = 0x00040001 -- acquire
1367 cmd = 0x00040002 -- release
1371 appid = data.client,
1378 if rset.resources.audio_playback then
1387 if rset.resources.display then
1388 reply.res.window = {
1395 if rset.resources.input then
1401 print("sending message to client: " .. data.client)
1403 if sc:send_message(data.client, reply) then
1404 print('*** reply OK')
1406 print('*** reply FAILED')
1410 rset = m:ResourceSet({
1411 application_class = "player",
1412 zone = "driver", -- msg.zone ("full")
1421 if msg.res.sound then
1423 resource_name = "audio_playback"
1425 rset.resources.audio_playback.attributes.pid = tostring(msg.pid)
1426 rset.resources.audio_playback.attributes.appid = msg.appid
1427 print("sound name: " .. msg.res.sound.name)
1428 print("sound zone:" .. msg.res.sound.zone)
1429 print("sound adjust: " .. tostring(msg.res.sound.adjust))
1430 if msg.res.sound.id then
1431 print("sound id: " .. msg.res.sound.id)
1435 if msg.res.input then
1437 resource_name = "input"
1439 rset.resources.input.attributes.pid = tostring(msg.pid)
1440 rset.resources.input.attributes.appid = msg.appid
1441 print("input name: " .. msg.res.sound.name)
1442 print("input event:" .. tostring(msg.res.input.event))
1445 if msg.res.window then
1447 resource_name = "display"
1449 rset.resources.display.attributes.pid = tostring(msg.pid)
1450 rset.resources.display.attributes.appid = msg.appid
1451 print("display name: " .. msg.res.display.name)
1452 print("display zone:" .. msg.res.display.zone)
1453 if msg.res.display.id then
1454 print("display id: " .. msg.res.display.id)
1461 -- parse the message
1463 -- fields common to all messages:
1468 if msg.command == 0x00040011 then -- MSG_CMD_CREATE_RES
1469 print("command CREATE")
1471 if not sets.cid then
1472 sets.cid = createResourceSet(self, cid, msg)
1475 elseif msg.command == 0x00040012 then -- MSG_CMD_DESTORY_RES
1476 print("command DESTROY")
1482 sets.cid = nil -- garbage collecting
1484 elseif msg.command == 0x00040001 then -- MSG_CMD_ACQUIRE_RES
1485 print("command ACQUIRE")
1487 if not sets.cid then
1488 sets.cid = createResourceSet(self, cid, msg)
1493 elseif msg.command == 0x00040002 then -- MSG_CMD_RELEASE_RES
1494 print("command RELEASE")
1500 elseif msg.command == 0x00040003 then -- MSG_CMD_DEPRIVE_RES
1501 print("command DEPRIVE")
1503 elseif msg.command == 0x00040004 then -- MSG_CMD_WAITING_RES
1504 print("command WAITING")
1506 elseif msg.command == 0x00040005 then -- MSG_CMD_REVERT_RES
1507 print("command REVERT")
1511 sc.inputdev_handler = function (self, cid, msg)
1513 print('*** inputdev handler: ' .. command_name(msg.command))