Handle first frame rendering correctly
This commit is contained in:
@@ -307,6 +307,17 @@ void MovieTexture_DShow::Create()
|
|||||||
* up the texture. */
|
* up the texture. */
|
||||||
CreateTexture();
|
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
|
// Start the graph running
|
||||||
Play();
|
Play();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,14 @@ CTextureRenderer::CTextureRenderer()
|
|||||||
if( FAILED(CBV_ret) )
|
if( FAILED(CBV_ret) )
|
||||||
RageException::Throw( hr_ssprintf(CBV_ret, "Could not create texture renderer object!") );
|
RageException::Throw( hr_ssprintf(CBV_ret, "Could not create texture renderer object!") );
|
||||||
|
|
||||||
// Store and ARageef the texture for our use.
|
|
||||||
m_pTexture = NULL;
|
m_pTexture = NULL;
|
||||||
|
|
||||||
|
m_OneFrameDecoded = SDL_CreateSemaphore(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CTextureRenderer::~CTextureRenderer()
|
CTextureRenderer::~CTextureRenderer()
|
||||||
{
|
{
|
||||||
// Do nothing
|
SDL_DestroySemaphore( m_OneFrameDecoded );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -88,5 +89,9 @@ HRESULT CTextureRenderer::DoRenderSample( IMediaSample * pSample )
|
|||||||
|
|
||||||
void CTextureRenderer::OnReceiveFirstSample( 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 );
|
DoRenderSample( pSample );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ public:
|
|||||||
long GetVidHeight() const { return m_lVidHeight; }
|
long GetVidHeight() const { return m_lVidHeight; }
|
||||||
void SetRenderTarget( MovieTexture_DShow* pTexture );
|
void SetRenderTarget( MovieTexture_DShow* pTexture );
|
||||||
|
|
||||||
|
SDL_sem *m_OneFrameDecoded;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Video width, height, and pitch.
|
// Video width, height, and pitch.
|
||||||
long m_lVidWidth, m_lVidHeight, m_lVidPitch;
|
long m_lVidWidth, m_lVidHeight, m_lVidPitch;
|
||||||
|
|||||||
Reference in New Issue
Block a user