Пример #1
0
void CRenderManager::StartRenderCapture(unsigned int captureId, unsigned int width, unsigned int height, int flags)
{
    CSingleLock lock(m_captCritSect);

    std::map<unsigned int, CRenderCapture*>::iterator it;
    it = m_captures.find(captureId);
    if (it == m_captures.end())
    {
        CLog::Log(LOGERROR, "CRenderManager::Capture - unknown capture id: %d", captureId);
        return;
    }

    CRenderCapture *capture = it->second;

    capture->SetState(CAPTURESTATE_NEEDSRENDER);
    capture->SetUserState(CAPTURESTATE_WORKING);
    capture->SetWidth(width);
    capture->SetHeight(height);
    capture->SetFlags(flags);
    capture->GetEvent().Reset();

    if (g_application.IsCurrentThread())
    {
        if (flags & CAPTUREFLAG_IMMEDIATELY)
        {
            //render capture and read out immediately
            RenderCapture(capture);
            capture->SetUserState(capture->GetState());
            capture->GetEvent().Set();
        }
    }

    if (!m_captures.empty())
        m_hasCaptures = true;
}
Пример #2
0
void CXBMCRenderManager::ManageCaptures()
{
  //no captures, return here so we don't do an unnecessary lock
  if (!m_hasCaptures)
    return;

  CSingleLock lock(m_captCritSect);

  std::list<CRenderCapture*>::iterator it = m_captures.begin();
  while (it != m_captures.end())
  {
    CRenderCapture* capture = *it;

    if (capture->GetState() == CAPTURESTATE_NEEDSDELETE)
    {
      delete capture;
      it = m_captures.erase(it);
      continue;
    }

    if (capture->GetState() == CAPTURESTATE_NEEDSRENDER)
      RenderCapture(capture);
    else if (capture->GetState() == CAPTURESTATE_NEEDSREADOUT)
      capture->ReadOut();

    if (capture->GetState() == CAPTURESTATE_DONE || capture->GetState() == CAPTURESTATE_FAILED)
    {
      //tell the thread that the capture is done or has failed
      capture->SetUserState(capture->GetState());
      capture->GetEvent().Set();

      if (capture->GetFlags() & CAPTUREFLAG_CONTINUOUS)
      {
        capture->SetState(CAPTURESTATE_NEEDSRENDER);

        //if rendering this capture continuously, and readout is async, render a new capture immediately
        if (capture->IsAsync() && !(capture->GetFlags() & CAPTUREFLAG_IMMEDIATELY))
          RenderCapture(capture);

        it++;
      }
      else
      {
        it = m_captures.erase(it);
      }
    }
    else
    {
      it++;
    }
  }

  if (m_captures.empty())
    m_hasCaptures = false;
}