Exemplo n.º 1
0
void CInputCodingTableBaiduPY::Process()
{
  while (!m_bStop) //Make sure we don't exit the thread
  {
    AbortableWait(m_Event, -1); //Wait for work to appear
    while (!m_bStop) //Process all queued work before going back to wait on the event
    {
      CSingleLock lock(m_CS);
      if (m_work.empty())
        break;

      auto work = m_work.front();
      m_work.pop_front();
      lock.Leave();

      std::string data;
      XFILE::CCurlFile http;
      std::string strUrl;
      strUrl = StringUtils::Format(m_url.c_str(), work.c_str(), m_api_begin, m_api_end);

      if (http.Get(strUrl, data))
        HandleResponse(work, data);
    }
  }
}
Exemplo n.º 2
0
void CWin32PowerStateWorker::Process(void)
{
  while (!m_bStop)
  {
    if (AbortableWait(m_queryEvent, -1) == WAIT_SIGNALED)
    {
      PowerManagement(m_state.load());
      m_state.exchange(POWERSTATE_NONE);
      m_queryEvent.Reset();
    }
  }
}
Exemplo n.º 3
0
void CScrobbler::Process()
{
    CLog::Log(LOGDEBUG, "%s: Thread started.", m_strLogPrefix.c_str());
    if (!m_pHttp)
    {
        // Hack since CCurlFile isn't threadsafe
        if (!(m_pHttp = new XFILE::CCurlFile))
            return;
    }
    while (!m_bStop)
    {
        AbortableWait(m_hEvent);
        if (m_bStop)
            break;

        if (m_strSessionID.IsEmpty())
        {
            time_t now = time(NULL);
            // We need to handshake.
            if (m_bBanned || m_bBadAuth ||
                    ((now - m_lastFailedHandshake) < m_failedHandshakeDelay))
                continue;
            if (!DoHandshake(now))
                continue;
        }
        int action = 0;
        {
            CSingleLock lock(m_actionLock);
            action = m_action;
            m_action = 0;
        }
        if (action == SCROBBLER_ACTION_NOWPLAYING)
            DoNowPlayingNotification();
        else if (action == SCROBBLER_ACTION_SUBMIT)
        {
            m_bSubmitting = true;
            DoSubmission();
            m_bSubmitting = false;
        }
    }
    delete m_pHttp; // More of aforementioned hack
    m_pHttp = NULL;
    CLog::Log(LOGDEBUG, "%s: Thread ended.", m_strLogPrefix.c_str());
}
Exemplo n.º 4
0
void CRemoteControl::Process()
{
  struct sockaddr_un addr;
  if (m_deviceName.length() >= sizeof(addr.sun_path))
  {
    CLog::Log(LOGERROR, "LIRC %s: device name is too long (%" PRIdS"), maximum is %" PRIdS"",
              __FUNCTION__, m_deviceName.length(), sizeof(addr.sun_path));
    return;
  }

  addr.sun_family = AF_UNIX;
  strcpy(addr.sun_path, m_deviceName.c_str());

  CLog::Log(LOGINFO, "LIRC %s: using: %s", __FUNCTION__, addr.sun_path);

  int iAttempt = 0;
  unsigned int iMsRetryDelay = 5000;

  // try to connect 60 times @ a 5 second interval (5 minutes)
  // multiple tries because LIRC service might be up and running a little later then xbmc on boot.
  while (!m_bStop && iAttempt <= 60)
  {
    if (Connect(addr, iAttempt == 0))
    {
      m_bInitialized = true;
      break;
    }

    if (iAttempt == 0)
      CLog::Log(LOGINFO, "CRemoteControl::Process - failed to connect to LIRC, will keep retrying every %d seconds", iMsRetryDelay / 1000);

    ++iAttempt;

    if (AbortableWait(m_event, iMsRetryDelay) == WAIT_INTERRUPTED)
      break;
  }

  if (!m_bInitialized)
  {
    CLog::Log(LOGDEBUG, "Failed to connect to LIRC. Giving up.");
  }
}
Exemplo n.º 5
0
void CRetroPlayerVideo::Process()
{
  while (!m_bStop)
  {
    // 1s should be a good failsafe if the event isn't triggered (shouldn't happen)
    if (AbortableWait(m_frameEvent, 1000) == WAIT_INTERRUPTED)
      break;

    VideoFrame *frame = NULL;
    m_buffer.GetPacket(frame);
    if (!frame)
      continue;

    if (!ProcessFrame(*frame))
      break;
  }

  // Clean up
  if (m_swsContext)
    sws_freeContext(m_swsContext);
}