Handle first frame rendering correctly

This commit is contained in:
Glenn Maynard
2003-09-01 19:22:14 +00:00
parent 21cf140aa4
commit 02e39d7f67
3 changed files with 20 additions and 2 deletions
@@ -307,6 +307,17 @@ void MovieTexture_DShow::Create()
* up the texture. */
CreateTexture();
/* Pausing the graph will cause only one frame to be rendered. Do that, then
* wait for the frame to be rendered, to guarantee that the texture is set
* when this function returns. */
Pause();
CHECKPOINT;
SDL_SemWait( pCTR->m_OneFrameDecoded );
CHECKPOINT;
CheckFrame();
CHECKPOINT;
// Start the graph running
Play();
}
@@ -17,13 +17,14 @@ CTextureRenderer::CTextureRenderer()
if( FAILED(CBV_ret) )
RageException::Throw( hr_ssprintf(CBV_ret, "Could not create texture renderer object!") );
// Store and ARageef the texture for our use.
m_pTexture = NULL;
m_OneFrameDecoded = SDL_CreateSemaphore(0);
}
CTextureRenderer::~CTextureRenderer()
{
// Do nothing
SDL_DestroySemaphore( m_OneFrameDecoded );
}
@@ -88,5 +89,9 @@ HRESULT CTextureRenderer::DoRenderSample( IMediaSample * pSample )
void CTextureRenderer::OnReceiveFirstSample( IMediaSample * pSample )
{
/* If the main thread is in MovieTexture_DShow::Create, kick: */
if( SDL_SemValue(m_OneFrameDecoded) == 0 )
SDL_SemPost( m_OneFrameDecoded );
DoRenderSample( pSample );
}
@@ -35,6 +35,8 @@ public:
long GetVidHeight() const { return m_lVidHeight; }
void SetRenderTarget( MovieTexture_DShow* pTexture );
SDL_sem *m_OneFrameDecoded;
protected:
// Video width, height, and pitch.
long m_lVidWidth, m_lVidHeight, m_lVidPitch;