[gstreamer-bugs] [Bug 592415] dshowsrcwrapper and wasapi uninitializes the COM library

GStreamer (bugzilla.gnome.org) bugzilla at gnome.org
Thu Aug 20 13:24:36 PDT 2009


http://bugzilla.gnome.org/show_bug.cgi?id=592415


Julien Isorce <julien.isorce> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |julien.isorce at gmail.com


--- Comment #2 from Julien Isorce <julien.isorce at gmail.com> 2009-08-20 20:24:32 UTC ---
Hi,

I have experienced the same problem that's why I am doing something like you
suggested for a long time:

in gst_dshowvideosrc_init:

A
--------------------------------
hres = CoInitializeEx (NULL, COINIT_MULTITHREADED); 
if (FAILED(hres))
{
  if (hres == RPC_E_CHANGED_MODE)
  {
    src->is_com_holder = FALSE;
    GST_INFO("COM ALREADY INITIALIZED 0x%x", hres);
  }
  else
    GST_WARNING("FAILED TO INITIALIZED COM 0x%x", hres);
}
else
  GST_INFO("COM INITIALIZED");
--------------------------------


and in gst_dshowvideosrc_dispose:

B
--------------------------------
if (src->is_com_holder)
{
  CoUninitialize ();
  GST_INFO("COM UNINITIALIZED");
}
else
  GST_INFO("NO COM HOLDER");
--------------------------------

But I have not commited it yet.

It solved the issue in my case but as Michael said we cannot ensure that the
_dispose function is called in the same thread as _init when src->is_com_holder
is TRUE.

What I understand about COM and CoInit and CoUninit is that the thread that
calls CoInitializeEx(NULL, COINIT_MULTITHREADED) for the first time must be the
one that calls CoUninitialize () (and when we are sure that other threads does
not attempt to use COM again)

So what is the solution I am suggesting:

We should call A in gst_init and B in gst_deinit (which is automatically called
when the program terminates, am I right on this point ?)
Then we should also just call CoInitializeEx (NULL, COINIT_MULTITHREADED)
in _init function of a GstElment (dshowvideosrc for example) without checking
the return value. And finally never call CoUninitialize in _dispose.

It means that I am not sure that this is necessary to call CoUninitialize in
all threads that are using COM. I think only the first one which have succeeded
to call CoInitializeEx, have to call CoUninitialize.

Julien

-- 
Configure bugmail: http://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.




More information about the Gstreamer-bugs mailing list