comparison src/cagou/core/cagou_main.py @ 75:b84dadbab62b

core: added a platform check in on_start: on_start is also called on non-android platform, so a check has been added to ignore android-specific code
author Goffi <goffi@goffi.org>
date Tue, 20 Dec 2016 21:10:53 +0100
parents 674b1fa3c945
children bc170ccca744
comparison
equal deleted inserted replaced
74:88e3071079a7 75:b84dadbab62b
226 @param **kwargs: additional keyword arguments used in format 226 @param **kwargs: additional keyword arguments used in format
227 """ 227 """
228 return os.path.expanduser(path).format(*args, media=self.host.media_dir, **kwargs) 228 return os.path.expanduser(path).format(*args, media=self.host.media_dir, **kwargs)
229 229
230 def on_start(self): 230 def on_start(self):
231 # XXX: we use memory map instead of bridge because if we try to call a bridge method 231 if sys.platform == "android":
232 # in on_pause method, the call data is not written before the actual pause 232 # XXX: we use memory map instead of bridge because if we try to call a bridge method
233 # we create a memory map on .cagou_status file with a 1 byte status 233 # in on_pause method, the call data is not written before the actual pause
234 # status is: 234 # we create a memory map on .cagou_status file with a 1 byte status
235 # R => running 235 # status is:
236 # P => paused 236 # R => running
237 # S => stopped 237 # P => paused
238 self._first_pause = True 238 # S => stopped
239 self.cagou_status_fd = open('.cagou_status', 'wb+') 239 self._first_pause = True
240 self.cagou_status_fd.write('R') 240 self.cagou_status_fd = open('.cagou_status', 'wb+')
241 self.cagou_status_fd.flush() 241 self.cagou_status_fd.write('R')
242 self.cagou_status = mmap.mmap(self.cagou_status_fd.fileno(), 1, prot=mmap.PROT_WRITE) 242 self.cagou_status_fd.flush()
243 self.cagou_status = mmap.mmap(self.cagou_status_fd.fileno(), 1, prot=mmap.PROT_WRITE)
243 244
244 def on_pause(self): 245 def on_pause(self):
245 self.cagou_status[0] = 'P' 246 self.cagou_status[0] = 'P'
246 return True 247 return True
247 248