Added lock acquisition to preview functions

This commit is contained in:
Joel Collins 2020-07-15 17:18:23 +01:00
parent 4bf866b66b
commit fccc58fd62

View file

@ -327,6 +327,7 @@ class PiCameraStreamer(BaseCamera):
"""Start the on board GPU camera preview.""" """Start the on board GPU camera preview."""
logging.info("Starting the GPU preview") logging.info("Starting the GPU preview")
with self.lock():
try: try:
if not self.camera.preview: if not self.camera.preview:
logging.debug("Starting preview") logging.debug("Starting preview")
@ -351,6 +352,8 @@ class PiCameraStreamer(BaseCamera):
def stop_preview(self): def stop_preview(self):
"""Stop the on board GPU camera preview.""" """Stop the on board GPU camera preview."""
with self.lock():
if self.camera.preview:
self.camera.stop_preview() self.camera.stop_preview()
self.preview_active = False self.preview_active = False