diff options
author | Christian Strømme <christian.stromme@theqtcompany.com> | 2016-03-30 19:13:11 +0200 |
---|---|---|
committer | Christian Stromme <christian.stromme@theqtcompany.com> | 2016-03-31 10:12:37 +0000 |
commit | 3fb3231a9e22dcb780d5b31ec57896429d40b0e5 (patch) | |
tree | 33b6bb1b635a8830710fcd38c9d3f43532dc1a3f /src | |
parent | 6569c2561932d2dea7ff902971a2e8d91a5b1fe9 (diff) |
DirectShow: Release all filters when disconnecting the graph.
When disconnecting the graph we need to make sure that all the filters
in the graph are released, even the ones that are automatically added.
Since we can't know in advance which filters the graph consists of, we
need release them one by one.
Task-number: QTBUG-49281
Change-Id: Ifdf2fb6fe1c90ab85b47565c5fe82b6ebe55b183
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/directshow/camera/dscamerasession.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp index 2e92cb37d..3421f2cd1 100644 --- a/src/plugins/directshow/camera/dscamerasession.cpp +++ b/src/plugins/directshow/camera/dscamerasession.cpp @@ -1092,9 +1092,19 @@ void DSCameraSession::disconnectGraph() pPin = NULL; } - m_filterGraph->RemoveFilter(m_nullRendererFilter); - m_filterGraph->RemoveFilter(m_previewFilter); - m_filterGraph->RemoveFilter(m_sourceFilter); + // To avoid increasing the memory usage every time the graph is re-connected it's + // important that all filters are released; also the ones added by the "Intelligent Connect". + IEnumFilters *enumFilters = NULL; + hr = m_filterGraph->EnumFilters(&enumFilters); + if (SUCCEEDED(hr)) { + IBaseFilter *filter = NULL; + while (enumFilters->Next(1, &filter, NULL) == S_OK) { + m_filterGraph->RemoveFilter(filter); + enumFilters->Reset(); + filter->Release(); + } + enumFilters->Release(); + } } static bool qt_frameRateRangeGreaterThan(const QCamera::FrameRateRange &r1, const QCamera::FrameRateRange &r2) |