Skip to content

Commit

Permalink
[mmalrenderer] Add shared lock around MMAL operations
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed May 8, 2015
1 parent 79a4306 commit b4b9bff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions xbmc/cores/VideoRenderers/MMALRenderer.cpp
Expand Up @@ -93,6 +93,7 @@ static void vout_input_port_cb_static(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *b

bool CMMALRenderer::init_vout(ERenderFormat format)
{
CSingleLock lock(m_sharedSection);
bool formatChanged = m_format != format;
MMAL_STATUS_T status;

Expand Down Expand Up @@ -224,6 +225,7 @@ CMMALRenderer::CMMALRenderer()

CMMALRenderer::~CMMALRenderer()
{
CSingleLock lock(m_sharedSection);
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
// shutdown thread
mmal_queue_put(m_release_queue, &m_quit_packet);
Expand All @@ -246,6 +248,7 @@ void CMMALRenderer::AddProcessor(CMMALVideoBuffer *buffer, int index)

bool CMMALRenderer::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format, unsigned int orientation)
{
CSingleLock lock(m_sharedSection);
ReleaseBuffers();

m_sourceWidth = width;
Expand Down Expand Up @@ -373,6 +376,7 @@ void CMMALRenderer::Update()

void CMMALRenderer::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
{
CSingleLock lock(m_sharedSection);
int source = m_iYV12RenderBuffer;
#if defined(MMAL_DEBUG_VERBOSE)
CLog::Log(LOGDEBUG, "%s::%s - %d %x %d %d", CLASSNAME, __func__, clear, flags, alpha, source);
Expand Down Expand Up @@ -431,6 +435,7 @@ void CMMALRenderer::RenderUpdate(bool clear, DWORD flags, DWORD alpha)

void CMMALRenderer::FlipPage(int source)
{
CSingleLock lock(m_sharedSection);
if (!m_bConfigured || m_format == RENDER_FMT_BYPASS)
return;

Expand All @@ -443,6 +448,7 @@ void CMMALRenderer::FlipPage(int source)

unsigned int CMMALRenderer::PreInit()
{
CSingleLock lock(m_sharedSection);
m_bConfigured = false;
UnInit();

Expand Down Expand Up @@ -474,6 +480,7 @@ void CMMALRenderer::ReleaseBuffers()

void CMMALRenderer::UnInitMMAL()
{
CSingleLock lock(m_sharedSection);
CLog::Log(LOGDEBUG, "%s::%s pool(%p)", CLASSNAME, __func__, m_vout_input_pool);
if (m_vout)
{
Expand Down Expand Up @@ -591,6 +598,7 @@ void CMMALRenderer::SetVideoRect(const CRect& InSrcRect, const CRect& InDestRect
// we get called twice a frame for left/right. Can ignore the rights.
if (g_graphicsContext.GetStereoView() == RENDER_STEREO_VIEW_RIGHT)
return;
CSingleLock lock(m_sharedSection);

if (!m_vout_input)
return;
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoRenderers/MMALRenderer.h
Expand Up @@ -108,6 +108,7 @@ class CMMALRenderer : public CBaseRenderer, public CThread
RENDER_STEREO_MODE m_display_stereo_mode;
bool m_StereoInvert;

CCriticalSection m_sharedSection;
MMAL_COMPONENT_T *m_vout;
MMAL_PORT_T *m_vout_input;
MMAL_POOL_T *m_vout_input_pool;
Expand Down

0 comments on commit b4b9bff

Please sign in to comment.