cec: added GetOSDName()/cec_get_osd_name(). only request the values we need in CCECPr...
[deb_libcec.git] / src / lib / CECProcessor.cpp
index d8fdb99f145a1763a6f11a8588178116fb702e19..8c95da7294a4fe866115ca6003947f7961fe173a 100644 (file)
@@ -231,6 +231,8 @@ void *CCECProcessor::Process(void)
 
     SetAckMask(m_logicalAddresses.AckMask());
 
+    ScanCECBus();
+
     {
       CLockObject lock(&m_mutex);
       m_bStarted = true;
@@ -385,6 +387,21 @@ bool CCECProcessor::SetHDMIPort(uint8_t iPort)
   return bReturn;
 }
 
+void CCECProcessor::ScanCECBus(void)
+{
+  CCECBusDevice *device(NULL);
+  for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
+  {
+    device = m_busDevices[iPtr];
+    if (device && device->GetStatus() == CEC_DEVICE_STATUS_PRESENT)
+    {
+      device->GetPhysicalAddress();
+      device->GetCecVersion();
+      device->GetVendorId();
+    }
+  }
+}
+
 bool CCECProcessor::CheckPhysicalAddress(uint16_t iPhysicalAddress)
 {
   for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
@@ -488,7 +505,11 @@ bool CCECProcessor::SwitchMonitoring(bool bEnable)
 bool CCECProcessor::PollDevice(cec_logical_address iAddress)
 {
   if (iAddress != CECDEVICE_UNKNOWN && m_busDevices[iAddress])
-    return m_busDevices[m_logicalAddresses.primary]->TransmitPoll(iAddress);
+  {
+    return m_logicalAddresses.primary == CECDEVICE_UNKNOWN ?
+        m_busDevices[iAddress]->TransmitPoll(iAddress) :
+        m_busDevices[m_logicalAddresses.primary]->TransmitPoll(iAddress);
+  }
   return false;
 }
 
@@ -558,6 +579,17 @@ cec_version CCECProcessor::GetDeviceCecVersion(cec_logical_address iAddress)
   return m_busDevices[iAddress]->GetCecVersion();
 }
 
+cec_osd_name CCECProcessor::GetDeviceOSDName(cec_logical_address iAddress)
+{
+  CStdString strOSDName = m_busDevices[iAddress]->GetOSDName();
+  cec_osd_name retVal;
+
+  snprintf(retVal.name, sizeof(retVal.name), "%s", strOSDName.c_str());
+  retVal.device = iAddress;
+
+  return retVal;
+}
+
 bool CCECProcessor::GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language)
 {
   if (m_busDevices[iAddress])
@@ -813,3 +845,13 @@ bool CCECProcessor::SetAckMask(uint16_t iMask)
 
   return bReturn;
 }
+
+bool CCECProcessor::SendKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait /* = false */)
+{
+  return m_busDevices[iDestination]->SendKeypress(key, bWait);
+}
+
+bool CCECProcessor::SendKeyRelease(cec_logical_address iDestination, bool bWait /* = false */)
+{
+  return m_busDevices[iDestination]->SendKeyRelease(bWait);
+}