qt - Working with CLSID_FilterGraph across different threads -


i'm using directshow in qt application.

to create instance of filter graph, using qtconcurrent::run (i.e. using 1 of available threads in global app thread pool).

here's simplified code sample runs in qthreadpool:

graph_ptr createmoviegraph(const qstring & file) {      ::coinitializeex(nullptr, coinit_multithreaded);      auto * dst = graph_ptr(new moviegraph(path));      ::couninitialize();       return dst; } 

later, delete graph_ptr object in ui thread. afaik, qapplication ui thread works in sta threading model deletion works without crashes or memory leaks. correct?

sometimes need pause or resume graph_ptr object in ui thread.

// ui thread _graph_ptr->pause(); 

here's "pause" implementatino in graph_ptr object:

_mediacontrolinterface->pause(); // ... // ccomptr<imediacontrol>   _mediacontrolinterface; 

the imediacontrol interface queried in qthreadpool @ graph_ptr object initialization time.

it turns out work object ui thread (sta), while object created in qthreadpool (mta) thread. works without crashes, guess cannot use object across threads different threading models?

thanks in advance.

 ::coinitializeex(nullptr, coinit_multithreaded);  auto * dst = graph_ptr(new moviegraph(path));  ::couninitialize(); 

this not well. couninitialize must called when com activity completed. add this, must checking returned status codes. on sta thread result in error on coinitializeex , unmatched couninitialize afterwards.

more not ends in access violations. maybe don't reach them. directshow uses simplified com , can pass raw pointers between apartments, have important things correctly: initialization/uninitialization, reference counting. stay out of trouble want create, run, stop , release graph on sta thread.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -