Skip to content

Commit

Permalink
DXVA: only allow a single dxva decoder to be opened
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Sep 7, 2014
1 parent b92d51f commit 00bc18f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.cpp
Expand Up @@ -504,6 +504,13 @@ bool CDXVAContext::CreateSurfaces(int width, int height, D3DFORMAT format, unsig

bool CDXVAContext::CreateDecoder(GUID &inGuid, DXVA2_VideoDesc *format, const DXVA2_ConfigPictureDecode *config, LPDIRECT3DSURFACE9 *surfaces, unsigned int count, IDirectXVideoDecoder **decoder)
{
CSingleLock lock(m_section);
std::vector<CDecoder*>::iterator it;
for (it = m_decoders.begin(); it != m_decoders.end(); ++it)
{
(*it)->CloseDXVADecoder();
}

HRESULT res = m_service->CreateVideoDecoder(inGuid, format, config, surfaces, count, decoder);
if (FAILED(res))
{
Expand Down Expand Up @@ -1036,6 +1043,10 @@ void CDecoder::RelBuffer(uint8_t *data)
int CDecoder::GetBuffer(AVCodecContext *avctx, AVFrame *pic, int flags)
{
CSingleLock lock(m_section);

if (!m_decoder)
return -1;

if(avctx->coded_width != m_format.SampleWidth
|| avctx->coded_height != m_format.SampleHeight)
{
Expand Down Expand Up @@ -1107,6 +1118,12 @@ unsigned CDecoder::GetAllowedReferences()
}


void CDecoder::CloseDXVADecoder()
{
CSingleLock lock(m_section);
SAFE_RELEASE(m_decoder);
}

//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//------------------------ PROCESSING SERVICE -------------------------------
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.h
Expand Up @@ -97,6 +97,7 @@ class CDecoder

static bool Supports(enum PixelFormat fmt);

void CloseDXVADecoder();

protected:
enum EDeviceState
Expand Down

0 comments on commit 00bc18f

Please sign in to comment.