Quantcast
Channel: Media Foundation Development for Windows Desktop forum
Viewing all articles
Browse latest Browse all 1079

MFPutWorkItem requires main thread?

$
0
0

I've been getting an exception in my Windows 7 64-bit C++ application, when calling MFPutWorkItem() on a secondary thread. My IMFAsyncCallback::GetParameters() implementation gets called, but not my IMFAsyncCallback::Invoke() implementation. In my call stack I see_beginthreadex() at the top, CWorkQueue::CThread::Init() next down, and CWorkQueue::AddThread() next down again. My call to MFPutWorkItem() targets MFASYNC_CALLBACK_QUEUE_MULTITHREADED.

When I call MFPutWorkItem() on the main/UI thread, it works fine. Is there a requirement for MFPutWorkItem() to be called on the main thread?

To explain why I'm trying to use a secondary thread for the call:

my application is using OpenGL to animate some geometry in my CWnd-based window,

my OnPaint() message handler calls SwapBuffers() to display the current frame, copies the pixel data associated with the CWnd's area on the screen into a CImage, and releases a secondary thread to convert the CImage's pixel data from its RGB colour space into the YUV colour space for the 'H264 Encoder MFT'-configured IMFTransform, using an OpenGL shader program.

When the shader program has finished, I was trying to copy the formatted YUV pixel data into an IMFBuffer, add that buffer to an IMFSample, and call MFPutWorkItem(). My Invoke() implementation calls IMFTransform::ProcessInput() on the IMFSample, to perform the H264 video encoding.

I don't pretend to know much about Media Foundation, and there may well be much better ways of saving my animation into an AVI.

My problem at this stage though is that MFPutWorkItem() doesn't seem to be happy being called on secondary thread. Is that behaviour expected, or is there something I'm not doing correctly?


Viewing all articles
Browse latest Browse all 1079

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>