当前位置: 首页>>代码示例>>C++>>正文


C++ CCECBusDevice::IsHandledByLibCEC方法代码示例

本文整理汇总了C++中CCECBusDevice::IsHandledByLibCEC方法的典型用法代码示例。如果您正苦于以下问题:C++ CCECBusDevice::IsHandledByLibCEC方法的具体用法?C++ CCECBusDevice::IsHandledByLibCEC怎么用?C++ CCECBusDevice::IsHandledByLibCEC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCECBusDevice的用法示例。


在下文中一共展示了CCECBusDevice::IsHandledByLibCEC方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Transmit

bool CCECProcessor::Transmit(const cec_command &data, bool bIsReply)
{
  cec_command transmitData(data);
  uint8_t iMaxTries(0);
  bool bRetry(true);
  uint8_t iTries(0);

  // get the current timeout setting
  uint8_t iLineTimeout(GetStandardLineTimeout());

  // reset the state of this message to 'unknown'
  cec_adapter_message_state adapterState = ADAPTER_MESSAGE_STATE_UNKNOWN;

  if (!m_communication->SupportsSourceLogicalAddress(transmitData.initiator))
  {
    if (transmitData.initiator == CECDEVICE_UNREGISTERED && m_communication->SupportsSourceLogicalAddress(CECDEVICE_FREEUSE))
    {
      m_libcec->AddLog(CEC_LOG_DEBUG, "initiator '%s' is not supported by the CEC adapter. using '%s' instead", ToString(transmitData.initiator), ToString(CECDEVICE_FREEUSE));
      transmitData.initiator = CECDEVICE_FREEUSE;
    }
    else
    {
      m_libcec->AddLog(CEC_LOG_DEBUG, "initiator '%s' is not supported by the CEC adapter", ToString(transmitData.initiator));
      return false;
    }
  }

  LogOutput(transmitData);

  // find the initiator device
  CCECBusDevice *initiator = m_busDevices->At(transmitData.initiator);
  if (!initiator)
  {
    m_libcec->AddLog(CEC_LOG_WARNING, "invalid initiator");
    return false;
  }

  // find the destination device, if it's not the broadcast address
  if (transmitData.destination != CECDEVICE_BROADCAST)
  {
    // check if the device is marked as handled by libCEC
    CCECBusDevice *destination = m_busDevices->At(transmitData.destination);
    if (destination && destination->IsHandledByLibCEC())
    {
      // and reject the command if it's trying to send data to a device that is handled by libCEC
      m_libcec->AddLog(CEC_LOG_WARNING, "not sending data to myself!");
      return false;
    }
  }

  // wait until we finished allocating a new LA if it got lost
  while (m_bStallCommunication) Sleep(5);

  {
    CLockObject lock(m_mutex);
    m_iLastTransmission = GetTimeMs();
    // set the number of tries
    iMaxTries = initiator->GetHandler()->GetTransmitRetries() + 1;
    initiator->MarkHandlerReady();
  }

  // and try to send the command
  while (bRetry && ++iTries < iMaxTries)
  {
    if (initiator->IsUnsupportedFeature(transmitData.opcode))
      return false;

    adapterState = !IsStopped() && m_communication && m_communication->IsOpen() ?
        m_communication->Write(transmitData, bRetry, iLineTimeout, bIsReply) :
        ADAPTER_MESSAGE_STATE_ERROR;
    iLineTimeout = m_iRetryLineTimeout;
  }

  return bIsReply ?
      adapterState == ADAPTER_MESSAGE_STATE_SENT_ACKED || adapterState == ADAPTER_MESSAGE_STATE_SENT || adapterState == ADAPTER_MESSAGE_STATE_WAITING_TO_BE_SENT :
      adapterState == ADAPTER_MESSAGE_STATE_SENT_ACKED;
}
开发者ID:1234qaz,项目名称:libcec,代码行数:77,代码来源:CECProcessor.cpp


注:本文中的CCECBusDevice::IsHandledByLibCEC方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。