Ticket #8620: 0001-fix_dxva2_segfaulting.commit

File 0001-fix_dxva2_segfaulting.commit, 2.2 KB (added by SHinck@…, 6 years ago)

Fix for crash on exit

Line 
1From 0f48f7bb1841bb70e1e0fd3b052ec6d4fa62275b Mon Sep 17 00:00:00 2001
2From: Sascha Hinck <SHinck@web.de>
3Date: Sat, 6 Jul 2013 01:48:43 +0200
4Subject: [PATCH] Fix segfaulting with DXVA2 hardware decoding at player end
5
6If playing content with DXVA2 hardware decoding mythfrontend segfaults
7on player end. That's because IDirectXVideoDecoderService_CreateSurface
8creates surface_count + 1 surfaces (1 frontbuffer + surface_count
9backbuffers) but IDirectXVideoDecoderService_CreateDecoder is created with
10surface_count buffers.
11---
12 mythtv/libs/libmythtv/dxva2decoder.cpp |   11 +++++++----
13 1 files changed, 7 insertions(+), 4 deletions(-)
14
15diff --git a/mythtv/libs/libmythtv/dxva2decoder.cpp b/mythtv/libs/libmythtv/dxva2decoder.cpp
16index 9789755..edfc317 100644
17--- a/mythtv/libs/libmythtv/dxva2decoder.cpp
18+++ b/mythtv/libs/libmythtv/dxva2decoder.cpp
19@@ -288,7 +288,7 @@ bool DXVA2Decoder::GetDecoderConfig(void)
20         m_service, m_input, &m_format, NULL, &cfg_count, &cfg_list);
21 
22     DXVA2_ConfigPictureDecode config = {};
23-    uint bitstream = 1;
24+    uint bitstream = 2;
25     for (uint i = 0; i < cfg_count; i++)
26     {
27         // select first available
28@@ -321,7 +321,7 @@ bool DXVA2Decoder::CreateSurfaces(void)
29 
30     HRESULT hr = IDirectXVideoDecoderService_CreateSurface(
31         m_service, (m_width + 15) & ~15, (m_height + 15) & ~15,
32-        m_context.surface_count, m_format.Format,
33+        m_context.surface_count - 1, m_format.Format,
34         D3DPOOL_DEFAULT, 0, DXVA2_VideoDecoderRenderTarget,
35         m_context.surface, NULL);
36 
37@@ -331,16 +331,19 @@ bool DXVA2Decoder::CreateSurfaces(void)
38     LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Created %1 decoder surfaces.")
39                                          .arg(m_context.surface_count));
40 
41-    for (uint i = 0; i < m_context.surface_count; i++)
42-        m_context.surface[i]->AddRef();
43     return true;
44 }
45 
46 void DXVA2Decoder::DestroySurfaces(void)
47 {
48     for (uint i = 0; i < m_context.surface_count; i++)
49+    {
50         if (m_context.surface[i])
51+        {
52             m_context.surface[i]->Release();
53+            m_context.surface[i] = NULL;
54+        }
55+    }
56     m_context.surface = NULL;
57     m_context.surface_count = 0;
58 }