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 Apr 18, 2015
1 parent 008a685 commit 89c8ddb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions xbmc/cores/VideoRenderers/MMALRenderer.cpp
Expand Up @@ -44,6 +44,7 @@

void CMMALRenderer::Prime()
{
CSingleLock lock(m_sharedSection);
#if defined(MMAL_DEBUG_VERBOSE)
CLog::Log(LOGDEBUG, "%s::%s format:%d dec:%p pool:%p", CLASSNAME, __func__, m_format, m_mmal_video, m_vout_input_pool);
#endif
Expand All @@ -69,6 +70,7 @@ void CMMALRenderer::Prime()

void *CMMALRenderer::PassCookie(void *cookie)
{
CSingleLock lock(m_sharedSection);
m_mmal_video = (CMMALVideo *)cookie;
#if defined(MMAL_DEBUG_VERBOSE)
CLog::Log(LOGDEBUG, "%s::%s cookie:%p", CLASSNAME, __func__, cookie);
Expand All @@ -90,6 +92,7 @@ static void vout_control_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer

void CMMALRenderer::vout_input_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
{
CSingleLock lock(m_sharedSection);
#if defined(MMAL_DEBUG_VERBOSE)
CMMALVideoBuffer *omvb = (CMMALVideoBuffer *)buffer->user_data;
CLog::Log(LOGDEBUG, "%s::%s port:%p buffer %p (%p), len %d cmd:%x f:%x", CLASSNAME, __func__, port, buffer, omvb, buffer->length, buffer->cmd, buffer->flags);
Expand All @@ -116,6 +119,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 @@ -255,6 +259,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 @@ -277,6 +282,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 @@ -307,6 +313,7 @@ bool CMMALRenderer::Configure(unsigned int width, unsigned int height, unsigned

int CMMALRenderer::GetImage(YV12Image *image, int source, bool readonly)
{
CSingleLock lock(m_sharedSection);
#if defined(MMAL_DEBUG_VERBOSE)
CLog::Log(LOGDEBUG, "%s::%s - %p %d %d", CLASSNAME, __func__, image, source, readonly);
#endif
Expand Down Expand Up @@ -404,6 +411,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 @@ -464,6 +472,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 @@ -476,6 +485,7 @@ void CMMALRenderer::FlipPage(int source)

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

Expand All @@ -501,12 +511,14 @@ unsigned int CMMALRenderer::PreInit()

void CMMALRenderer::ReleaseBuffers()
{
CSingleLock lock(m_sharedSection);
for (int i=0; i<NUM_BUFFERS; i++)
ReleaseBuffer(i);
}

void CMMALRenderer::UnInitMMAL()
{
CSingleLock lock(m_sharedSection);
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
if (m_vout)
{
Expand Down Expand Up @@ -623,6 +635,7 @@ EINTERLACEMETHOD CMMALRenderer::AutoInterlaceMethod()

void CMMALRenderer::SetVideoRect(const CRect& InSrcRect, const CRect& InDestRect)
{
CSingleLock lock(m_sharedSection);
assert(g_graphicsContext.GetStereoView() != RENDER_STEREO_VIEW_RIGHT);

if (!m_vout_input)
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoRenderers/MMALRenderer.h
Expand Up @@ -112,6 +112,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 89c8ddb

Please sign in to comment.