Permalink
Browse files

vdpau: remove recover variable and use diplay state

  • Loading branch information...
1 parent dbbb968 commit f4e13417f6e7d6f19c709592793640b6b80ddd89 @FernetMenta FernetMenta committed Oct 15, 2011
Showing with 28 additions and 16 deletions.
  1. +25 −14 xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
  2. +3 −2 xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h
@@ -92,7 +92,7 @@ CVDPAU::CVDPAU()
surfaceNum = presentSurfaceNum = 0;
picAge.b_age = picAge.ip_age[0] = picAge.ip_age[1] = 256*256*256*64;
vdpauConfigured = false;
- recover = false;
+ m_DisplayState = VDPAU_OPEN;
m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
m_mixerstep = 0;
m_DisplayState = VDPAU_OPEN;
@@ -443,7 +443,7 @@ int CVDPAU::Check(AVCodecContext* avctx)
}
lock.Enter();
}
- if (recover || m_DisplayState == VDPAU_RESET)
+ if (m_DisplayState == VDPAU_RESET)
{
CLog::Log(LOGNOTICE,"Attempting recovery");
@@ -452,7 +452,6 @@ int CVDPAU::Check(AVCodecContext* avctx)
InitVDPAUProcs();
- recover = false;
m_DisplayState = VDPAU_OPEN;
return VC_FLUSHED;
@@ -1038,10 +1037,12 @@ int CVDPAU::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
struct pictureAge* pA = &vdp->picAge;
// while we are waiting to recover we can't do anything
- if(vdp->recover)
- {
- CLog::Log(LOGWARNING, "CVDPAU::FFGetBuffer - returning due to awaiting recovery");
- return -1;
+ { CSingleLock lock(vdp->m_DisplaySection);
+ if(vdp->m_DisplayState != VDPAU_OPEN)
+ {
+ CLog::Log(LOGWARNING, "CVDPAU::FFGetBuffer - returning due to awaiting recovery");
+ return -1;
+ }
}
vdpau_render_state * render = NULL;
@@ -1134,9 +1135,11 @@ void CVDPAU::FFDrawSlice(struct AVCodecContext *s,
CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)s->opaque;
CVDPAU* vdp = (CVDPAU*)ctx->GetHardware();
- /* while we are waiting to recover we can't do anything */
- if(vdp->recover)
- return;
+ // while we are waiting to recover we can't do anything
+ { CSingleLock lock(vdp->m_DisplaySection);
+ if(vdp->m_DisplayState != VDPAU_OPEN)
+ return;
+ }
if(src->linesize[0] || src->linesize[1] || src->linesize[2]
|| offset[0] || offset[1] || offset[2])
@@ -1433,23 +1436,31 @@ void CVDPAU::VDPPreemptionCallbackFunction(VdpDevice device, void* context)
{
CLog::Log(LOGDEBUG,"VDPAU Device Preempted - attempting recovery");
CVDPAU* pCtx = (CVDPAU*)context;
- pCtx->recover = true;
+
+ { CSingleLock lock(pCtx->m_DisplaySection);
+ if(pCtx->m_DisplayState == VDPAU_OPEN)
+ pCtx->m_DisplayState = VDPAU_RESET;
+ }
}
bool CVDPAU::CheckStatus(VdpStatus vdp_st, int line)
{
+ CSingleLock lock(m_DisplaySection);
+
if (vdp_st == VDP_STATUS_HANDLE_DEVICE_MISMATCH
|| vdp_st == VDP_STATUS_DISPLAY_PREEMPTED)
- recover = true;
+ if(m_DisplayState == VDPAU_OPEN)
+ m_DisplayState = VDPAU_RESET;
// no need to log errors about this case, as it will happen on cleanup
- if (vdp_st == VDP_STATUS_INVALID_HANDLE && recover && vdpauConfigured)
+ if (vdp_st == VDP_STATUS_INVALID_HANDLE && (m_DisplayState != VDPAU_OPEN) && vdpauConfigured)
return false;
if (vdp_st != VDP_STATUS_OK)
{
CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
- recover = true;
+ if(m_DisplayState == VDPAU_OPEN)
+ m_DisplayState = VDPAU_RESET;
return true;
}
return false;
@@ -102,7 +102,6 @@ class CVDPAU
void InitCSCMatrix(int Height);
bool CheckStatus(VdpStatus vdp_st, int line);
- bool CheckRecover(bool force = false);
void CheckFeatures();
void SetColor();
void SetNoiseReduction();
@@ -111,7 +110,6 @@ class CVDPAU
void SetHWUpscaling();
pictureAge picAge;
- bool recover;
vdpau_render_state *past[2], *current, *future;
int tmpDeintMode, tmpDeintGUI, tmpDeint;
float tmpNoiseReduction, tmpSharpness;
@@ -226,6 +224,9 @@ class CVDPAU
std::vector<vdpau_render_state*> m_videoSurfaces;
+ // OnLostDevice triggers transition from all states to LOST
+ // internal errors trigger transition from OPEN to RESET
+ // OnResetDevice triggers transition from LOST to RESET
enum EDisplayState
{ VDPAU_OPEN
, VDPAU_RESET

0 comments on commit f4e1341

Please sign in to comment.