[v2,3/3] libcamera: framebuffer_allocator: Remove entry if allocation fails
diff mbox series

Message ID 20240310143023.752559-4-pobrn@protonmail.com
State Accepted
Commit 2e2ba223f3a249f1c04fe88c2709ca6e7d42c242
Headers show
Series
  • couple FrameBufferAllocator changes
Related show

Commit Message

Barnabás Pőcze March 10, 2024, 2:30 p.m. UTC
Remove the entry from the `buffers_` mapping if
`Camera::exportFrameBuffers()` fails, otherwise
there would be a stale entry in the map.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
---
 src/libcamera/framebuffer_allocator.cpp | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Kieran Bingham March 11, 2024, 2:19 p.m. UTC | #1
Quoting Barnabás Pőcze (2024-03-10 14:30:43)
> Remove the entry from the `buffers_` mapping if
> `Camera::exportFrameBuffers()` fails, otherwise
> there would be a stale entry in the map.
> 
> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
> ---
>  src/libcamera/framebuffer_allocator.cpp | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp
> index fc19a33a..dbd0db19 100644
> --- a/src/libcamera/framebuffer_allocator.cpp
> +++ b/src/libcamera/framebuffer_allocator.cpp
> @@ -97,6 +97,10 @@ int FrameBufferAllocator::allocate(Stream *stream)
>                 LOG(Allocator, Error)
>                         << "Stream is not part of " << camera_->id()
>                         << " active configuration";
> +
> +       if (ret < 0)
> +               buffers_.erase(it);
> +

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>         return ret;
>  }
>  
> -- 
> 2.44.0
> 
>
Jacopo Mondi March 11, 2024, 5:03 p.m. UTC | #2
Hi Barnabás

On Sun, Mar 10, 2024 at 02:30:43PM +0000, Barnabás Pőcze wrote:
> Remove the entry from the `buffers_` mapping if
> `Camera::exportFrameBuffers()` fails, otherwise
> there would be a stale entry in the map.
>
> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Thanks
  j

> ---
>  src/libcamera/framebuffer_allocator.cpp | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp
> index fc19a33a..dbd0db19 100644
> --- a/src/libcamera/framebuffer_allocator.cpp
> +++ b/src/libcamera/framebuffer_allocator.cpp
> @@ -97,6 +97,10 @@ int FrameBufferAllocator::allocate(Stream *stream)
>  		LOG(Allocator, Error)
>  			<< "Stream is not part of " << camera_->id()
>  			<< " active configuration";
> +
> +	if (ret < 0)
> +		buffers_.erase(it);
> +
>  	return ret;
>  }
>
> --
> 2.44.0
>
>

Patch
diff mbox series

diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp
index fc19a33a..dbd0db19 100644
--- a/src/libcamera/framebuffer_allocator.cpp
+++ b/src/libcamera/framebuffer_allocator.cpp
@@ -97,6 +97,10 @@  int FrameBufferAllocator::allocate(Stream *stream)
 		LOG(Allocator, Error)
 			<< "Stream is not part of " << camera_->id()
 			<< " active configuration";
+
+	if (ret < 0)
+		buffers_.erase(it);
+
 	return ret;
 }