Skip to content

Commit

Permalink
[mmal] Move the image pool from decoder to renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed May 8, 2015
1 parent fc154f2 commit 02fa7a2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
22 changes: 13 additions & 9 deletions xbmc/cores/VideoRenderers/MMALRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@

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

// we'll assume that video is accelerated (RENDER_FMT_MMAL) for now
// we can reconfigure renderer later if necessary
if (!m_bConfigured)
m_bConfigured = init_vout(RENDER_FMT_MMAL);

#if defined(MMAL_DEBUG_VERBOSE)
CLog::Log(LOGDEBUG, "%s::%s cookie:%p", CLASSNAME, __func__, (void *)m_vout_input_pool);
#endif
Expand Down Expand Up @@ -178,14 +184,11 @@ bool CMMALRenderer::init_vout(ERenderFormat format)
return false;
}

if (m_format == RENDER_FMT_YUV420P)
m_vout_input_pool = mmal_port_pool_create(m_vout_input , m_vout_input->buffer_num, m_vout_input->buffer_size);
if (!m_vout_input_pool)
{
m_vout_input_pool = mmal_pool_create(m_vout_input->buffer_num, m_vout_input->buffer_size);
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;
}
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;
}
return true;
}
Expand Down Expand Up @@ -467,7 +470,7 @@ void CMMALRenderer::ReleaseBuffers()

void CMMALRenderer::UnInitMMAL()
{
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
CLog::Log(LOGDEBUG, "%s::%s pool(%p)", CLASSNAME, __func__, m_vout_input_pool);
if (m_vout)
{
mmal_component_disable(m_vout);
Expand All @@ -481,6 +484,8 @@ void CMMALRenderer::UnInitMMAL()
m_vout_input = NULL;
}

ReleaseBuffers();

if (m_vout_input_pool)
{
mmal_pool_destroy(m_vout_input_pool);
Expand All @@ -492,7 +497,6 @@ void CMMALRenderer::UnInitMMAL()
mmal_component_release(m_vout);
m_vout = NULL;
}
ReleaseBuffers();

m_RenderUpdateCallBackFn = NULL;
m_RenderUpdateCallBackCtx = NULL;
Expand Down
18 changes: 5 additions & 13 deletions xbmc/cores/dvdplayer/DVDCodecs/Video/MMALCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ CMMALVideo::CMMALVideo()
m_dec_input = NULL;
m_dec_output = NULL;
m_dec_input_pool = NULL;
m_dec_output_pool = NULL;
m_vout_input_pool = NULL;

m_deint = NULL;
Expand Down Expand Up @@ -163,10 +162,6 @@ CMMALVideo::~CMMALVideo()
mmal_pool_destroy(m_dec_input_pool);
m_dec_input_pool = NULL;

if (m_dec_output_pool)
mmal_pool_destroy(m_dec_output_pool);
m_dec_output_pool = NULL;

if (m_deint)
mmal_component_destroy(m_deint);
m_deint = NULL;
Expand Down Expand Up @@ -695,13 +690,6 @@ bool CMMALVideo::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options, MMALVide
return false;
}

m_dec_output_pool = mmal_port_pool_create(m_dec_output, m_dec_output->buffer_num, m_dec_output->buffer_size);
if(!m_dec_output_pool)
{
CLog::Log(LOGERROR, "%s::%s Failed to create pool for decode output port (status=%x %s)", CLASSNAME, __func__, status, mmal_status_to_string(status));
return false;
}

if (!SendCodecConfigData())
return false;

Expand Down Expand Up @@ -748,6 +736,7 @@ int CMMALVideo::Decode(uint8_t* pData, int iSize, double dts, double pts)
MMAL_BUFFER_HEADER_T *buffer;
MMAL_STATUS_T status;

Prime();
// we need to queue then de-queue the demux packet, seems silly but
// mmal might not have an input buffer available when we are called
// and we must store the demuxer packet and try again later.
Expand Down Expand Up @@ -893,7 +882,10 @@ int CMMALVideo::Decode(uint8_t* pData, int iSize, double dts, double pts)
void CMMALVideo::Prime()
{
MMAL_BUFFER_HEADER_T *buffer;
while (buffer = mmal_queue_get(m_dec_output_pool->queue), buffer)
if (g_advancedSettings.CanLogComponent(LOGVIDEO))
CLog::Log(LOGDEBUG, "%s::%s - queue(%p)", CLASSNAME, __func__, m_vout_input_pool);
assert(m_vout_input_pool);
while (buffer = mmal_queue_get(m_vout_input_pool->queue), buffer)
Recycle(buffer);
}

Expand Down
1 change: 0 additions & 1 deletion xbmc/cores/dvdplayer/DVDCodecs/Video/MMALCodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ class CMMALVideo
MMAL_PORT_T *m_dec_input;
MMAL_PORT_T *m_dec_output;
MMAL_POOL_T *m_dec_input_pool;
MMAL_POOL_T *m_dec_output_pool;
MMAL_POOL_T *m_vout_input_pool;

MMAL_ES_FORMAT_T *m_es_format;
Expand Down

0 comments on commit 02fa7a2

Please sign in to comment.