IMFSourceReaderCallback thread executes after delete. RRS feed

  • Question

  • Hey Guys. I built a class which uses IMFSourceReader for getting images from webcam using Asynchronous method. The class destructor release IMFSourceReader follow by IMFMediaSource->Shutdown, then proceed by release.

    I create an instance of the class ( A ) and later delete it without any error. However, when I create another instance of the class ( B ), the callback thread tells me that my IMFSourceReader has been released and could not get sample with a dereferenced pointer 0xDDDDDDDD. When I use step by step debug at the callback thread, I found that 2 callback thread is working at the same time with a IMFSourceReader being usable which I suspect from instance ( B ) and another IMFSourceReader which has been released from instance ( A ) . I used EnterCriticalSection and LeaveCriticalSection for my callback.

    So, is there a way to actually stop the thread before releasing IMFSourceReader?


    Saturday, October 20, 2012 5:44 AM

All replies

  • IMFSourceReader uses MF platform worker threads to execute work items.  The threads are independent of the source reader and cannot just be stopped.  (MFShutdown will destroy MF platform threads, but there is no guaranteed time at which this will happen).

    It sounds like the issue is that your IMFSourceReaderCallback object is not respecting its refcount.  Whatever object is implementing IMFSourceReaderCallback cannot be destroyed until its refcount reaches 0.  Otherwise, there might be a callback pending on a worker thread that will cause a fault trying to access the deleted callback instance.

    Monday, November 19, 2012 11:13 PM
  • mark

    Saturday, August 16, 2014 5:57 AM