DirectShow: correctly clear surface in EVR presenter
The surface was never cleared in the EVR presenter. It could lead to situations where the presenter would use a destroyed surface. Change-Id: If2223f09f6f8c20c06345bed40803da10dcf4ae3 Reviewed-by: Christian Stromme <christian.stromme@qt.io>
This commit is contained in:
@@ -46,11 +46,20 @@ DirectShowVideoRendererControl::DirectShowVideoRendererControl(DirectShowEventLo
|
||||
, m_loop(loop)
|
||||
, m_surface(0)
|
||||
, m_filter(0)
|
||||
#ifdef HAVE_EVR
|
||||
, m_evrPresenter(0)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
DirectShowVideoRendererControl::~DirectShowVideoRendererControl()
|
||||
{
|
||||
#ifdef HAVE_EVR
|
||||
if (m_evrPresenter) {
|
||||
m_evrPresenter->setSurface(Q_NULLPTR);
|
||||
m_evrPresenter->Release();
|
||||
}
|
||||
#endif
|
||||
if (m_filter)
|
||||
m_filter->Release();
|
||||
}
|
||||
@@ -65,6 +74,14 @@ void DirectShowVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
|
||||
if (m_surface == surface)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_EVR
|
||||
if (m_evrPresenter) {
|
||||
m_evrPresenter->setSurface(Q_NULLPTR);
|
||||
m_evrPresenter->Release();
|
||||
m_evrPresenter = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_filter) {
|
||||
m_filter->Release();
|
||||
m_filter = 0;
|
||||
@@ -75,12 +92,13 @@ void DirectShowVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
|
||||
if (m_surface) {
|
||||
#ifdef HAVE_EVR
|
||||
m_filter = com_new<IBaseFilter>(clsid_EnhancedVideoRenderer);
|
||||
EVRCustomPresenter *evrPresenter = new EVRCustomPresenter(m_surface);
|
||||
if (!evrPresenter->isValid() || !qt_evr_setCustomPresenter(m_filter, evrPresenter)) {
|
||||
m_evrPresenter = new EVRCustomPresenter(m_surface);
|
||||
if (!m_evrPresenter->isValid() || !qt_evr_setCustomPresenter(m_filter, m_evrPresenter)) {
|
||||
m_filter->Release();
|
||||
m_filter = 0;
|
||||
m_evrPresenter->Release();
|
||||
m_evrPresenter = 0;
|
||||
}
|
||||
evrPresenter->Release();
|
||||
|
||||
if (!m_filter)
|
||||
#endif
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
#include "qvideorenderercontrol.h"
|
||||
|
||||
class DirectShowEventLoop;
|
||||
#ifdef HAVE_EVR
|
||||
class EVRCustomPresenter;
|
||||
#endif
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
@@ -61,6 +64,9 @@ private:
|
||||
DirectShowEventLoop *m_loop;
|
||||
QAbstractVideoSurface *m_surface;
|
||||
IBaseFilter *m_filter;
|
||||
#ifdef HAVE_EVR
|
||||
EVRCustomPresenter *m_evrPresenter;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user