Cleaned up camera locks
This commit is contained in:
parent
8e35ef2b29
commit
90a3a738af
1 changed files with 59 additions and 58 deletions
|
|
@ -240,9 +240,11 @@ class StreamingCamera(BaseCamera):
|
|||
def start_preview(self, fullscreen=True, window=None) -> bool:
|
||||
"""Start the on board GPU camera preview."""
|
||||
logging.info("Starting the GPU preview")
|
||||
self.start_stream_recording()
|
||||
|
||||
# TODO: Commented out as I honestly can't remember why this was here. May need to put back?
|
||||
#self.start_stream_recording()
|
||||
|
||||
try:
|
||||
with self.lock:
|
||||
if not self.camera.preview:
|
||||
logging.debug("Starting preview")
|
||||
self.camera.start_preview(fullscreen=fullscreen, window=window)
|
||||
|
|
@ -257,14 +259,11 @@ class StreamingCamera(BaseCamera):
|
|||
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))
|
||||
return True
|
||||
|
||||
def stop_preview(self) -> bool:
|
||||
"""Stop the on board GPU camera preview."""
|
||||
with self.lock:
|
||||
self.camera.stop_preview()
|
||||
self.state['preview_active'] = False
|
||||
return True
|
||||
|
||||
def start_recording(
|
||||
self,
|
||||
|
|
@ -340,6 +339,7 @@ class StreamingCamera(BaseCamera):
|
|||
splitter_port (int): Splitter port to stop recording on
|
||||
resolution ((int, int)): Resolution to set the camera to, after stopping recording.
|
||||
"""
|
||||
with self.lock:
|
||||
# If no resolution is specified, default to image_resolution
|
||||
if not resolution:
|
||||
resolution = self.config['image_resolution']
|
||||
|
|
@ -367,6 +367,7 @@ class StreamingCamera(BaseCamera):
|
|||
splitter_port (int): Splitter port to start recording on
|
||||
resolution ((int, int)): Resolution to set the camera to, before starting recording. Defaults to `self.config['stream_resolution']`.
|
||||
"""
|
||||
with self.lock:
|
||||
# If stream object was destroyed
|
||||
if not hasattr(self, 'stream'):
|
||||
self.stream = io.BytesIO() # Create a stream object
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue