Skip to content

Commit

Permalink
Allow VAAPI profile to be used more than once in a row.
Browse files Browse the repository at this point in the history
Fixes #11746
  • Loading branch information
jyavenard committed Aug 13, 2013
1 parent 4fdb43b commit 57ee052
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions mythtv/libs/libmythtv/vaapicontext.cpp
Expand Up @@ -185,8 +185,19 @@ class VAAPIDisplay : ReferenceCounter
return ret;
}

static VAAPIDisplay *GetDisplay(VAAPIDisplayType display_type)
static VAAPIDisplay *GetDisplay(VAAPIDisplayType display_type, bool noreuse)
{
if (noreuse)
{
VAAPIDisplay *tmp = new VAAPIDisplay(display_type);
if (tmp->Create())
{
return tmp;
}
tmp->DecrRef();
return NULL;
}

QMutexLocker locker(&s_VAAPIDisplayLock);

if (s_VAAPIDisplay)
Expand All @@ -202,7 +213,7 @@ class VAAPIDisplay : ReferenceCounter
}

s_VAAPIDisplay = new VAAPIDisplay(display_type);
if (s_VAAPIDisplay && s_VAAPIDisplay->Create())
if (s_VAAPIDisplay->Create())
return s_VAAPIDisplay;

s_VAAPIDisplay->DecrRef();
Expand All @@ -225,7 +236,7 @@ bool VAAPIContext::IsFormatAccelerated(QSize size, MythCodecID codec,
{
bool result = false;
VAAPIContext *ctx = new VAAPIContext(kVADisplayX11, codec);
if (ctx && ctx->CreateDisplay(size))
if (ctx->CreateDisplay(size, true))
{
pix_fmt = ctx->GetPixelFormat();
result = pix_fmt == PIX_FMT_VAAPI_VLD;
Expand Down Expand Up @@ -298,11 +309,11 @@ VAAPIContext::~VAAPIContext()
LOG(VB_PLAYBACK, LOG_INFO, LOC + "Deleted context");
}

bool VAAPIContext::CreateDisplay(QSize size)
bool VAAPIContext::CreateDisplay(QSize size, bool noreuse)
{
m_size = size;
bool ok = true;
m_display = VAAPIDisplay::GetDisplay(m_dispType);
m_display = VAAPIDisplay::GetDisplay(m_dispType, noreuse);
CREATE_CHECK(!m_size.isEmpty(), "Invalid size");
CREATE_CHECK(m_display != NULL, "Invalid display");
CREATE_CHECK(InitDisplay(), "Invalid VADisplay");
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/vaapicontext.h
Expand Up @@ -34,7 +34,7 @@ class VAAPIContext
VAAPIContext(VAAPIDisplayType display_type, MythCodecID codec);
~VAAPIContext();

bool CreateDisplay(QSize size);
bool CreateDisplay(QSize size, bool noreuse = false);
bool CreateBuffers(void);
void* GetVideoSurface(int i);
uint8_t* GetSurfaceIDPointer(void* buf);
Expand Down

0 comments on commit 57ee052

Please sign in to comment.