Commit 74a41330 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

[media] media: Keep using the same graph walk object for a given pipeline

Initialise a given graph walk object once, and then keep using it whilst
the same pipeline is running. Once the pipeline is stopped, release the
graph walk object.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 29d8da02
...@@ -379,10 +379,10 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, ...@@ -379,10 +379,10 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
mutex_lock(&mdev->graph_mutex); mutex_lock(&mdev->graph_mutex);
ret = media_entity_graph_walk_init(&pipe->graph, mdev); if (!pipe->streaming_count++) {
if (ret) { ret = media_entity_graph_walk_init(&pipe->graph, mdev);
mutex_unlock(&mdev->graph_mutex); if (ret)
return ret; goto error_graph_walk_start;
} }
media_entity_graph_walk_start(&pipe->graph, entity); media_entity_graph_walk_start(&pipe->graph, entity);
...@@ -483,7 +483,9 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, ...@@ -483,7 +483,9 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
break; break;
} }
media_entity_graph_walk_cleanup(graph); error_graph_walk_start:
if (!--pipe->streaming_count)
media_entity_graph_walk_cleanup(graph);
mutex_unlock(&mdev->graph_mutex); mutex_unlock(&mdev->graph_mutex);
...@@ -495,9 +497,11 @@ void media_entity_pipeline_stop(struct media_entity *entity) ...@@ -495,9 +497,11 @@ void media_entity_pipeline_stop(struct media_entity *entity)
{ {
struct media_device *mdev = entity->graph_obj.mdev; struct media_device *mdev = entity->graph_obj.mdev;
struct media_entity_graph *graph = &entity->pipe->graph; struct media_entity_graph *graph = &entity->pipe->graph;
struct media_pipeline *pipe = entity->pipe;
mutex_lock(&mdev->graph_mutex); mutex_lock(&mdev->graph_mutex);
WARN_ON(!pipe->streaming_count);
media_entity_graph_walk_start(graph, entity); media_entity_graph_walk_start(graph, entity);
while ((entity = media_entity_graph_walk_next(graph))) { while ((entity = media_entity_graph_walk_next(graph))) {
...@@ -506,7 +510,8 @@ void media_entity_pipeline_stop(struct media_entity *entity) ...@@ -506,7 +510,8 @@ void media_entity_pipeline_stop(struct media_entity *entity)
entity->pipe = NULL; entity->pipe = NULL;
} }
media_entity_graph_walk_cleanup(graph); if (!--pipe->streaming_count)
media_entity_graph_walk_cleanup(graph);
mutex_unlock(&mdev->graph_mutex); mutex_unlock(&mdev->graph_mutex);
} }
......
...@@ -119,9 +119,11 @@ struct media_entity_graph { ...@@ -119,9 +119,11 @@ struct media_entity_graph {
/* /*
* struct media_pipeline - Media pipeline related information * struct media_pipeline - Media pipeline related information
* *
* @graph: Media graph walk during pipeline start / stop * @streaming_count: Streaming start count - streaming stop count
* @graph: Media graph walk during pipeline start / stop
*/ */
struct media_pipeline { struct media_pipeline {
int streaming_count;
struct media_entity_graph graph; struct media_entity_graph graph;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment