Example #1
0
void CApplicationMessenger::ProcessMessages()
{
  // process threadmessages
  CSingleLock lock (m_critSection);
  while (!m_vecMessages.empty())
  {
    ThreadMessage* pMsg = m_vecMessages.front();
    //first remove the message from the queue, else the message could be processed more then once
    m_vecMessages.pop();

    //Leave here as the message might make another
    //thread call processmessages or sendmessage

    std::shared_ptr<CEvent> waitEvent = pMsg->waitEvent;
    lock.Leave(); // <- see the large comment in SendMessage ^

    ProcessMessage(pMsg);
    
    if (waitEvent)
      waitEvent->Set();
    delete pMsg;

    lock.Enter();
  }
}
Example #2
0
unsigned int CDVDAudio::AddPackets(const DVDAudioFrame &audioframe)
{
  m_bAbort = false;

  CSingleLock lock (m_critSection);

  if(!m_pAudioStream)
    return 0;

  CAESyncInfo info = m_pAudioStream->GetSyncInfo();
  if (info.state == CAESyncInfo::SYNC_INSYNC)
  {
    unsigned int newTime = info.errortime;
    if (newTime != m_syncErrorTime)
    {
      m_syncErrorTime = info.errortime;
      m_syncError = info.error / 1000 * DVD_TIME_BASE;
      m_resampleRatio = info.rr;
    }
  }
  else
  {
    m_syncErrorTime = 0;
    m_syncError = 0.0;
  }

  //Calculate a timeout when this definitely should be done
  double timeout;
  timeout  = DVD_SEC_TO_TIME(m_pAudioStream->GetDelay()) + audioframe.duration;
  timeout += DVD_SEC_TO_TIME(1.0);
  timeout += CDVDClock::GetAbsoluteClock();

  unsigned int total = audioframe.nb_frames;
  unsigned int frames = audioframe.nb_frames;
  unsigned int offset = 0;
  do
  {
    double pts = (offset == 0) ? audioframe.pts / DVD_TIME_BASE * 1000 : 0.0;
    unsigned int copied = m_pAudioStream->AddData(audioframe.data, offset, frames, pts);
    offset += copied;
    frames -= copied;
    if (frames <= 0)
      break;

    if (copied == 0 && timeout < CDVDClock::GetAbsoluteClock())
    {
      CLog::Log(LOGERROR, "CDVDAudio::AddPacketsRenderer - timeout adding data to renderer");
      break;
    }

    lock.Leave();
    Sleep(1);
    lock.Enter();
  } while (!m_bAbort);

  m_playingPts = audioframe.pts + audioframe.duration - GetDelay();
  m_timeOfPts = CDVDClock::GetAbsoluteClock();

  return total - frames;
}
void CApplicationMessenger::ProcessWindowMessages()
{
  CSingleLock lock (m_critSection);
  //message type is window, process window messages
  while (m_vecWindowMessages.size() > 0)
  {
    ThreadMessage* pMsg = m_vecWindowMessages.front();
    //first remove the message from the queue, else the message could be processed more then once
    m_vecWindowMessages.pop();

    // leave here in case we make more thread messages from this one
    lock.Leave();

    ProcessMessage(pMsg);
    if (pMsg->hWaitEvent)
      SetEvent(pMsg->hWaitEvent);
    delete pMsg;

    lock.Enter();
  }
}
Example #4
0
void CApplicationMessenger::ProcessMessages()
{
/*
	参数:
		1、
		
	返回:
		1、
		
	说明:
		1、处理消息,实质就是从m_vecMessages  队列中取出每个消息,然后分别对此
			消息调用ProcessMessage  进行处理,见消息队列m_vecMessages 的定义

		2、注意此函数与ProcessMessage 方法的区别( 注意此函数多一个s  字母),此函数
			是处理m_vecMessages  队列中的所有消息的,而ProcessMessage  只是处理一个消息
*/
	// process threadmessages
	CSingleLock lock (m_critSection);
	while (m_vecMessages.size() > 0)
	{
		ThreadMessage* pMsg = m_vecMessages.front();
		//first remove the message from the queue, else the message could be processed more then once
		m_vecMessages.pop();

		//Leave here as the message might make another
		//thread call processmessages or sendmessage

		boost::shared_ptr<CEvent> waitEvent = pMsg->waitEvent; 
		lock.Leave(); // <- see the large comment in SendMessage ^

		ProcessMessage(pMsg); /* 处理一条消息*/
		
		if (waitEvent)
			waitEvent->Set();
		
		delete pMsg;

		lock.Enter();
	}
}
void CApplicationMessenger::ProcessMessages()
{
  // process threadmessages
  CSingleLock lock (m_critSection);
  while (m_vecMessages.size() > 0)
  {
    ThreadMessage* pMsg = m_vecMessages.front();
    //first remove the message from the queue, else the message could be processed more then once
    m_vecMessages.pop();

    //Leave here as the message might make another
    //thread call processmessages or sendmessage
    lock.Leave();

    ProcessMessage(pMsg);
    if (pMsg->hWaitEvent)
      SetEvent(pMsg->hWaitEvent);
    delete pMsg;

    lock.Enter();
  }
}
void CApplicationMessenger::ProcessWindowMessages()
{
  CSingleLock lock (m_critSection);
  //message type is window, process window messages
  while (!m_vecWindowMessages.empty())
  {
    ThreadMessage* pMsg = m_vecWindowMessages.front();
    //first remove the message from the queue, else the message could be processed more then once
    m_vecWindowMessages.pop();

    // leave here in case we make more thread messages from this one

    std::shared_ptr<CEvent> waitEvent = pMsg->waitEvent;
    lock.Leave(); // <- see the large comment in SendMessage ^

    ProcessMessage(pMsg);
    if (waitEvent)
      waitEvent->Set();
    delete pMsg;

    lock.Enter();
  }
}
Example #7
0
void CApplicationMessenger::ProcessWindowMessages()
{
/*
	参数:
		1、
		
	返回:
		1、
		
	说明:
		1、处理消息,实质就是从m_vecWindowMessages  队列中取出每个消息,然后分别对此
			消息调用ProcessMessage  进行处理
		2、见消息队列m_vecWindowMessages 的定义
*/
	CSingleLock lock (m_critSection);
	//message type is window, process window messages
	while (m_vecWindowMessages.size() > 0)
	{
		ThreadMessage* pMsg = m_vecWindowMessages.front();
		//first remove the message from the queue, else the message could be processed more then once
		m_vecWindowMessages.pop();

		// leave here in case we make more thread messages from this one

		boost::shared_ptr<CEvent> waitEvent = pMsg->waitEvent;
		lock.Leave(); // <- see the large comment in SendMessage ^

		ProcessMessage(pMsg);
		if (waitEvent)
			waitEvent->Set();
		
		delete pMsg;

		lock.Enter();
	}
}