bool VideoOutputOpenGLVAAPI::CreateVAAPIContext(QSize size) { // FIXME During a video stream change this is called from the decoder // thread - which breaks all other efforts to remove non-UI thread // access to the OpenGL context. There is no obvious fix however - if we // don't delete and re-create the VAAPI decoder context immediately then // the decoder fails and playback exits. OpenGLLocker ctx_lock(gl_context); if (m_ctx) DeleteVAAPIContext(); m_ctx = new VAAPIContext(video_codec_id); if (m_ctx && m_ctx->CreateDisplay(size) && m_ctx->CreateBuffers()) { int num_buffers = m_ctx->GetNumBuffers(); const QSize video_dim = window.GetActualVideoDim(); bool ok = true; for (int i = 0; i < num_buffers; i++) { ok &= vbuffers.CreateBuffer(video_dim.width(), video_dim.height(), i, m_ctx->GetVideoSurface(i), FMT_VAAPI); } InitPictureAttributes(); return ok; } LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create VAAPI context."); errorState = kError_Unknown; return false; }
bool VideoOutputOpenGLVAAPI::CreateVAAPIContext(QSize size) { // FIXME During a video stream change this is called from the decoder // thread - which breaks all other efforts to remove non-UI thread // access to the OpenGL context. There is no obvious fix however - if we // don't delete and re-create the VAAPI decoder context immediately then // the decoder fails and playback exits. // lvr 27-oct-13 // in 0.27 if m_ctx->CreateDisplay is called outside of the UI thread then // it fails, which then causes subsequent unbalanced calls to doneCurrent // which results in Qt aborting. So just fail if non-UI. if (!gCoreContext->IsUIThread()) { LOG(VB_GENERAL, LOG_ERR, LOC + "CreateVAAPIContext called from non-UI thread"); return false; } OpenGLLocker ctx_lock(gl_context); if (m_ctx) DeleteVAAPIContext(); m_ctx = new VAAPIContext(kVADisplayGLX, video_codec_id); if (m_ctx && m_ctx->CreateDisplay(size) && m_ctx->CreateBuffers()) { int num_buffers = m_ctx->GetNumBuffers(); const QSize video_dim = window.GetActualVideoDim(); bool ok = true; for (int i = 0; i < num_buffers; i++) { ok &= vbuffers.CreateBuffer(video_dim.width(), video_dim.height(), i, m_ctx->GetVideoSurface(i), FMT_VAAPI); } InitPictureAttributes(); return ok; } LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create VAAPI context."); errorState = kError_Unknown; return false; }
void VideoOutputOpenGLVAAPI::TearDown(void) { DeleteVAAPIContext(); }