Jump to content
  • Advertisement
Sign in to follow this  
Programmer101

Setting Callbacks

This topic is 3901 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
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).

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!