|Microsoft DirectX 9.0|
The SetCallback method specifies a callback method to call on incoming samples.
HRESULT SetCallback( ISampleGrabberCB *pCallback, long WhichMethodToCallback );
Pointer to an ISampleGrabberCB interface containing the callback method, or NULL to cancel the callback.
Index specifying the callback method. Must be one of the following values.
|0||Call the ISampleGrabberCB::SampleCB method.|
|1||Call the ISampleGrabberCB::BufferCB method.|
Returns one of the following values.
|E_INVALIDARG||Samples are not being buffered.|
If the sample is a Microsoft® DirectDraw® surface, the surface is locked during the callback. The Win16 lock (also called Win16Mutex) might be locked as well. Both of these locks create the potential for deadlock. If the callback thread waits for a thread that is trying to call a DirectDraw API, it can cause deadlock. In addition, if the Win16 lock is being held, deadlock can result if the callback holds a critical section or waits for another thread to complete any activity.
Therefore, the callback should not perform any actions with the potential to block, such as holding a critical section or waiting on another thread. Also, do not call any GDI or USER32.DLL APIs that might cause a window to move. For more information about the Win16 lock, see Knowledge Base article Q125867, Understanding Win16Mutex.
The data processing thread blocks until the callback method returns. If the callback does not return quickly, it can interfere with playback.
Modifying the contents of the sample is not recommended. Either make a copy of the sample, or write a custom filter instead of using the Sample Grabber.
The filter does not invoke the callback function for