Skip to content

Commit

Permalink
Fix up overlay buffer handling
Browse files Browse the repository at this point in the history
  • Loading branch information
waveform80 committed Jun 1, 2016
1 parent 88e3e2f commit 9f523b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 10 additions & 6 deletions picamera/mmalobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,12 +808,16 @@ def wrapper(port, buf):
prefix="Unable to enable port %s" % self.name)
assert self._pool is None
self._pool = MMALPortPool(self)
try:
self._pool.send_all_buffers(self)
except:
self._pool.close()
self._pool = None
raise
# If this port is an output port, send it all the buffers
# in the pool. If it's an input port, don't bother: the user
# will presumably want to feed buffers to it manually
if self._port[0].type == mmal.MMAL_PORT_TYPE_OUTPUT:
try:
self._pool.send_all_buffers(self)
except:
self._pool.close()
self._pool = None
raise
else:
super(MMALPort, self).enable()

Expand Down
4 changes: 1 addition & 3 deletions picamera/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,8 @@ def __init__(
self.renderer.inputs[0].copy_from(parent._camera.outputs[parent.CAMERA_PREVIEW_PORT])
self.renderer.inputs[0].format = mmal.MMAL_ENCODING_RGB24
if size is not None:
w, h = size
self.renderer.inputs[0].framesize = (w, h)
self.renderer.inputs[0].framesize = size
self.renderer.inputs[0].commit()
self.renderer.enabled = True
# The following callback is required to prevent the mmalobj layer
# automatically passing buffers back to the port
self.renderer.inputs[0].enable(callback=lambda port, buf: True)
Expand Down

0 comments on commit 9f523b5

Please sign in to comment.