I'm using DirectShow in my Qt application.
To create the instance of Filter Graph, I am using QtConcurrent::run (i.e. using one of the available threads in global app thread pool).
Here's a simplified code sample that runs in QThreadPool:
graph_ptr createMovieGraph(const QString & file)
{
::CoInitializeEx(nullptr, COINIT_MULTITHREADED);
auto * dst = graph_ptr(new MovieGraph(path));
::CoUninitialize();
return dst;
}
Later, I delete my graph_ptr object in UI thread. AFAIK, QApplication UI thread works in STA threading model but deletion works without any crashes or memory leaks. Is it correct?
Sometimes I need to pause or resume my graph_ptr object in UI thread.
// UI Thread
_graph_ptr->pause();
Here's the "pause" implementatino in graph_ptr object:
_mediaControlInterface->Pause();
// ...
// CComPtr<IMediaControl> _mediaControlInterface;
The IMediaControl interface was queried in QThreadPool at the graph_ptr object initialization time.
It turns out that I work with the object from UI thread (STA), while this object was created in QThreadPool (MTA) thread. Everything works without crashes, but I guess I cannot use object across threads with different threading models?
Thanks in advance.