Skip to content

Commit

Permalink
mmalrenderer: Keep both pools
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed May 18, 2016
1 parent a6d040e commit 4c1f09f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
44 changes: 34 additions & 10 deletions xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ MMAL_POOL_T *CMMALRenderer::GetPool(ERenderFormat format, AVPixelFormat pixfmt,
if (!m_bMMALConfigured || formatChanged)
m_bMMALConfigured = init_vout(format, pixfmt, opaque);

return m_vout_input_pool;
return opaque ? m_vout_input_pool_opaque : m_vout_input_pool;
}

CRenderInfo CMMALRenderer::GetRenderInfo()
Expand All @@ -55,7 +55,7 @@ CRenderInfo CMMALRenderer::GetRenderInfo()
CRenderInfo info;

if (g_advancedSettings.CanLogComponent(LOGVIDEO))
CLog::Log(LOGDEBUG, "%s::%s cookie:%p", CLASSNAME, __func__, (void *)m_vout_input_pool);
CLog::Log(LOGDEBUG, "%s::%s opaque:%p", CLASSNAME, __func__, this);

info.max_buffer_size = NUM_BUFFERS;
info.optimal_buffer_size = NUM_BUFFERS;
Expand Down Expand Up @@ -123,7 +123,7 @@ bool CMMALRenderer::init_vout(ERenderFormat format, AVPixelFormat pixfmt, bool o
CLog::Log(LOGDEBUG, "%s::%s configured:%d format %d->%d pixfmt %x->%x opaque %d->%d", CLASSNAME, __func__, m_bConfigured, m_format, format, m_pixfmt, pixfmt, m_opaque, opaque);

if (m_bMMALConfigured && formatChanged)
UnInitMMAL();
UnInitMMAL(!opaque, opaque);

if (m_bMMALConfigured || format == RENDER_FMT_BYPASS)
return true;
Expand Down Expand Up @@ -176,7 +176,10 @@ bool CMMALRenderer::init_vout(ERenderFormat format, AVPixelFormat pixfmt, bool o
return false;
}

m_vout_input->buffer_num = std::max(m_vout_input->buffer_num_recommended, (uint32_t)m_NumYV12Buffers+(m_opaque?0:32));
uint32_t num_buffers = std::max(m_vout_input->buffer_num_recommended, (uint32_t)m_NumYV12Buffers+32);
uint32_t num_buffers_opaque = std::max(m_vout_input->buffer_num_recommended, (uint32_t)m_NumYV12Buffers);

m_vout_input->buffer_num = m_opaque ? num_buffers_opaque:num_buffers;
m_vout_input->buffer_size = m_vout_input->buffer_size_recommended;

status = mmal_port_enable(m_vout_input, vout_input_port_cb_static);
Expand All @@ -193,13 +196,26 @@ bool CMMALRenderer::init_vout(ERenderFormat format, AVPixelFormat pixfmt, bool o
return false;
}

CLog::Log(LOGDEBUG, "%s::%s Created pool of size %d x %d", CLASSNAME, __func__, m_vout_input->buffer_num, m_vout_input->buffer_size);
m_vout_input_pool = mmal_port_pool_create(m_vout_input , m_vout_input->buffer_num, m_opaque ? m_vout_input->buffer_size:0);
if (!m_vout_input_pool)
{
m_vout_input_pool = mmal_port_pool_create(m_vout_input, num_buffers, 0);
CLog::Log(LOGDEBUG, "%s::%s Created pool %p of size %d x %d", CLASSNAME, __func__, m_vout_input, num_buffers, 0);
}
if (!m_vout_input_pool)
{
CLog::Log(LOGERROR, "%s::%s Failed to create pool for decoder input port (status=%x %s)", CLASSNAME, __func__, status, mmal_status_to_string(status));
return false;
}
if (!m_vout_input_pool_opaque)
{
m_vout_input_pool_opaque = mmal_port_pool_create(m_vout_input, num_buffers_opaque, 128);
CLog::Log(LOGDEBUG, "%s::%s Created opaque pool %p of size %d x %d", CLASSNAME, __func__, m_vout_input_pool_opaque, num_buffers_opaque, 128);
}
if (!m_vout_input_pool_opaque)
{
CLog::Log(LOGERROR, "%s::%s Failed to create opaque pool for decoder input port (status=%x %s)", CLASSNAME, __func__, status, mmal_status_to_string(status));
return false;
}
if (!CSettings::GetInstance().GetBool("videoplayer.usedisplayasclock"))
{
m_queue = mmal_queue_create();
Expand All @@ -214,6 +230,7 @@ CMMALRenderer::CMMALRenderer() : CThread("MMALRenderer")
m_vout = NULL;
m_vout_input = NULL;
m_vout_input_pool = NULL;
m_vout_input_pool_opaque = NULL;
memset(m_buffers, 0, sizeof m_buffers);
m_iFlags = 0;
m_format = RENDER_FMT_NONE;
Expand Down Expand Up @@ -508,10 +525,10 @@ void CMMALRenderer::ReleaseBuffers()
ReleaseBuffer(i);
}

void CMMALRenderer::UnInitMMAL()
void CMMALRenderer::UnInitMMAL(bool destroy_pool, bool destroy_pool_opaque)
{
CSingleLock lock(m_sharedSection);
CLog::Log(LOGDEBUG, "%s::%s pool(%p)", CLASSNAME, __func__, m_vout_input_pool);
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
if (m_queue)
{
StopThread(true);
Expand All @@ -531,11 +548,18 @@ void CMMALRenderer::UnInitMMAL()

ReleaseBuffers();

if (m_vout_input_pool)
if (m_vout_input_pool && destroy_pool)
{
CLog::Log(LOGDEBUG, "%s::%s destroying pool (%p)", CLASSNAME, __func__, m_vout_input_pool);
mmal_port_pool_destroy(m_vout_input, m_vout_input_pool);
m_vout_input_pool = NULL;
}
if (m_vout_input_pool_opaque && destroy_pool_opaque)
{
CLog::Log(LOGDEBUG, "%s::%s destroying opaque pool (%p)", CLASSNAME, __func__, m_vout_input_pool_opaque);
mmal_port_pool_destroy(m_vout_input, m_vout_input_pool_opaque);
m_vout_input_pool_opaque = NULL;
}
m_vout_input = NULL;

if (m_vout)
Expand All @@ -557,7 +581,7 @@ void CMMALRenderer::UnInitMMAL()

void CMMALRenderer::UnInit()
{
UnInitMMAL();
UnInitMMAL(true, true);
}

bool CMMALRenderer::RenderCapture(CRenderCapture* capture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ class CMMALRenderer : public CBaseRenderer, public CThread
MMAL_COMPONENT_T *m_vout;
MMAL_PORT_T *m_vout_input;
MMAL_POOL_T *m_vout_input_pool;
MMAL_POOL_T *m_vout_input_pool_opaque;
MMAL_QUEUE_T *m_queue;
double m_error;

bool init_vout(ERenderFormat format, AVPixelFormat pixfmt, bool opaque);
void ReleaseBuffers();
void UnInitMMAL();
void UnInitMMAL(bool destroy_pool, bool destroy_pool_opaque);
};

0 comments on commit 4c1f09f

Please sign in to comment.