Sign in to follow this  

Setting Callbacks

This topic is 3592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

This topic is 3592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this