summaryrefslogtreecommitdiffstats
path: root/src/plugins/directshow/player
diff options
context:
space:
mode:
authorVal Doroshchuk <valentyn.doroshchuk@qt.io>2019-08-30 12:59:29 +0200
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2019-09-09 12:33:18 +0200
commitcb06ede8ba9a33adbbfdc690faa1a83be4e70b55 (patch)
tree2c3da763347405210683bbb860726214d69a8714 /src/plugins/directshow/player
parent97177277a2fcca974d7599ab8ea12ad80ab30efc (diff)
DirectShow: Allow QMediaPlayer in secondary thread
Since using of any COM objects must be only after CoInitialize(), otherwise CoCreateInstance() returns nothing which causes a crash. If QMediaPlayer is moved to another thread, loading of any content will also cause a crash because of COM is not initialized. Proposing to use thread_local ref counter to keep each thread initialized and avoid double initialization. Fixes: QTBUG-77163 Change-Id: I81c67d6407b853c824edd3b42454fddf792fd90c Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src/plugins/directshow/player')
-rw-r--r--src/plugins/directshow/player/directshowplayerservice.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp
index def18be74..f5899cb6a 100644
--- a/src/plugins/directshow/player/directshowplayerservice.cpp
+++ b/src/plugins/directshow/player/directshowplayerservice.cpp
@@ -327,6 +327,7 @@ void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream
0x36b73882, 0xc2c8, 0x11cf, {0x8b, 0x46, 0x00, 0x80, 0x5f, 0x6c, 0xef, 0x60} };
m_graphStatus = Loading;
+ DirectShowUtils::CoInitializeIfNeeded();
m_graph = com_new<IFilterGraph2>(CLSID_FilterGraph, iid_IFilterGraph2);
m_graphBuilder = com_new<ICaptureGraphBuilder2>(CLSID_CaptureGraphBuilder2, IID_ICaptureGraphBuilder2);
@@ -664,6 +665,7 @@ void DirectShowPlayerService::releaseGraph()
::SetEvent(m_taskHandle);
m_loop->wait(&m_mutex);
+ DirectShowUtils::CoUninitializeIfNeeded();
}
}