bool CVDPAU::CheckRecover(bool force) { if (recover || force) { CLog::Log(LOGNOTICE,"Attempting recovery"); FiniVDPAUOutput(); FiniVDPAUProcs(); recover = false; InitVDPAUProcs(); return true; } return false; }
int CVDPAU::Check(AVCodecContext* avctx) { EDisplayState state; { CSharedLock lock(m_DisplaySection); state = m_DisplayState; } if (state == VDPAU_LOST) { CLog::Log(LOGNOTICE,"CVDPAU::Check waiting for display reset event"); if (!m_DisplayEvent.WaitMSec(2000)) { CLog::Log(LOGERROR, "CVDPAU::Check - device didn't reset in reasonable time"); return VC_ERROR; } { CSharedLock lock(m_DisplaySection); state = m_DisplayState; } } if (state == VDPAU_RESET || state == VDPAU_ERROR) { CLog::Log(LOGNOTICE,"Attempting recovery"); CSingleLock gLock(g_graphicsContext); CExclusiveLock lock(m_DecoderSection); FiniVDPAUOutput(); FiniVDPAUProcs(); InitVDPAUProcs(); if (state == VDPAU_RESET) return VC_FLUSHED; else return VC_ERROR; } return 0; }
bool CVDPAU::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces) { if(avctx->width == 0 || avctx->height == 0) { CLog::Log(LOGWARNING,"(VDPAU) no width/height available, can't init"); return false; } if (!dl_handle) { dl_handle = dlopen("libvdpau.so.1", RTLD_LAZY); if (!dl_handle) { const char* error = dlerror(); if (!error) error = "dlerror() returned NULL"; CLog::Log(LOGNOTICE,"(VDPAU) Unable to get handle to libvdpau: %s", error); //g_application.m_guiDialogKaiToast.QueueNotification(CGUIDialogKaiToast::Error, "VDPAU", error, 10000); return false; } } InitVDPAUProcs(); if (vdp_device != VDP_INVALID_HANDLE) { SpewHardwareAvailable(); VdpDecoderProfile profile = 0; if(avctx->codec_id == CODEC_ID_H264) profile = VDP_DECODER_PROFILE_H264_HIGH; #ifdef VDP_DECODER_PROFILE_MPEG4_PART2_ASP else if(avctx->codec_id == CODEC_ID_MPEG4) profile = VDP_DECODER_PROFILE_MPEG4_PART2_ASP; #endif if(profile) { if (!CDVDCodecUtils::IsVP3CompatibleWidth(avctx->width)) CLog::Log(LOGWARNING,"(VDPAU) width %i might not be supported because of hardware bug", avctx->width); /* attempt to create a decoder with this width/height, some sizes are not supported by hw */ VdpStatus vdp_st; vdp_st = vdp_decoder_create(vdp_device, profile, avctx->width, avctx->height, 5, &decoder); if(vdp_st != VDP_STATUS_OK) { CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) checking for decoder support\n", vdp_get_error_string(vdp_st), vdp_st); FiniVDPAUProcs(); return false; } vdp_decoder_destroy(decoder); CheckStatus(vdp_st, __LINE__); } InitCSCMatrix(avctx->height); MakePixmap(avctx->width,avctx->height); /* finally setup ffmpeg */ avctx->get_buffer = CVDPAU::FFGetBuffer; avctx->release_buffer = CVDPAU::FFReleaseBuffer; avctx->draw_horiz_band = CVDPAU::FFDrawSlice; avctx->slice_flags=SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD; return true; } return false; }