Message ID | 20190713172351.25452-3-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Laurent, Thanks for your patch. On 2019-07-13 20:23:37 +0300, Laurent Pinchart wrote: > There's no need to check if buffers have been allocated before freeing > them as the BufferPool::destroyBuffers() method is a no-op when no > buffers have been allocated. Document this fact explicitly, and remove > the buffer count check. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > --- > src/libcamera/buffer.cpp | 3 +++ > src/libcamera/camera.cpp | 3 --- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp > index d86278a8a90a..c0a020942f5c 100644 > --- a/src/libcamera/buffer.cpp > +++ b/src/libcamera/buffer.cpp > @@ -311,6 +311,9 @@ void BufferPool::createBuffers(unsigned int count) > > /** > * \brief Release all buffers from pool > + * > + * If no buffers have been created or if buffers have already been released no > + * operation is performed. > */ > void BufferPool::destroyBuffers() > { > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp > index 094f1b63b7f1..810cb1295f34 100644 > --- a/src/libcamera/camera.cpp > +++ b/src/libcamera/camera.cpp > @@ -740,9 +740,6 @@ int Camera::freeBuffers() > return -EACCES; > > for (Stream *stream : activeStreams_) { > - if (!stream->bufferPool().count()) > - continue; > - > /* > * All mappings must be destroyed before buffers can be freed > * by the V4L2 device that has allocated them. > -- > Regards, > > Laurent Pinchart > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp index d86278a8a90a..c0a020942f5c 100644 --- a/src/libcamera/buffer.cpp +++ b/src/libcamera/buffer.cpp @@ -311,6 +311,9 @@ void BufferPool::createBuffers(unsigned int count) /** * \brief Release all buffers from pool + * + * If no buffers have been created or if buffers have already been released no + * operation is performed. */ void BufferPool::destroyBuffers() { diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 094f1b63b7f1..810cb1295f34 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -740,9 +740,6 @@ int Camera::freeBuffers() return -EACCES; for (Stream *stream : activeStreams_) { - if (!stream->bufferPool().count()) - continue; - /* * All mappings must be destroyed before buffers can be freed * by the V4L2 device that has allocated them.
There's no need to check if buffers have been allocated before freeing them as the BufferPool::destroyBuffers() method is a no-op when no buffers have been allocated. Document this fact explicitly, and remove the buffer count check. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- src/libcamera/buffer.cpp | 3 +++ src/libcamera/camera.cpp | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-)