Ejemplo n.º 1
0
 def stop(self):
     """
     Stops the encoder, regardless of whether it's finished
     """
     # The check on is_enabled below is not a race condition; we ignore the
     # EINVAL error in the case the port turns out to be disabled when we
     # disable below. The check exists purely to prevent stderr getting
     # spammed by our continued attempts to disable an already disabled port
     if self.encoder and self.output_port[0].is_enabled:
         if self.started_capture:
             self.started_capture = False
             mmal_check(
                 mmal.mmal_port_parameter_set_boolean(
                     self.camera_port,
                     mmal.MMAL_PARAMETER_CAPTURE,
                     mmal.MMAL_FALSE),
                 prefix="Failed to stop capture")
         try:
             mmal_check(
                 mmal.mmal_port_disable(self.output_port),
                 prefix="Failed to disable encoder output port")
         except PiCameraMMALError as e:
             if e.status != mmal.MMAL_EINVAL:
                 raise
     self.stopped = True
     self.event.set()
     self._close_output()
Ejemplo n.º 2
0
 def stop(self):
     """
     Stops the encoder, regardless of whether it's finished
     """
     # The check on is_enabled below is not a race condition; we ignore the
     # EINVAL error in the case the port turns out to be disabled when we
     # disable below. The check exists purely to prevent stderr getting
     # spammed by our continued attempts to disable an already disabled port
     if self.encoder and self.output_port[0].is_enabled:
         if self.started_capture:
             self.started_capture = False
             mmal_check(
                 mmal.mmal_port_parameter_set_boolean(
                     self.camera_port, mmal.MMAL_PARAMETER_CAPTURE, mmal.MMAL_FALSE
                 ),
                 prefix="Failed to stop capture",
             )
         try:
             mmal_check(mmal.mmal_port_disable(self.output_port), prefix="Failed to disable encoder output port")
         except PiCameraMMALError as e:
             if e.status != mmal.MMAL_EINVAL:
                 raise
     self.stopped = True
     self.event.set()
     self._close_output()
Ejemplo n.º 3
0
 def wait(self, timeout=None):
     """
     Waits for the encoder to finish (successfully or otherwise)
     """
     result = self.event.wait(timeout)
     if result:
         if self.started_capture:
             self.started_capture = False
             mmal_check(
                 mmal.mmal_port_parameter_set_boolean(
                     self.camera_port,
                     mmal.MMAL_PARAMETER_CAPTURE,
                     mmal.MMAL_FALSE),
                 prefix="Failed to stop capture")
         try:
             mmal_check(
                 mmal.mmal_port_disable(self.output_port),
                 prefix="Failed to disable encoder output port")
         except PiCameraMMALError as e:
             if e.status != mmal.MMAL_EINVAL:
                 raise
         self._close_output()
         # Check whether the callback set an exception
         if self.exception:
             raise self.exception
     return result
Ejemplo n.º 4
0
 def stop(self):
     """
     Stops the encoder, regardless of whether it's finished
     """
     if self.encoder and self.output_port[0].is_enabled:
         mmal_check(mmal.mmal_port_disable(self.output_port),
                    prefix="Failed to disable encoder output port")
     self.stopped = True
     self.event.set()
     self._close_output()
Ejemplo n.º 5
0
 def stop(self):
     """
     Stops the encoder, regardless of whether it's finished
     """
     if self.encoder and self.output_port[0].is_enabled:
         mmal_check(
             mmal.mmal_port_disable(self.output_port),
             prefix="Failed to disable encoder output port")
     self.stopped = True
     self.event.set()
     self._close_output()
Ejemplo n.º 6
0
 def wait(self, timeout=None):
     """
     Waits for the encoder to finish (successfully or otherwise)
     """
     result = self.event.wait(timeout)
     if result:
         mmal_check(mmal.mmal_port_disable(self.output_port),
                    prefix="Failed to disable encoder output port")
         self._close_output()
         # Check whether the callback set an exception
         if self.exception:
             raise self.exception
     return result
Ejemplo n.º 7
0
 def wait(self, timeout=None):
     """
     Waits for the encoder to finish (successfully or otherwise)
     """
     result = self.event.wait(timeout)
     if result:
         mmal_check(
             mmal.mmal_port_disable(self.output_port),
             prefix="Failed to disable encoder output port")
         self._close_output()
         # Check whether the callback set an exception
         if self.exception:
             raise self.exception
     return result