Make the CTextureRenderer a local, since it's freed by m_pGB, and
we can set it all up in init.
This commit is contained in:
@@ -370,18 +370,9 @@ void RageMovieTexture::Create()
|
|||||||
if( FAILED( hr = InitDShowTextureRenderer() ) )
|
if( FAILED( hr = InitDShowTextureRenderer() ) )
|
||||||
throw RageException( hr, "Could not initialize the DirectShow Texture Renderer!" );
|
throw RageException( hr, "Could not initialize the DirectShow Texture Renderer!" );
|
||||||
|
|
||||||
if( FAILED( hr = CreateD3DTexture() ) )
|
|
||||||
throw RageException( hr, "Could not create the D3D Texture!" );
|
|
||||||
|
|
||||||
// Pass the D3D texture to our TextureRenderer so it knows
|
|
||||||
// where to render new movie frames to.
|
|
||||||
if( FAILED( hr = m_pCTR->SetRenderTarget( this ) ) )
|
|
||||||
throw RageException( hr, "RageMovieTexture: SetRenderTarget failed." );
|
|
||||||
|
|
||||||
// Start the graph running
|
// Start the graph running
|
||||||
if( FAILED( hr = PlayMovie() ) )
|
if( FAILED( hr = PlayMovie() ) )
|
||||||
throw RageException( hr, "Could not run the DirectShow graph." );
|
throw RageException( hr, "Could not run the DirectShow graph." );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -410,10 +401,11 @@ HRESULT RageMovieTexture::InitDShowTextureRenderer()
|
|||||||
throw RageException( hr, "Could not create CLSID_FilterGraph!" );
|
throw RageException( hr, "Could not create CLSID_FilterGraph!" );
|
||||||
|
|
||||||
// Create the Texture Renderer object
|
// Create the Texture Renderer object
|
||||||
m_pCTR = new CTextureRenderer();
|
CTextureRenderer *pCTR = new CTextureRenderer;
|
||||||
|
|
||||||
// Get a pointer to the IBaseFilter on the TextureRenderer, add it to graph
|
/* Get a pointer to the IBaseFilter on the TextureRenderer, and add it to the
|
||||||
CComPtr<IBaseFilter> pFTR = m_pCTR;
|
* graph. When m_pGB is released, it will free pFTR. */
|
||||||
|
CComPtr<IBaseFilter> pFTR = pCTR;
|
||||||
if( FAILED( hr = m_pGB->AddFilter(pFTR, L"TEXTURERENDERER" ) ) )
|
if( FAILED( hr = m_pGB->AddFilter(pFTR, L"TEXTURERENDERER" ) ) )
|
||||||
throw RageException( hr, "Could not add renderer filter to graph!" );
|
throw RageException( hr, "Could not add renderer filter to graph!" );
|
||||||
|
|
||||||
@@ -453,11 +445,21 @@ HRESULT RageMovieTexture::InitDShowTextureRenderer()
|
|||||||
|
|
||||||
// The graph is built, now get the set the output video width and height.
|
// The graph is built, now get the set the output video width and height.
|
||||||
// The source and image width will always be the same since we can't scale the video
|
// The source and image width will always be the same since we can't scale the video
|
||||||
m_iSourceWidth = m_pCTR->GetVidWidth();
|
m_iSourceWidth = pCTR->GetVidWidth();
|
||||||
m_iSourceHeight = m_pCTR->GetVidHeight();
|
m_iSourceHeight = pCTR->GetVidHeight();
|
||||||
m_iImageWidth = m_iSourceWidth;
|
m_iImageWidth = m_iSourceWidth;
|
||||||
m_iImageHeight = m_iSourceHeight;
|
m_iImageHeight = m_iSourceHeight;
|
||||||
|
|
||||||
|
/* We've set up the movie, so we know the dimensions we need. Set
|
||||||
|
* up the texture. */
|
||||||
|
if( FAILED( hr = CreateD3DTexture() ) )
|
||||||
|
throw RageException( hr, "Could not create the D3D Texture!" );
|
||||||
|
|
||||||
|
// Pass the D3D texture to our TextureRenderer so it knows
|
||||||
|
// where to render new movie frames to.
|
||||||
|
if( FAILED( hr = pCTR->SetRenderTarget( this ) ) )
|
||||||
|
throw RageException( hr, "RageMovieTexture: SetRenderTarget failed." );
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -548,15 +550,11 @@ void RageMovieTexture::CheckMovieStatus()
|
|||||||
void RageMovieTexture::CleanupDShow()
|
void RageMovieTexture::CleanupDShow()
|
||||||
{
|
{
|
||||||
LOG->Trace("RageMovieTexture::CleanupDShow()");
|
LOG->Trace("RageMovieTexture::CleanupDShow()");
|
||||||
m_pCTR->SetRenderTarget( NULL );
|
|
||||||
// Shut down the graph
|
// Shut down the graph
|
||||||
if (m_pGB) {
|
if (m_pGB) {
|
||||||
Stop();
|
Stop();
|
||||||
m_pGB.Release ();
|
m_pGB.Release ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// MEM LEAK! Why in the world does this cause a crash... I'm commenting it out for now.
|
|
||||||
// SAFE_DELETE( m_pCTR );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageMovieTexture::Play()
|
void RageMovieTexture::Play()
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
#include "baseclasses/streams.h"
|
#include "baseclasses/streams.h"
|
||||||
|
|
||||||
class CTextureRenderer;
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// RageMovieTexture Class Declarations
|
// RageMovieTexture Class Declarations
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -75,7 +73,6 @@ protected:
|
|||||||
// DirectShow pointers
|
// DirectShow pointers
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
CComPtr<IGraphBuilder> m_pGB; // GraphBuilder
|
CComPtr<IGraphBuilder> m_pGB; // GraphBuilder
|
||||||
CTextureRenderer *m_pCTR; // DShow Texture renderer
|
|
||||||
bool m_bLoop;
|
bool m_bLoop;
|
||||||
bool m_bPlaying;
|
bool m_bPlaying;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user