From 02e39d7f67658e0b4e1f7e57eb193365c2571096 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 1 Sep 2003 19:22:14 +0000 Subject: [PATCH] Handle first frame rendering correctly --- .../src/arch/MovieTexture/MovieTexture_DShow.cpp | 11 +++++++++++ .../arch/MovieTexture/MovieTexture_DShowHelper.cpp | 9 +++++++-- .../src/arch/MovieTexture/MovieTexture_DShowHelper.h | 2 ++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp b/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp index 3f303939ff..48f560d9da 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp +++ b/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp @@ -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(); } diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_DShowHelper.cpp b/stepmania/src/arch/MovieTexture/MovieTexture_DShowHelper.cpp index 5bea552548..158164a3df 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture_DShowHelper.cpp +++ b/stepmania/src/arch/MovieTexture/MovieTexture_DShowHelper.cpp @@ -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 ); } diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_DShowHelper.h b/stepmania/src/arch/MovieTexture/MovieTexture_DShowHelper.h index 136273bad6..20c7d6cd16 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture_DShowHelper.h +++ b/stepmania/src/arch/MovieTexture/MovieTexture_DShowHelper.h @@ -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;