Skip to content

Commit 0759c90

Browse files
committed
Merge pull request #5 from ninovanhooff/issue4
Replace continuous capture by state-based trigger
2 parents 2d52eac + ac18b12 commit 0759c90

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

resources/lib/state.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __init__(self, settings):
8282

8383
# create the capture object
8484
self.__capture = xbmc.RenderCapture()
85-
self.__capture.capture(64, 64, xbmc.CAPTURE_FLAG_CONTINUOUS)
85+
self.__capture.capture(64, 64)
8686

8787
def __del__(self):
8888
'''Destructor
@@ -101,7 +101,8 @@ def execute(self):
101101

102102
# capture an image
103103
self.__capture.waitForCaptureStateChangeEvent(200)
104-
if self.__capture.getCaptureState() == xbmc.CAPTURE_STATE_DONE:
104+
captureState = self.__capture.getCaptureState()
105+
if captureState == xbmc.CAPTURE_STATE_DONE:
105106
# retrieve image data and reformat into rgb format
106107
data = self.__capture.getImage()
107108
if self.__capture.getImageFormat() == 'ARGB':
@@ -117,7 +118,12 @@ def execute(self):
117118
# unable to send image. notify and go to the error state
118119
notify(xbmcaddon.Addon().getLocalizedString(32101))
119120
return ErrorState(self.__settings)
121+
122+
if captureState != xbmc.CAPTURE_STATE_WORKING:
123+
#the current capture is processed or it has failed, we request a new one
124+
self.__capture.capture(64, 64)
120125

126+
#limit the maximum number of frames sent to hyperion
121127
xbmc.sleep(100)
122128

123129
return self

0 commit comments

Comments
 (0)