Skip to content

Commit

Permalink
CVideoBufferManager: Add critical section
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed Jul 5, 2017
1 parent eb33cb3 commit 3ecf181
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions xbmc/cores/VideoPlayer/Process/VideoBuffer.cpp
Expand Up @@ -347,18 +347,21 @@ bool CVideoBufferPoolSysMem::IsCompatible(AVPixelFormat format, int width, int h

CVideoBufferManager::CVideoBufferManager()
{
CSingleLock lock(m_critSection);
std::shared_ptr<IVideoBufferPool> pool = std::make_shared<CVideoBufferPoolSysMem>();
RegisterPool(pool);
}

void CVideoBufferManager::RegisterPool(std::shared_ptr<IVideoBufferPool> pool)
{
CSingleLock lock(m_critSection);
// preferred pools are to the front
m_pools.push_front(pool);
}

void CVideoBufferManager::ReleasePools()
{
CSingleLock lock(m_critSection);
std::list<std::shared_ptr<IVideoBufferPool>> pools = m_pools;
m_pools.clear();
std::shared_ptr<IVideoBufferPool> pool = std::make_shared<CVideoBufferPoolSysMem>();
Expand All @@ -372,6 +375,7 @@ void CVideoBufferManager::ReleasePools()

CVideoBuffer* CVideoBufferManager::Get(AVPixelFormat format, int width, int height)
{
CSingleLock lock(m_critSection);
for (auto pool: m_pools)
{
if (!pool->IsConfigured())
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoPlayer/Process/VideoBuffer.h
Expand Up @@ -163,5 +163,6 @@ class CVideoBufferManager
CVideoBuffer* Get(AVPixelFormat format, int width, int height);

protected:
CCriticalSection m_critSection;
std::list<std::shared_ptr<IVideoBufferPool>> m_pools;
};

0 comments on commit 3ecf181

Please sign in to comment.