Skip to content

Commit 9203a71

Browse files
author
Clement Champetier
committed
filters: refactor how to allocate/free the objects
1 parent aa9bba3 commit 9203a71

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/AvTranscoder/filter/Filter.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class AvExport Filter
3030
#endif
3131

3232
private:
33-
AVFilter* _filter;
34-
AVFilterContext* _context;
33+
AVFilter* _filter; ///< Has ownership
34+
AVFilterContext* _context; ///< Has link (no ownership)
3535
std::string _options;
3636
std::string _instanceName;
3737
};

src/AvTranscoder/filter/FilterGraph.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ FilterGraph::~FilterGraph()
3030
{
3131
for(std::vector<Filter*>::iterator it = _filters.begin(); it < _filters.end(); ++it)
3232
{
33-
it = _filters.erase(it);
33+
delete(*it);
3434
}
3535
avfilter_graph_free(&_graph);
3636
}
@@ -168,9 +168,8 @@ void FilterGraph::addInBuffer(const std::vector<IFrame*>& inputs)
168168
throw std::runtime_error("Cannot create input buffer of filter graph: the given frame is invalid.");
169169

170170
// add in buffer
171-
Filter* in = new Filter(filterName, filterOptions.str(), "in");
172171
LOG_INFO("Add filter '" << filterName << "' at the beginning of the graph.")
173-
_filters.insert(_filters.begin(), in);
172+
_filters.insert(_filters.begin(), new Filter(filterName, filterOptions.str(), "in"));
174173
}
175174
}
176175

0 commit comments

Comments
 (0)