summaryrefslogtreecommitdiffstats
path: root/src/plugins/multimedia/windows
diff options
context:
space:
mode:
authorAndré de la Rocha <andre.rocha@qt.io>2022-01-31 22:47:11 +0100
committerAndré de la Rocha <andre.rocha@qt.io>2022-02-01 16:05:25 +0100
commit7fa8e78cc2417ab245c2e662dc2ece77329fed31 (patch)
treed94361da7ee15614cff79bcee2035a4587c456cb /src/plugins/multimedia/windows
parenta997f2cee2c8509aa597bb89e3c00eefe31c7564 (diff)
Windows: Fix texture leak on media player
Textures were being created in D3DPresentEngine::createVideoSamples() and never released. Fixes: QTBUG-100341 Pick-to: 6.2 6.3 Change-Id: I31c9bbfa5a6a6b626685c45980adcbf23a473582 Reviewed-by: Piotr Srebrny <piotr.srebrny@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/plugins/multimedia/windows')
-rw-r--r--src/plugins/multimedia/windows/evr/evrd3dpresentengine.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/multimedia/windows/evr/evrd3dpresentengine.cpp b/src/plugins/multimedia/windows/evr/evrd3dpresentengine.cpp
index 6090be6d6..c3c6bac1a 100644
--- a/src/plugins/multimedia/windows/evr/evrd3dpresentengine.cpp
+++ b/src/plugins/multimedia/windows/evr/evrd3dpresentengine.cpp
@@ -534,9 +534,11 @@ HRESULT D3DPresentEngine::createVideoSamples(IMFMediaType *format, QList<IMFSamp
d3dFormat = D3DFMT_A8B8G8R8;
for (int i = 0; i < PRESENTER_BUFFER_COUNT; i++) {
- IDirect3DTexture9 *texture = nullptr;
+ // texture ref cnt is increased by GetSurfaceLevel()/MFCreateVideoSampleFromSurface()
+ // below, so it will be destroyed only when the sample pool is released.
+ QWindowsIUPointer<IDirect3DTexture9> texture;
HANDLE sharedHandle = nullptr;
- hr = m_device->CreateTexture(width, height, 1, D3DUSAGE_RENDERTARGET, (D3DFORMAT)d3dFormat, D3DPOOL_DEFAULT, &texture, &sharedHandle);
+ hr = m_device->CreateTexture(width, height, 1, D3DUSAGE_RENDERTARGET, (D3DFORMAT)d3dFormat, D3DPOOL_DEFAULT, texture.address(), &sharedHandle);
if (FAILED(hr))
break;