Setting Callbacks

Started by
1 comment, last by Programmer101 16 years, 2 months ago
I'm writing a program with DirectShow that plays a video through a custom allocator. While setting the custom allocator, I'm having a bit of trouble setting a callback. The interface that I'm using is the IVMRSurfaceAllocator9 which has a "callback" method: IVMRSurfaceAllocator9::InitializeDevice I wrote my own implementation for this following the same return and input:
HRESULT CALLBACK InitializeDevice(DWORD_PTR dwUserID, VMR9AllocationInfo *lpAllocInfo, DWORD *lpNumBuffers)
{
	//Set VMR to work with directx
	graphics.Release();
	if(!graphics.InitializeGraphics(g_hWnd, pWidth, pHeight, false))
		return E_FAIL;

	//Set the D3D device
	if(FAILED(pSAN->SetD3DDevice(graphics.GetDevice(), NULL)))
		return E_FAIL;
	
	return S_OK;
}
but I don't know how to tell the interface that I want this to be the callback. I tried this:
pSAN->InitializeDevice = InitializeDevice;
but obviously that didn't work and it gave me an error. How do I set the callback? Thanks.
Advertisement
MSDN

According to the docs, this isn't a callback function at all. It seems that you need to provide custom implmentations for the interface. To do this, create a class that derives from IVMRSurfaceAllocator9, and provide your custom implmentation of IVMRSurfaceAllocator9 (and don't forget to implement the methods from IUnknown, too).
NextWar: The Quest for Earth available now for Windows Phone 7.
Haha, alright. Part of the documentation said:

"Allocate surfaces in the IVMRSurfaceAllocator9::InitializeDevice callback method:"

maybe it means something else but that makes sense that it would be implemented. Thanks!

This topic is closed to new replies.

Advertisement