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 9, 2015
1 parent ea5085e commit e059c0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions xbmc/cores/VideoRenderers/MMALRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

CRenderInfo CMMALRenderer::GetRenderInfo()
{
CSingleLock lock(m_sharedSection);
CRenderInfo info;

// we'll assume that video is accelerated (RENDER_FMT_MMAL) for now
Expand Down Expand Up @@ -92,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 @@ -223,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 @@ -245,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 @@ -372,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 @@ -430,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 @@ -442,6 +448,7 @@ void CMMALRenderer::FlipPage(int source)

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

Expand Down Expand Up @@ -473,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 @@ -590,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
Original file line number Diff line number Diff line change
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 e059c0e

Please sign in to comment.