The device should be released after each streaming session

This commit is contained in:
Fabio Manganiello 2020-09-25 17:34:53 +02:00
parent c12e7bab90
commit 28409b8688

View file

@ -132,7 +132,7 @@ class CameraPiPlugin(CameraPlugin):
return self.status() return self.status()
def streaming_thread(self, camera: Camera, stream_format: str, duration: Optional[float] = None): def streaming_thread(self, camera: PiCamera, stream_format: str, duration: Optional[float] = None):
server_socket = self._prepare_server_socket(camera) server_socket = self._prepare_server_socket(camera)
sock = None sock = None
streaming_started_time = time.time() streaming_started_time = time.time()
@ -159,18 +159,10 @@ class CameraPiPlugin(CameraPlugin):
sock.close() sock.close()
except Exception as e: except Exception as e:
self.logger.warning('Error while closing client socket: {}'.format(str(e))) self.logger.warning('Error while closing client socket: {}'.format(str(e)))
self.release_device(camera)
finally: finally:
self._cleanup_stream(camera, server_socket, sock) self._cleanup_stream(camera, server_socket, sock)
try:
camera.object.stop_recording()
except Exception as e:
self.logger.warning('Error while stopping camera recording: {}'.format(str(e)))
try:
camera.object.close()
except Exception as e:
self.logger.warning('Error while closing camera: {}'.format(str(e)))
self.logger.info('Stopped camera stream') self.logger.info('Stopped camera stream')
@action @action