[libcamera-devel] pipeline: simple: Fix an issue in breadth-first search
diff mbox series

Message ID 20210404210353.268967-1-pnguyen@baylibre.com
State Accepted
Commit 0373490ef64340ed42a21500b6f9a3575b890ba5
Headers show
Series
  • [libcamera-devel] pipeline: simple: Fix an issue in breadth-first search
Related show

Commit Message

Phi-bang Nguyen April 4, 2021, 9:03 p.m. UTC
When seting up the pipeline, the latest entity in the queue is
taken but the oldest one is poped. This is a mistake. Fix it.

Fixes: 4671911df040 ("pipeline: simple: Use breadth-first search
to setup media pipeline")

Signed-off-by: Phi-Bang Nguyen <pnguyen@baylibre.com>
---
 src/libcamera/pipeline/simple/simple.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Phi-bang Nguyen April 13, 2021, 10:12 a.m. UTC | #1
Hi Laurent,

Just a kind reminder to see if you have some feedback on the patch :-)

Thanks !

On Sun, Apr 4, 2021 at 11:04 PM Phi-Bang Nguyen <pnguyen@baylibre.com>
wrote:

> When seting up the pipeline, the latest entity in the queue is
> taken but the oldest one is poped. This is a mistake. Fix it.
>
> Fixes: 4671911df040 ("pipeline: simple: Use breadth-first search
> to setup media pipeline")
>
> Signed-off-by: Phi-Bang Nguyen <pnguyen@baylibre.com>
> ---
>  src/libcamera/pipeline/simple/simple.cpp | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/libcamera/pipeline/simple/simple.cpp
> b/src/libcamera/pipeline/simple/simple.cpp
> index f81a4d15..a2dbc336 100644
> --- a/src/libcamera/pipeline/simple/simple.cpp
> +++ b/src/libcamera/pipeline/simple/simple.cpp
> @@ -288,12 +288,12 @@
> SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe,
>
>         /* Remember at each entity where we came from. */
>         std::unordered_map<MediaEntity *, Entity> parents;
> -       queue.push(sensor);
> -
>         MediaEntity *entity = nullptr;
>
> +       queue.push(sensor);
> +
>         while (!queue.empty()) {
> -               entity = queue.back();
> +               entity = queue.front();
>                 queue.pop();
>
>                 /* Found the capture device. */
> --
> 2.25.1
>
>
Laurent Pinchart April 13, 2021, 11:38 p.m. UTC | #2
Hi Phi-Bang,

Thank you for the patch, and sorry for the delay.

On Sun, Apr 04, 2021 at 11:03:53PM +0200, Phi-Bang Nguyen wrote:
> When seting up the pipeline, the latest entity in the queue is
> taken but the oldest one is poped. This is a mistake. Fix it.
> 
> Fixes: 4671911df040 ("pipeline: simple: Use breadth-first search
> to setup media pipeline")

Minor issue, the Fixes: line shouldn't be wrapped (to make it easy for
scripts to parse it). I've fixed this and pushed the patch.

> Signed-off-by: Phi-Bang Nguyen <pnguyen@baylibre.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/libcamera/pipeline/simple/simple.cpp | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
> index f81a4d15..a2dbc336 100644
> --- a/src/libcamera/pipeline/simple/simple.cpp
> +++ b/src/libcamera/pipeline/simple/simple.cpp
> @@ -288,12 +288,12 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe,
>  
>  	/* Remember at each entity where we came from. */
>  	std::unordered_map<MediaEntity *, Entity> parents;
> -	queue.push(sensor);
> -
>  	MediaEntity *entity = nullptr;
>  
> +	queue.push(sensor);
> +
>  	while (!queue.empty()) {
> -		entity = queue.back();
> +		entity = queue.front();
>  		queue.pop();
>  
>  		/* Found the capture device. */

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index f81a4d15..a2dbc336 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -288,12 +288,12 @@  SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe,
 
 	/* Remember at each entity where we came from. */
 	std::unordered_map<MediaEntity *, Entity> parents;
-	queue.push(sensor);
-
 	MediaEntity *entity = nullptr;
 
+	queue.push(sensor);
+
 	while (!queue.empty()) {
-		entity = queue.back();
+		entity = queue.front();
 		queue.pop();
 
 		/* Found the capture device. */