disposing of video when using "RenderToTexture"
-
Friday, February 24, 2006 6:33 PMhi,
i am using C#, feb2006 sdk and managed directx 1.
i am exploring the Video class, especially the render to texture feature.
setting the whole thing up was not much of a problem, except for the total lack of documentation of this class. anyways, after some trial and error i got it work quite nicely.
the class seems well designed and - once you know how - is easy to use.
my problem is, i haven't found a way of safely disposing of the video object. i ALWAYS get an access violation exception when i call Video.Dispose(). mind you: this only applies to the render to texture mode. the normal window output works fine.
here's what i do in a nutshell:
i have a simple form object with a child window in which i setup a mdx1 device and display the video textures.
i start the video and catch the "TextureReadyToRender" event. since the delegate is invoked in a different thread i send a message to the form on each texture ready event, so that the actual display happens in the original form thread. the texture is processed by a pixel shader.
as i said, everything works nicely while the video is playing. i don't see any memory leaks or stuff like that. and the shader processes each frame as expected.
however, i cannot find a way to dispose of the video object without getting an exception.
whenever i call the dispose method i get an access violation exception. i inserted a Stop button in the form where i manually stop and then dispose the video. i get an exception.
i simply close the form and i get an (access violation) exception in the Dispose override of the form (when the base.Dispose() method is called in the generated code by the ide).
i tried simply dispose without prior call to stop - makes no difference.
all of this does not happen when i simply play the video in a window, whitout the render to texture option. but i need to catch every frame and process it with my pixel shader...
the version of the "Microsoft.DirectX.AudioVideoPlayback" reference is 1.0.2902.0.
the runtime version of the reference is 1.1.4322.
is this a known bug or am i doing something wrong?
Answers
-
Friday, May 12, 2006 6:37 PM
It is a bug, but we have no plans to update this API.
All Replies
-
Tuesday, April 11, 2006 12:40 PMhi,
i'm not sure exactly how your doing it but it seem to be getting an exception when disposing as well. the only problem is, i can't even get the video to play. would you mind sending me your code for playing? it would be very helpful to me and i will try and fix the disposal problem as well, letting you know. thanks.
alex -
Thursday, May 11, 2006 11:39 AMhi haraldhw,
I'm having the same problem. I'm trying to dispose a video which renders to texture mode and i'm getting
"An unhandled exception of type 'System.NullReferenceException' occurred in microsoft.directx.audiovideoplayback.dll"
"Microsoft.DirectX.AudioVideoPlayback" reference is 1.0.2902.0.
the runtime version of the reference is 1.1.4322.
this is the code i'm using:
Video v1 = new Video(GetNextMovie());
v1.TextureReadyToRender += new TextureRenderEventHandler(v1_TextureReadyToRender);
v1.RenderToTexture(tsVideo.Device);
v1.Play();
//v1.CurrentPosition = v1.Duration - 5;
Thread.Sleep(1000);
v1.Stop();
v1.Dispose(); // << the error above occurs here when i'm disposing the video.
I tried to dessign the TextureReadyToRender event from the video, i tried to bind to a null device before disposing, on disposing i tried to see if the video is null or is already disposed. nothing worked. I found no solution so far to this problem. -
Friday, May 12, 2006 6:37 PM
It is a bug, but we have no plans to update this API.
-
Monday, May 15, 2006 10:13 AMok, but is there a workaround to get the texture from a video and to render it on a surface?
what i'm trying to do is to play multiple videos in the same time, each videos to render their textures on a specific rectangle on the same surface.
Theoretically, I could do this with the Video object from AudioVideoPlayback, using RenderToTexture. Practically, there is this bug which stops me doing this player.
Can this be done using DirectX and of course without memory leaks due to bugs deep in the dx apis? -
Thursday, May 18, 2006 8:15 PM
David Weller wrote: It is a bug, but we have no plans to update this API.
could you pls give some more info regarding this bug?
is it safe to ignore the exception in the sense that future instantiations of Video objects will work properly (except for the bug in discussion)?
if not, is there a workaround?

