# Path: src/alexapi/device_platforms/baseplatform.py
# class BasePlatform:
# 	__metaclass__ = ABCMeta
# 
# 	_trigger_callback = None
# 
# 	def __init__(self, config, platform_name):
# 		self._config = config
# 
# 		self._pconfig = {}
# 		if config['platforms']['common']:
# 			self._pconfig = config['platforms']['common']
# 
# 		if config['platforms'][platform_name]:
# 			self._pconfig.update(config['platforms'][platform_name])
# 
# 	@abstractmethod
# 	def setup(self):
# 		pass
# 
# 	@abstractmethod
# 	def after_setup(self, trigger_callback=None):
# 		pass
# 
# 	@abstractmethod
# 	def indicate_failure(self):
# 		pass
# 
# 	@abstractmethod
# 	def indicate_success(self):
# 		pass
# 
# 	@abstractmethod
# 	def indicate_recording(self, state=True):
# 		pass
# 
# 	@abstractmethod
# 	def indicate_playback(self, state=True):
# 		pass
# 
# 	@abstractmethod
# 	def indicate_processing(self, state=True):
# 		pass
# 
# 	@abstractmethod
# 	def force_recording(self):
# 		pass
# 
# 	@abstractmethod
# 	def cleanup(self):
# 		pass


import time
import threading
import logging
import sys
from .baseplatform import BasePlatform
		logger.info("indicate_recording_on %s", state)

	def indicate_playback(self, state=True):
		logger.info("indicate_playback %s", state)

	def indicate_processing(self, state=True):
		logger.info("indicate_processing %s", state)

	def after_setup(self, trigger_callback=None):

		self._trigger_callback = trigger_callback

		if self._trigger_callback:
			self.trigger_thread = DesktopPlatformTriggerThread(self, trigger_callback)
			self.trigger_thread.setDaemon(True)
			self.trigger_thread.start()

	def force_recording(self):
		return time.time() - self.started < self._pconfig['min_seconds_to_record']

	def cleanup(self):
		self.trigger_thread.stop()


class DesktopPlatformTriggerThread(threading.Thread):
	def __init__(self, platform, trigger_callback):
		threading.Thread.__init__(self)

		self.platform = platform
		self._trigger_callback = trigger_callback

# Path: src/alexapi/device_platforms/baseplatform.py
# class BasePlatform:
# 	__metaclass__ = ABCMeta
# 
# 	_trigger_callback = None
# 
# 	def __init__(self, config, platform_name):
# 		self._config = config
# 
# 		self._pconfig = {}
# 		if config['platforms']['common']:
# 			self._pconfig = config['platforms']['common']
# 
# 		if config['platforms'][platform_name]:
# 			self._pconfig.update(config['platforms'][platform_name])
# 
# 	@abstractmethod
# 	def setup(self):
# 		pass
# 
# 	@abstractmethod
# 	def after_setup(self, trigger_callback=None):
# 		pass
# 
# 	@abstractmethod
# 	def indicate_failure(self):
# 		pass
# 
# 	@abstractmethod
# 	def indicate_success(self):
# 		pass
# 
# 	@abstractmethod
# 	def indicate_recording(self, state=True):
# 		pass
# 
# 	@abstractmethod
# 	def indicate_playback(self, state=True):
# 		pass
# 
# 	@abstractmethod
# 	def indicate_processing(self, state=True):
# 		pass
# 
# 	@abstractmethod
# 	def force_recording(self):
# 		pass
# 
# 	@abstractmethod
# 	def cleanup(self):
# 		pass


# Path: src/alexapi/device_platforms/desktopplatform.py
import time
import threading
import logging
import sys
from .baseplatform import BasePlatform

		logger.info("indicate_recording_on %s", state)

	def indicate_playback(self, state=True):
		logger.info("indicate_playback %s", state)

	def indicate_processing(self, state=True):
		logger.info("indicate_processing %s", state)

	def after_setup(self, trigger_callback=None):

		self._trigger_callback = trigger_callback

		if self._trigger_callback:
			self.trigger_thread = DesktopPlatformTriggerThread(self, trigger_callback)
			self.trigger_thread.setDaemon(True)
			self.trigger_thread.start()

	def force_recording(self):
		return time.time() - self.started < self._pconfig['min_seconds_to_record']

	def cleanup(self):
		self.trigger_thread.stop()


class DesktopPlatformTriggerThread(threading.Thread):
	def __init__(self, platform, trigger_callback):
		threading.Thread.__init__(self)

		self.platform = platform
		self._trigger_callback = trigger_callback

		self.should_run = True