Skip to content
Permalink
Browse files

mmal: Keep references to pools to ensure they are lazily destroyed

  • Loading branch information...
popcornmix committed Jul 12, 2016
1 parent 1d48967 commit a5cc453982056c632ce2689173c14c009a25e2e6
@@ -57,8 +57,8 @@ using namespace KODI::MESSAGING;

#define VERBOSE 0

CMMALVideoBuffer::CMMALVideoBuffer(CMMALVideo *omv)
: m_omv(omv)
CMMALVideoBuffer::CMMALVideoBuffer(CMMALVideo *omv, std::shared_ptr<CMMALPool> pool)
: m_omv(omv), m_pool(pool)
{
if (VERBOSE && g_advancedSettings.CanLogComponent(LOGVIDEO))
CLog::Log(LOGDEBUG, "%s::%s %p", CLASSNAME, __func__, this);
@@ -270,7 +270,7 @@ void CMMALVideo::dec_output_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buf
if (m_fps > 40.0f && !g_graphicsContext.IsFullScreenVideo() && !(m_num_decoded & 1))
wanted = false;
if (wanted)
omvb = new CMMALVideoBuffer(this);
omvb = new CMMALVideoBuffer(this, m_pool);
m_num_decoded++;
if (g_advancedSettings.CanLogComponent(LOGVIDEO))
CLog::Log(LOGDEBUG, "%s::%s - %p (%p) buffer_size(%u) dts:%.3f pts:%.3f flags:%x:%x",
@@ -76,9 +76,11 @@ class CMMALPool;
class CMMALVideoBuffer : public CMMALBuffer
{
public:
CMMALVideoBuffer(CMMALVideo *omv);
CMMALVideoBuffer(CMMALVideo *omv, std::shared_ptr<CMMALPool> pool);
virtual ~CMMALVideoBuffer();
CMMALVideo *m_omv;
protected:
std::shared_ptr<CMMALPool> m_pool;
};

class CMMALVideo : public CDVDVideoCodec
@@ -354,6 +354,7 @@ bool CDecoder::Open(AVCodecContext *avctx, AVCodecContext* mainctx, enum AVPixel
if (CreateDummyDecoder())
m_pool = std::make_shared<CMMALPool>(m_dec_output, m_dec_output->buffer_num, 0);
assert(m_pool);
m_gpu_pool.SetPool(m_pool);
return true;
}

@@ -63,10 +63,12 @@ class CGPUPool
MMAL_BUFFER_HEADER_T *GetMmal(MMAL_POOL_T *render_pool);
virtual void Acquire() {}
virtual void Release() {}
virtual void SetPool(std::shared_ptr<CMMALPool> pool) { m_pool = pool; }
protected:
CCriticalSection m_section;
std::deque<CGPUMEM *> m_freeBuffers;
bool m_closing;
std::shared_ptr<CMMALPool> m_pool;
};

class CGPUPoolWrap : public CGPUPool

0 comments on commit a5cc453

Please sign in to comment.
You can’t perform that action at this time.