Added lock acquisition to preview functions
This commit is contained in:
parent
4bf866b66b
commit
fccc58fd62
1 changed files with 24 additions and 21 deletions
|
|
@ -327,32 +327,35 @@ 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")
|
||||||
|
|
||||||
try:
|
with self.lock():
|
||||||
if not self.camera.preview:
|
try:
|
||||||
logging.debug("Starting preview")
|
if not self.camera.preview:
|
||||||
self.camera.start_preview(fullscreen=fullscreen, window=window)
|
logging.debug("Starting preview")
|
||||||
else:
|
self.camera.start_preview(fullscreen=fullscreen, window=window)
|
||||||
logging.debug("Resizing preview")
|
else:
|
||||||
if window:
|
logging.debug("Resizing preview")
|
||||||
self.camera.preview.window = window
|
if window:
|
||||||
if fullscreen:
|
self.camera.preview.window = window
|
||||||
self.camera.preview.fullscreen = fullscreen
|
if fullscreen:
|
||||||
self.preview_active = True
|
self.camera.preview.fullscreen = fullscreen
|
||||||
except picamera.exc.PiCameraMMALError as e:
|
self.preview_active = True
|
||||||
logging.error(
|
except picamera.exc.PiCameraMMALError as e:
|
||||||
"Suppressed a MMALError in start_preview. Exception: {}".format(e)
|
logging.error(
|
||||||
)
|
"Suppressed a MMALError in start_preview. Exception: {}".format(e)
|
||||||
except picamera.exc.PiCameraValueError as e:
|
|
||||||
logging.error(
|
|
||||||
"Suppressed a ValueError exception in start_preview. Exception: {}".format(
|
|
||||||
e
|
|
||||||
)
|
)
|
||||||
|
except picamera.exc.PiCameraValueError as e:
|
||||||
|
logging.error(
|
||||||
|
"Suppressed a ValueError exception in start_preview. Exception: {}".format(
|
||||||
|
e
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def stop_preview(self):
|
def stop_preview(self):
|
||||||
"""Stop the on board GPU camera preview."""
|
"""Stop the on board GPU camera preview."""
|
||||||
self.camera.stop_preview()
|
with self.lock():
|
||||||
self.preview_active = False
|
if self.camera.preview:
|
||||||
|
self.camera.stop_preview()
|
||||||
|
self.preview_active = False
|
||||||
|
|
||||||
def start_recording(self, output, fmt: str = "h264", quality: int = 15):
|
def start_recording(self, output, fmt: str = "h264", quality: int = 15):
|
||||||
"""Start recording.
|
"""Start recording.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue